Skip to content

Commit 1b1390e

Browse files
committed
manually update type for now
1 parent e68aa19 commit 1b1390e

File tree

2 files changed

+24
-34
lines changed

2 files changed

+24
-34
lines changed

src/together/cli/api/endpoints.py

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,9 @@
1313

1414

1515
def print_endpoint(
16-
endpoint: Union[DedicatedEndpoint, ListEndpoint], json: bool = False
16+
endpoint: Union[DedicatedEndpoint, ListEndpoint],
1717
) -> None:
1818
"""Print endpoint details in a Docker-like format or JSON."""
19-
if json:
20-
import json as json_lib
21-
22-
output: Dict[str, Any] = {
23-
"id": endpoint.id,
24-
"name": endpoint.name,
25-
"model": endpoint.model,
26-
"type": endpoint.type,
27-
"owner": endpoint.owner,
28-
"state": endpoint.state,
29-
"created_at": endpoint.created_at.isoformat(),
30-
}
31-
32-
if isinstance(endpoint, DedicatedEndpoint):
33-
output.update(
34-
{
35-
"display_name": endpoint.display_name,
36-
"hardware": endpoint.hardware,
37-
"autoscaling": {
38-
"min_replicas": endpoint.autoscaling.min_replicas,
39-
"max_replicas": endpoint.autoscaling.max_replicas,
40-
},
41-
}
42-
)
43-
44-
click.echo(json_lib.dumps(output, indent=2))
45-
return
4619

4720
# Print header info
4821
click.echo(f"ID:\t\t{endpoint.id}")
@@ -244,7 +217,12 @@ def create(
244217
def get(client: Together, endpoint_id: str, json: bool) -> None:
245218
"""Get a dedicated inference endpoint."""
246219
endpoint = client.endpoints.get(endpoint_id)
247-
print_endpoint(endpoint, json=json)
220+
if json:
221+
import json as json_lib
222+
223+
click.echo(json_lib.dumps(endpoint.model_dump(), indent=2))
224+
else:
225+
print_endpoint(endpoint)
248226

249227

250228
@endpoints.command()
@@ -362,10 +340,19 @@ def list(
362340
click.echo("No dedicated endpoints found", err=True)
363341
return
364342

365-
click.echo("Dedicated endpoints:", err=True)
366-
for endpoint in endpoints:
367-
print_endpoint(endpoint, json=json)
368-
click.echo()
343+
click.echo("Endpoints:", err=True)
344+
if json:
345+
import json as json_lib
346+
347+
click.echo(
348+
json_lib.dumps([endpoint.model_dump() for endpoint in endpoints], indent=2)
349+
)
350+
else:
351+
for endpoint in endpoints:
352+
print_endpoint(
353+
endpoint,
354+
)
355+
click.echo()
369356

370357

371358
@endpoints.command()

src/together/types/endpoints.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ class BaseEndpoint(TogetherJSONModel):
7979
"""Base class for endpoint models with common fields."""
8080

8181
object: Literal["endpoint"] = Field(description="The type of object")
82-
id: str = Field(description="Unique identifier for the endpoint")
82+
id: Optional[str] = Field(
83+
default=None, description="Unique identifier for the endpoint"
84+
)
8385
name: str = Field(description="System name for the endpoint")
8486
model: str = Field(description="The model deployed on this endpoint")
8587
type: str = Field(description="The type of endpoint")
@@ -99,6 +101,7 @@ class ListEndpoint(BaseEndpoint):
99101
class DedicatedEndpoint(BaseEndpoint):
100102
"""Details about a dedicated endpoint deployment."""
101103

104+
id: str = Field(description="Unique identifier for the endpoint")
102105
type: Literal["dedicated"] = Field(description="The type of endpoint")
103106
display_name: str = Field(description="Human-readable name for the endpoint")
104107
hardware: str = Field(

0 commit comments

Comments
 (0)