mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-29 03:09:45 +02:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f4c5fefee | ||
|
|
7cf230defa | ||
|
|
5db65e0281 | ||
|
|
b08c2e092f | ||
|
|
120ae38c12 | ||
|
|
22942d4eec | ||
|
|
1756ce1dd2 |
@@ -29,6 +29,10 @@
|
||||
"name": "Store",
|
||||
"description": "Store is an API for managing persistent key-value store (long-term memory) that is available from any thread."
|
||||
},
|
||||
{
|
||||
"name": "A2A",
|
||||
"description": "Agent-to-Agent Protocol related endpoints for exposing assistants as A2A-compliant agents."
|
||||
},
|
||||
{
|
||||
"name": "MCP",
|
||||
"description": "Model Context Protocol related endpoints for exposing an agent as an MCP server."
|
||||
@@ -3182,6 +3186,195 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/a2a/{assistant_id}": {
|
||||
"post": {
|
||||
"operationId": "post_a2a",
|
||||
"summary": "A2A Post",
|
||||
"description": "Communicate with an assistant using the Agent-to-Agent Protocol.\nSends a JSON-RPC 2.0 message to the assistant.\n\n- **Request**: Provide an object with `jsonrpc`, `id`, `method`, and optional `params`.\n- **Response**: Returns a JSON-RPC response with task information or error.\n\n**Supported Methods:**\n- `message/send`: Send a message to the assistant\n- `tasks/get`: Get the status and result of a task\n\n**Notes:**\n- Supports threaded conversations via thread context\n- Messages can contain text and data parts\n- Tasks run asynchronously and return completion status\n",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "assistant_id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "uuid"
|
||||
},
|
||||
"description": "The ID of the assistant to communicate with"
|
||||
},
|
||||
{
|
||||
"name": "Accept",
|
||||
"in": "header",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": ["application/json"]
|
||||
},
|
||||
"description": "Must be application/json"
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"jsonrpc": {
|
||||
"type": "string",
|
||||
"enum": ["2.0"],
|
||||
"description": "JSON-RPC version"
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "Request identifier"
|
||||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"enum": ["message/send", "tasks/get"],
|
||||
"description": "The method to invoke"
|
||||
},
|
||||
"params": {
|
||||
"type": "object",
|
||||
"description": "Method parameters",
|
||||
"oneOf": [
|
||||
{
|
||||
"title": "Message Send Parameters",
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"role": {
|
||||
"type": "string",
|
||||
"enum": ["user", "assistant"],
|
||||
"description": "Message role"
|
||||
},
|
||||
"parts": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"title": "Text Part",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string",
|
||||
"enum": ["text"]
|
||||
},
|
||||
"text": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["kind", "text"]
|
||||
},
|
||||
{
|
||||
"title": "Data Part",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string",
|
||||
"enum": ["data"]
|
||||
},
|
||||
"data": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": ["kind", "data"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"description": "Message parts"
|
||||
},
|
||||
"messageId": {
|
||||
"type": "string",
|
||||
"description": "Unique message identifier"
|
||||
}
|
||||
},
|
||||
"required": ["role", "parts", "messageId"]
|
||||
},
|
||||
"thread": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"threadId": {
|
||||
"type": "string",
|
||||
"description": "Thread identifier for conversation context"
|
||||
}
|
||||
},
|
||||
"description": "Optional thread context"
|
||||
}
|
||||
},
|
||||
"required": ["message"]
|
||||
},
|
||||
{
|
||||
"title": "Task Get Parameters",
|
||||
"properties": {
|
||||
"taskId": {
|
||||
"type": "string",
|
||||
"description": "Task identifier to retrieve"
|
||||
}
|
||||
},
|
||||
"required": ["taskId"]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": ["jsonrpc", "id", "method"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "JSON-RPC response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"jsonrpc": {
|
||||
"type": "string",
|
||||
"enum": ["2.0"]
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"result": {
|
||||
"type": "object",
|
||||
"description": "Success result containing task information or task details"
|
||||
},
|
||||
"error": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"description": "Error information if request failed"
|
||||
}
|
||||
},
|
||||
"required": ["jsonrpc", "id"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request - invalid JSON-RPC or missing Accept header"
|
||||
},
|
||||
"404": {
|
||||
"description": "Assistant not found"
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal server error"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"A2A"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/mcp/": {
|
||||
"post": {
|
||||
"operationId": "post_mcp",
|
||||
@@ -4822,6 +5015,12 @@
|
||||
},
|
||||
"ThreadSearchRequest": {
|
||||
"properties": {
|
||||
"ids": {
|
||||
"type": "array",
|
||||
"items": {"type": "string", "format": "uuid"},
|
||||
"title": "Ids",
|
||||
"description": "List of thread IDs to include. Others are excluded."
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object",
|
||||
"title": "Metadata",
|
||||
|
||||
@@ -1040,7 +1040,7 @@ def node_a(state: State, runtime: Runtime[ContextSchema]):
|
||||
...
|
||||
```
|
||||
|
||||
See [this guide](../how-tos/graph-api.ipynb#add-runtime-configuration) for a full breakdown on configuration.
|
||||
See [this guide](../how-tos/graph-api.md#add-runtime-configuration) for a full breakdown on configuration.
|
||||
:::
|
||||
|
||||
:::js
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from langgraph_sdk.auth import Auth
|
||||
from langgraph_sdk.client import get_client, get_sync_client
|
||||
|
||||
__version__ = "0.2.3"
|
||||
__version__ = "0.2.5"
|
||||
|
||||
__all__ = ["Auth", "get_client", "get_sync_client"]
|
||||
|
||||
@@ -489,6 +489,9 @@ class ThreadsSearch(typing.TypedDict, total=False):
|
||||
offset: int
|
||||
"""Offset for pagination."""
|
||||
|
||||
ids: Sequence[UUID] | None
|
||||
"""typing.Optional list of thread IDs to filter by."""
|
||||
|
||||
thread_id: UUID | None
|
||||
"""typing.Optional thread ID to filter by."""
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ from langgraph_sdk.schema import (
|
||||
ThreadSortBy,
|
||||
ThreadState,
|
||||
ThreadStatus,
|
||||
ThreadStreamMode,
|
||||
ThreadUpdateStateResponse,
|
||||
)
|
||||
from langgraph_sdk.sse import SSEDecoder, aiter_lines_raw, iter_lines_raw
|
||||
@@ -1308,6 +1309,7 @@ class ThreadsClient:
|
||||
*,
|
||||
metadata: Json = None,
|
||||
values: Json = None,
|
||||
ids: Sequence[str] | None = None,
|
||||
status: ThreadStatus | None = None,
|
||||
limit: int = 10,
|
||||
offset: int = 0,
|
||||
@@ -1322,6 +1324,7 @@ class ThreadsClient:
|
||||
Args:
|
||||
metadata: Thread metadata to filter on.
|
||||
values: State values to filter on.
|
||||
ids: List of thread IDs to filter by.
|
||||
status: Thread status to filter on.
|
||||
Must be one of 'idle', 'busy', 'interrupted' or 'error'.
|
||||
limit: Limit on number of threads to return.
|
||||
@@ -1355,6 +1358,8 @@ class ThreadsClient:
|
||||
payload["metadata"] = metadata
|
||||
if values:
|
||||
payload["values"] = values
|
||||
if ids:
|
||||
payload["ids"] = ids
|
||||
if status:
|
||||
payload["status"] = status
|
||||
if sort_by:
|
||||
@@ -1684,6 +1689,53 @@ class ThreadsClient:
|
||||
params=params,
|
||||
)
|
||||
|
||||
async def join_stream(
|
||||
self,
|
||||
thread_id: str,
|
||||
*,
|
||||
last_event_id: str | None = None,
|
||||
stream_mode: ThreadStreamMode | Sequence[ThreadStreamMode] = "run_modes",
|
||||
headers: Mapping[str, str] | None = None,
|
||||
params: QueryParamTypes | None = None,
|
||||
) -> AsyncIterator[StreamPart]:
|
||||
"""Get a stream of events for a thread.
|
||||
|
||||
Args:
|
||||
thread_id: The ID of the thread to get the stream for.
|
||||
last_event_id: The ID of the last event to get.
|
||||
headers: Optional custom headers to include with the request.
|
||||
params: Optional query parameters to include with the request.
|
||||
|
||||
Returns:
|
||||
Iterator[StreamPart]: An iterator of stream parts.
|
||||
|
||||
???+ example "Example Usage"
|
||||
|
||||
```python
|
||||
|
||||
for chunk in client.threads.join_stream(
|
||||
thread_id="my_thread_id",
|
||||
last_event_id="my_event_id",
|
||||
):
|
||||
print(chunk)
|
||||
```
|
||||
|
||||
""" # noqa: E501
|
||||
query_params = {
|
||||
"stream_mode": stream_mode,
|
||||
}
|
||||
if params:
|
||||
query_params.update(params)
|
||||
return self.http.stream(
|
||||
f"/threads/{thread_id}/stream",
|
||||
"GET",
|
||||
headers={
|
||||
**({"Last-Event-ID": last_event_id} if last_event_id else {}),
|
||||
**(headers or {}),
|
||||
},
|
||||
params=query_params,
|
||||
)
|
||||
|
||||
|
||||
class RunsClient:
|
||||
"""Client for managing runs in LangGraph.
|
||||
@@ -4406,6 +4458,7 @@ class SyncThreadsClient:
|
||||
*,
|
||||
metadata: Json = None,
|
||||
values: Json = None,
|
||||
ids: Sequence[str] | None = None,
|
||||
status: ThreadStatus | None = None,
|
||||
limit: int = 10,
|
||||
offset: int = 0,
|
||||
@@ -4420,6 +4473,7 @@ class SyncThreadsClient:
|
||||
Args:
|
||||
metadata: Thread metadata to filter on.
|
||||
values: State values to filter on.
|
||||
ids: List of thread IDs to filter by.
|
||||
status: Thread status to filter on.
|
||||
Must be one of 'idle', 'busy', 'interrupted' or 'error'.
|
||||
limit: Limit on number of threads to return.
|
||||
@@ -4449,6 +4503,8 @@ class SyncThreadsClient:
|
||||
payload["metadata"] = metadata
|
||||
if values:
|
||||
payload["values"] = values
|
||||
if ids:
|
||||
payload["ids"] = ids
|
||||
if status:
|
||||
payload["status"] = status
|
||||
if sort_by:
|
||||
@@ -4772,6 +4828,54 @@ class SyncThreadsClient:
|
||||
params=params,
|
||||
)
|
||||
|
||||
def join_stream(
|
||||
self,
|
||||
thread_id: str,
|
||||
*,
|
||||
stream_mode: ThreadStreamMode | Sequence[ThreadStreamMode] = "run_modes",
|
||||
last_event_id: str | None = None,
|
||||
headers: Mapping[str, str] | None = None,
|
||||
params: QueryParamTypes | None = None,
|
||||
) -> Iterator[StreamPart]:
|
||||
"""Get a stream of events for a thread.
|
||||
|
||||
Args:
|
||||
thread_id: The ID of the thread to get the stream for.
|
||||
last_event_id: The ID of the last event to get.
|
||||
headers: Optional custom headers to include with the request.
|
||||
params: Optional query parameters to include with the request.
|
||||
|
||||
Returns:
|
||||
Iterator[StreamPart]: An iterator of stream parts.
|
||||
|
||||
???+ example "Example Usage"
|
||||
|
||||
```python
|
||||
|
||||
for chunk in client.threads.join_stream(
|
||||
thread_id="my_thread_id",
|
||||
last_event_id="my_event_id",
|
||||
stream_mode="run_modes",
|
||||
):
|
||||
print(chunk)
|
||||
```
|
||||
|
||||
""" # noqa: E501
|
||||
query_params = {
|
||||
"stream_mode": stream_mode,
|
||||
}
|
||||
if params:
|
||||
query_params.update(params)
|
||||
return self.http.stream(
|
||||
f"/threads/{thread_id}/stream",
|
||||
"GET",
|
||||
headers={
|
||||
**({"Last-Event-ID": last_event_id} if last_event_id else {}),
|
||||
**(headers or {}),
|
||||
},
|
||||
params=query_params,
|
||||
)
|
||||
|
||||
|
||||
class SyncRunsClient:
|
||||
"""Synchronous client for managing runs in LangGraph.
|
||||
|
||||
@@ -38,6 +38,14 @@ Represents the status of a thread:
|
||||
- "error": An exception occurred during task processing.
|
||||
"""
|
||||
|
||||
ThreadStreamMode = Literal["run_modes", "lifecycle", "state_update"]
|
||||
"""
|
||||
Defines the mode of streaming:
|
||||
- "run_modes": Stream the same events as the runs on thread, as well as run_done events.
|
||||
- "lifecycle": Stream only run start/end events.
|
||||
- "state_update": Stream state updates on the thread.
|
||||
"""
|
||||
|
||||
StreamMode = Literal[
|
||||
"values",
|
||||
"messages",
|
||||
|
||||
Reference in New Issue
Block a user