diff --git a/libs/sdk-py/langgraph_sdk/client/async_client.py b/libs/sdk-py/langgraph_sdk/client/async_client.py index 2c4083b37..7e55df32a 100644 --- a/libs/sdk-py/langgraph_sdk/client/async_client.py +++ b/libs/sdk-py/langgraph_sdk/client/async_client.py @@ -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], diff --git a/libs/sdk-py/langgraph_sdk/client/sync_client.py b/libs/sdk-py/langgraph_sdk/client/sync_client.py index f41a04c2e..1c99625f8 100644 --- a/libs/sdk-py/langgraph_sdk/client/sync_client.py +++ b/libs/sdk-py/langgraph_sdk/client/sync_client.py @@ -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], diff --git a/libs/sdk-py/langgraph_sdk/schema.py b/libs/sdk-py/langgraph_sdk/schema.py index aff52cdf0..da1db204c 100644 --- a/libs/sdk-py/langgraph_sdk/schema.py +++ b/libs/sdk-py/langgraph_sdk/schema.py @@ -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."""