sdk: Add subgraphs method

This commit is contained in:
Nuno Campos
2024-09-24 11:02:50 -07:00
parent 247e2bae8d
commit dfa874aaf6
3 changed files with 54 additions and 0 deletions
@@ -34,6 +34,7 @@ from langgraph_sdk.schema import (
RunCreate,
StreamMode,
StreamPart,
Subgraphs,
Thread,
ThreadState,
ThreadStatus,
@@ -392,6 +393,29 @@ class AssistantsClient:
""" # noqa: E501
return await self.http.get(f"/assistants/{assistant_id}/schemas")
async def get_subgraphs(
self, assistant_id: str, namespace: Optional[str] = None, recurse: bool = False
) -> Subgraphs:
"""Get the schemas of an assistant by ID.
Args:
assistant_id: The ID of the assistant to get the schema of.
Returns:
Subgraphs: The graph schema for the assistant.
""" # noqa: E501
if namespace is not None:
return await self.http.get(
f"/assistants/{assistant_id}/subgraphs/{namespace}",
params={"recurse": recurse},
)
else:
return await self.http.get(
f"/assistants/{assistant_id}/subgraphs",
params={"recurse": recurse},
)
async def create(
self,
graph_id: Optional[str],
@@ -33,6 +33,7 @@ from langgraph_sdk.schema import (
RunCreate,
StreamMode,
StreamPart,
Subgraphs,
Thread,
ThreadState,
ThreadStatus,
@@ -377,6 +378,29 @@ class SyncAssistantsClient:
""" # noqa: E501
return self.http.get(f"/assistants/{assistant_id}/schemas")
async def get_subgraphs(
self, assistant_id: str, namespace: Optional[str] = None, recurse: bool = False
) -> Subgraphs:
"""Get the schemas of an assistant by ID.
Args:
assistant_id: The ID of the assistant to get the schema of.
Returns:
Subgraphs: The graph schema for the assistant.
""" # noqa: E501
if namespace is not None:
return await self.http.get(
f"/assistants/{assistant_id}/subgraphs/{namespace}",
params={"recurse": recurse},
)
else:
return await self.http.get(
f"/assistants/{assistant_id}/subgraphs",
params={"recurse": recurse},
)
def create(
self,
graph_id: Optional[str],
+6
View File
@@ -58,6 +58,9 @@ class GraphSchema(TypedDict):
input_schema: Optional[dict]
"""The schema for the graph state.
Missing if unable to generate JSON schema from graph."""
output_schema: Optional[dict]
"""The schema for the graph output.
Missing if unable to generate JSON schema from graph."""
state_schema: Optional[dict]
"""The schema for the graph state.
Missing if unable to generate JSON schema from graph."""
@@ -66,6 +69,9 @@ class GraphSchema(TypedDict):
Missing if unable to generate JSON schema from graph."""
Subgraphs = dict[str, GraphSchema]
class AssistantBase(TypedDict):
"""Assistant base model."""