mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-07 02:07:52 +02:00
sdk: Add subgraphs method
This commit is contained in:
@@ -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],
|
||||
|
||||
@@ -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."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user