feat(sdk-py): sdk support for context API (#5566)

Adding support for the `context` arg to `invoke/stream` to the sdk. This
is paired with an update to the API as well that adds `context` support
to the `assistants` and `runs` endpoints.

Bumping version to v0.2.0 on the `v1` branch given this and the
interrupt schema changes.
This commit is contained in:
Sydney Runkle
2025-07-22 10:48:12 -04:00
committed by GitHub
parent 508e333220
commit 9e3cb1f034
8 changed files with 141 additions and 30 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ license-files = ['LICENSE']
dependencies = [
"langchain-core>=0.1",
"langgraph-checkpoint>=2.1.0,<3.0.0",
"langgraph-sdk>=0.1.42,<0.2.0",
"langgraph-sdk>=0.2.0,<0.3.0",
"langgraph-prebuilt>=0.5.0,<0.6.0",
"xxhash>=3.5.0",
"pydantic>=2.7.4",
+1 -1
View File
@@ -1481,7 +1481,7 @@ wheels = [
[[package]]
name = "langgraph-sdk"
version = "0.1.74"
version = "0.2.0"
source = { editable = "../sdk-py" }
dependencies = [
{ name = "httpx" },
+1 -1
View File
@@ -507,7 +507,7 @@ dev = [
[[package]]
name = "langgraph-sdk"
version = "0.1.74"
version = "0.2.0"
source = { editable = "../sdk-py" }
dependencies = [
{ name = "httpx" },
+11 -4
View File
@@ -556,7 +556,8 @@ class AssistantsCreate(typing.TypedDict, total=False):
create_params = {
"assistant_id": UUID("123e4567-e89b-12d3-a456-426614174000"),
"graph_id": "graph123",
"config": {"key": "value"},
"config": {"tags": ["tag1", "tag2"]},
"context": {"key": "value"},
"metadata": {"owner": "user123"},
"if_exists": "do_nothing",
"name": "Assistant 1"
@@ -570,9 +571,11 @@ class AssistantsCreate(typing.TypedDict, total=False):
graph_id: str
"""Graph ID to use for this assistant."""
config: dict[str, typing.Any] | typing.Any | None
config: dict[str, typing.Any]
"""typing.Optional configuration for the assistant."""
context: dict[str, typing.Any]
metadata: MetadataInput
"""typing.Optional metadata to attach to the assistant."""
@@ -610,7 +613,8 @@ class AssistantsUpdate(typing.TypedDict, total=False):
update_params = {
"assistant_id": UUID("123e4567-e89b-12d3-a456-426614174000"),
"graph_id": "graph123",
"config": {"key": "value"},
"config": {"tags": ["tag1", "tag2"]},
"context": {"key": "value"},
"metadata": {"owner": "user123"},
"name": "Assistant 1",
"version": 1
@@ -624,9 +628,12 @@ class AssistantsUpdate(typing.TypedDict, total=False):
graph_id: str | None
"""typing.Optional graph ID to update."""
config: dict[str, typing.Any] | typing.Any | None
config: dict[str, typing.Any]
"""typing.Optional configuration to update."""
context: dict[str, typing.Any]
"""The static context of the assistant."""
metadata: MetadataInput
"""typing.Optional metadata to update."""
+114 -21
View File
@@ -39,6 +39,7 @@ from langgraph_sdk.schema import (
Checkpoint,
Command,
Config,
Context,
Cron,
CronSortBy,
DisconnectMode,
@@ -646,9 +647,9 @@ class AssistantsClient:
}
}
},
'config_schema':
'context_schema':
{
'title': 'Configurable',
'title': 'Context',
'type': 'object',
'properties':
{
@@ -706,6 +707,7 @@ class AssistantsClient:
graph_id: str | None,
config: Config | None = None,
*,
context: Context | None = None,
metadata: Json = None,
assistant_id: str | None = None,
if_exists: OnConflictBehavior | None = None,
@@ -721,6 +723,8 @@ class AssistantsClient:
graph_id: The ID of the graph the assistant should use. The graph ID is normally set in your langgraph.json configuration.
config: Configuration to use for the graph.
metadata: Metadata to add to assistant.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
assistant_id: Assistant ID to use, will default to a random UUID if not provided.
if_exists: How to handle duplicate creation. Defaults to 'raise' under the hood.
Must be either 'raise' (raise error if duplicate), or 'do_nothing' (return existing assistant).
@@ -738,7 +742,7 @@ class AssistantsClient:
client = get_client(url="http://localhost:2024")
assistant = await client.assistants.create(
graph_id="agent",
config={"configurable": {"model_name": "openai"}},
context={"model_name": "openai"},
metadata={"number":1},
assistant_id="my-assistant-id",
if_exists="do_nothing",
@@ -751,6 +755,8 @@ class AssistantsClient:
}
if config:
payload["config"] = config
if context:
payload["context"] = context
if metadata:
payload["metadata"] = metadata
if assistant_id:
@@ -769,6 +775,7 @@ class AssistantsClient:
*,
graph_id: str | None = None,
config: Config | None = None,
context: Context | None = None,
metadata: Json = None,
name: str | None = None,
headers: dict[str, str] | None = None,
@@ -783,6 +790,8 @@ class AssistantsClient:
graph_id: The ID of the graph the assistant should use.
The graph ID is normally set in your langgraph.json configuration. If None, assistant will keep pointing to same graph.
config: Configuration to use for the graph.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
metadata: Metadata to merge with existing assistant metadata.
name: The new name for the assistant.
headers: Optional custom headers to include with the request.
@@ -799,7 +808,7 @@ class AssistantsClient:
assistant = await client.assistants.update(
assistant_id='e280dad7-8618-443f-87f1-8e41841c180f',
graph_id="other-graph",
config={"configurable": {"model_name": "anthropic"}},
context={"model_name": "anthropic"},
metadata={"number":2}
)
```
@@ -810,6 +819,8 @@ class AssistantsClient:
payload["graph_id"] = graph_id
if config:
payload["config"] = config
if context:
payload["context"] = context
if metadata:
payload["metadata"] = metadata
if name:
@@ -1482,7 +1493,7 @@ class ThreadsClient:
class RunsClient:
"""Client for managing runs in LangGraph.
A run is a single assistant invocation with optional input, config, and metadata.
A run is a single assistant invocation with optional input, config, context, and metadata.
This client manages runs, which can be stateful (on threads) or stateless.
???+ example "Example"
@@ -1509,6 +1520,7 @@ class RunsClient:
stream_resumable: bool = False,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
checkpoint_during: bool | None = None,
@@ -1562,6 +1574,7 @@ class RunsClient:
stream_resumable: bool = False,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
checkpoint_during: bool | None = None,
@@ -1592,6 +1605,8 @@ class RunsClient:
If true, the stream can be resumed and replayed in its entirety even after disconnection.
metadata: Metadata to assign to the run.
config: The configuration for the assistant.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
checkpoint: The checkpoint to resume from.
checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
interrupt_before: Nodes to interrupt immediately before they get executed.
@@ -1623,7 +1638,7 @@ class RunsClient:
input={"messages": [{"role": "user", "content": "how are you?"}]},
stream_mode=["values","debug"],
metadata={"name":"my_run"},
config={"configurable": {"model_name": "anthropic"}},
context={"model_name": "anthropic"},
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
feedback_keys=["my_feedback_key_1","my_feedback_key_2"],
@@ -1650,6 +1665,7 @@ class RunsClient:
{k: v for k, v in command.items() if v is not None} if command else None
),
"config": config,
"context": context,
"metadata": metadata,
"stream_mode": stream_mode,
"stream_subgraphs": stream_subgraphs,
@@ -1701,6 +1717,7 @@ class RunsClient:
metadata: dict | None = None,
checkpoint_during: bool | None = None,
config: Config | None = None,
context: Context | None = None,
interrupt_before: All | Sequence[str] | None = None,
interrupt_after: All | Sequence[str] | None = None,
webhook: str | None = None,
@@ -1724,6 +1741,7 @@ class RunsClient:
stream_resumable: bool = False,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
checkpoint_during: bool | None = None,
@@ -1749,6 +1767,7 @@ class RunsClient:
stream_resumable: bool = False,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
checkpoint_during: bool | None = None,
@@ -1777,6 +1796,8 @@ class RunsClient:
If true, the stream can be resumed and replayed in its entirety even after disconnection.
metadata: Metadata to assign to the run.
config: The configuration for the assistant.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
checkpoint: The checkpoint to resume from.
checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
interrupt_before: Nodes to interrupt immediately before they get executed.
@@ -1805,7 +1826,7 @@ class RunsClient:
assistant_id="my_assistant_id",
input={"messages": [{"role": "user", "content": "hello!"}]},
metadata={"name":"my_run"},
config={"configurable": {"model_name": "openai"}},
context={"model_name": "openai"},
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
webhook="https://my.fake.webhook.com",
@@ -1849,10 +1870,13 @@ class RunsClient:
'graph_id': 'agent',
'thread_id': 'my_thread_id',
'checkpoint_id': None,
'model_name': "openai",
'assistant_id': 'my_assistant_id'
}
},
},
'context':
{
'model_name': 'openai'
}
'webhook': "https://my.fake.webhook.com",
'temporary': False,
'stream_mode': ['values'],
@@ -1873,6 +1897,7 @@ class RunsClient:
"stream_subgraphs": stream_subgraphs,
"stream_resumable": stream_resumable,
"config": config,
"context": context,
"metadata": metadata,
"assistant_id": assistant_id,
"interrupt_before": interrupt_before,
@@ -1919,6 +1944,7 @@ class RunsClient:
command: Command | None = None,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
checkpoint_during: bool | None = None,
@@ -1944,6 +1970,7 @@ class RunsClient:
command: Command | None = None,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint_during: bool | None = None,
interrupt_before: All | Sequence[str] | None = None,
interrupt_after: All | Sequence[str] | None = None,
@@ -1966,6 +1993,7 @@ class RunsClient:
command: Command | None = None,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
checkpoint_during: bool | None = None,
@@ -1992,6 +2020,8 @@ class RunsClient:
command: A command to execute. Cannot be combined with input.
metadata: Metadata to assign to the run.
config: The configuration for the assistant.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
checkpoint: The checkpoint to resume from.
checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
interrupt_before: Nodes to interrupt immediately before they get executed.
@@ -2022,7 +2052,7 @@ class RunsClient:
assistant_id="agent",
input={"messages": [{"role": "user", "content": "how are you?"}]},
metadata={"name":"my_run"},
config={"configurable": {"model_name": "anthropic"}},
context={"model_name": "anthropic"},
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
webhook="https://my.fake.webhook.com",
@@ -2068,6 +2098,7 @@ class RunsClient:
{k: v for k, v in command.items() if v is not None} if command else None
),
"config": config,
"context": context,
"metadata": metadata,
"assistant_id": assistant_id,
"interrupt_before": interrupt_before,
@@ -2332,7 +2363,7 @@ class RunsClient:
class CronClient:
"""Client for managing recurrent runs (cron jobs) in LangGraph.
A run is a single invocation of an assistant with optional input and config.
A run is a single invocation of an assistant with optional input, config, and context.
This client allows scheduling recurring runs to occur automatically.
???+ example "Example Usage"
@@ -2365,6 +2396,7 @@ class CronClient:
input: dict | None = None,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint_during: bool | None = None,
interrupt_before: All | list[str] | None = None,
interrupt_after: All | list[str] | None = None,
@@ -2382,6 +2414,8 @@ class CronClient:
input: The input to the graph.
metadata: Metadata to assign to the cron job runs.
config: The configuration for the assistant.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
interrupt_before: Nodes to interrupt immediately before they get executed.
@@ -2405,7 +2439,7 @@ class CronClient:
schedule="27 15 * * *",
input={"messages": [{"role": "user", "content": "hello!"}]},
metadata={"name":"my_run"},
config={"configurable": {"model_name": "openai"}},
context={"model_name": "openai"},
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
webhook="https://my.fake.webhook.com",
@@ -2418,6 +2452,7 @@ class CronClient:
"input": input,
"config": config,
"metadata": metadata,
"context": context,
"assistant_id": assistant_id,
"checkpoint_during": checkpoint_during,
"interrupt_before": interrupt_before,
@@ -2439,6 +2474,7 @@ class CronClient:
input: dict | None = None,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint_during: bool | None = None,
interrupt_before: All | list[str] | None = None,
interrupt_after: All | list[str] | None = None,
@@ -2455,6 +2491,8 @@ class CronClient:
input: The input to the graph.
metadata: Metadata to assign to the cron job runs.
config: The configuration for the assistant.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
interrupt_before: Nodes to interrupt immediately before they get executed.
interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
@@ -2475,7 +2513,7 @@ class CronClient:
schedule="27 15 * * *",
input={"messages": [{"role": "user", "content": "hello!"}]},
metadata={"name":"my_run"},
config={"configurable": {"model_name": "openai"}},
context={"model_name": "openai"},
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
webhook="https://my.fake.webhook.com",
@@ -2489,6 +2527,7 @@ class CronClient:
"input": input,
"config": config,
"metadata": metadata,
"context": context,
"assistant_id": assistant_id,
"checkpoint_during": checkpoint_during,
"interrupt_before": interrupt_before,
@@ -3216,6 +3255,7 @@ class SyncAssistantsClient:
'created_at': '2024-06-25T17:10:33.109781+00:00',
'updated_at': '2024-06-25T17:10:33.109781+00:00',
'config': {},
'context': {},
'metadata': {'created_by': 'system'}
}
```
@@ -3379,6 +3419,20 @@ class SyncAssistantsClient:
'type': 'string'
}
}
},
'context_schema':
{
'title': 'Context',
'type': 'object',
'properties':
{
'model_name':
{
'title': 'Model Name',
'enum': ['anthropic', 'openai'],
'type': 'string'
}
}
}
}
```
@@ -3422,6 +3476,7 @@ class SyncAssistantsClient:
graph_id: str | None,
config: Config | None = None,
*,
context: Context | None = None,
metadata: Json = None,
assistant_id: str | None = None,
if_exists: OnConflictBehavior | None = None,
@@ -3436,6 +3491,8 @@ class SyncAssistantsClient:
Args:
graph_id: The ID of the graph the assistant should use. The graph ID is normally set in your langgraph.json configuration.
config: Configuration to use for the graph.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
metadata: Metadata to add to assistant.
assistant_id: Assistant ID to use, will default to a random UUID if not provided.
if_exists: How to handle duplicate creation. Defaults to 'raise' under the hood.
@@ -3454,7 +3511,7 @@ class SyncAssistantsClient:
client = get_sync_client(url="http://localhost:2024")
assistant = client.assistants.create(
graph_id="agent",
config={"configurable": {"model_name": "openai"}},
context={"model_name": "openai"},
metadata={"number":1},
assistant_id="my-assistant-id",
if_exists="do_nothing",
@@ -3467,6 +3524,8 @@ class SyncAssistantsClient:
}
if config:
payload["config"] = config
if context:
payload["context"] = context
if metadata:
payload["metadata"] = metadata
if assistant_id:
@@ -3485,6 +3544,7 @@ class SyncAssistantsClient:
*,
graph_id: str | None = None,
config: Config | None = None,
context: Context | None = None,
metadata: Json = None,
name: str | None = None,
headers: dict[str, str] | None = None,
@@ -3499,6 +3559,8 @@ class SyncAssistantsClient:
graph_id: The ID of the graph the assistant should use.
The graph ID is normally set in your langgraph.json configuration. If None, assistant will keep pointing to same graph.
config: Configuration to use for the graph.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
metadata: Metadata to merge with existing assistant metadata.
name: The new name for the assistant.
headers: Optional custom headers to include with the request.
@@ -3515,7 +3577,7 @@ class SyncAssistantsClient:
assistant = client.assistants.update(
assistant_id='e280dad7-8618-443f-87f1-8e41841c180f',
graph_id="other-graph",
config={"configurable": {"model_name": "anthropic"}},
context={"model_name": "anthropic"},
metadata={"number":2}
)
```
@@ -3525,6 +3587,8 @@ class SyncAssistantsClient:
payload["graph_id"] = graph_id
if config:
payload["config"] = config
if context:
payload["context"] = context
if metadata:
payload["metadata"] = metadata
if name:
@@ -4220,6 +4284,7 @@ class SyncRunsClient:
stream_subgraphs: bool = False,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
checkpoint_during: bool | None = None,
@@ -4248,6 +4313,7 @@ class SyncRunsClient:
stream_resumable: bool = False,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint_during: bool | None = None,
interrupt_before: All | Sequence[str] | None = None,
interrupt_after: All | Sequence[str] | None = None,
@@ -4273,6 +4339,7 @@ class SyncRunsClient:
stream_resumable: bool = False,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
checkpoint_during: bool | None = None,
@@ -4303,6 +4370,8 @@ class SyncRunsClient:
If true, the stream can be resumed and replayed in its entirety even after disconnection.
metadata: Metadata to assign to the run.
config: The configuration for the assistant.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
checkpoint: The checkpoint to resume from.
checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
interrupt_before: Nodes to interrupt immediately before they get executed.
@@ -4335,7 +4404,7 @@ class SyncRunsClient:
input={"messages": [{"role": "user", "content": "how are you?"}]},
stream_mode=["values","debug"],
metadata={"name":"my_run"},
config={"configurable": {"model_name": "anthropic"}},
context={"model_name": "anthropic"},
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
feedback_keys=["my_feedback_key_1","my_feedback_key_2"],
@@ -4359,6 +4428,7 @@ class SyncRunsClient:
{k: v for k, v in command.items() if v is not None} if command else None
),
"config": config,
"context": context,
"metadata": metadata,
"stream_mode": stream_mode,
"stream_subgraphs": stream_subgraphs,
@@ -4409,6 +4479,7 @@ class SyncRunsClient:
stream_resumable: bool = False,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint_during: bool | None = None,
interrupt_before: All | Sequence[str] | None = None,
interrupt_after: All | Sequence[str] | None = None,
@@ -4433,6 +4504,7 @@ class SyncRunsClient:
stream_resumable: bool = False,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
checkpoint_during: bool | None = None,
@@ -4458,6 +4530,7 @@ class SyncRunsClient:
stream_resumable: bool = False,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
checkpoint_during: bool | None = None,
@@ -4486,6 +4559,8 @@ class SyncRunsClient:
If true, the stream can be resumed and replayed in its entirety even after disconnection.
metadata: Metadata to assign to the run.
config: The configuration for the assistant.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
checkpoint: The checkpoint to resume from.
checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
interrupt_before: Nodes to interrupt immediately before they get executed.
@@ -4514,7 +4589,7 @@ class SyncRunsClient:
assistant_id="my_assistant_id",
input={"messages": [{"role": "user", "content": "hello!"}]},
metadata={"name":"my_run"},
config={"configurable": {"model_name": "openai"}},
context={"model_name": "openai"},
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
webhook="https://my.fake.webhook.com",
@@ -4558,10 +4633,13 @@ class SyncRunsClient:
'graph_id': 'agent',
'thread_id': 'my_thread_id',
'checkpoint_id': None,
'model_name': "openai",
'assistant_id': 'my_assistant_id'
}
},
'context':
{
'model_name': 'openai'
},
'webhook': "https://my.fake.webhook.com",
'temporary': False,
'stream_mode': ['values'],
@@ -4582,6 +4660,7 @@ class SyncRunsClient:
"stream_subgraphs": stream_subgraphs,
"stream_resumable": stream_resumable,
"config": config,
"context": context,
"metadata": metadata,
"assistant_id": assistant_id,
"interrupt_before": interrupt_before,
@@ -4630,6 +4709,7 @@ class SyncRunsClient:
command: Command | None = None,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
checkpoint_during: bool | None = None,
@@ -4654,6 +4734,7 @@ class SyncRunsClient:
command: Command | None = None,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint_during: bool | None = None,
interrupt_before: All | Sequence[str] | None = None,
interrupt_after: All | Sequence[str] | None = None,
@@ -4675,6 +4756,7 @@ class SyncRunsClient:
command: Command | None = None,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint_during: bool | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
@@ -4700,6 +4782,8 @@ class SyncRunsClient:
command: The command to execute.
metadata: Metadata to assign to the run.
config: The configuration for the assistant.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
checkpoint: The checkpoint to resume from.
checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
interrupt_before: Nodes to interrupt immediately before they get executed.
@@ -4730,7 +4814,7 @@ class SyncRunsClient:
assistant_id="agent",
input={"messages": [{"role": "user", "content": "how are you?"}]},
metadata={"name":"my_run"},
config={"configurable": {"model_name": "anthropic"}},
context={"model_name": "anthropic"},
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
webhook="https://my.fake.webhook.com",
@@ -4777,6 +4861,7 @@ class SyncRunsClient:
{k: v for k, v in command.items() if v is not None} if command else None
),
"config": config,
"context": context,
"metadata": metadata,
"assistant_id": assistant_id,
"interrupt_before": interrupt_before,
@@ -5059,6 +5144,7 @@ class SyncCronClient:
metadata: dict | None = None,
checkpoint_during: bool | None = None,
config: Config | None = None,
context: Context | None = None,
interrupt_before: All | list[str] | None = None,
interrupt_after: All | list[str] | None = None,
webhook: str | None = None,
@@ -5075,6 +5161,8 @@ class SyncCronClient:
input: The input to the graph.
metadata: Metadata to assign to the cron job runs.
config: The configuration for the assistant.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
interrupt_before: Nodes to interrupt immediately before they get executed.
interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
@@ -5096,7 +5184,7 @@ class SyncCronClient:
schedule="27 15 * * *",
input={"messages": [{"role": "user", "content": "hello!"}]},
metadata={"name":"my_run"},
config={"configurable": {"model_name": "openai"}},
context={"model_name": "openai"},
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
webhook="https://my.fake.webhook.com",
@@ -5109,6 +5197,7 @@ class SyncCronClient:
"input": input,
"config": config,
"metadata": metadata,
"context": context,
"assistant_id": assistant_id,
"interrupt_before": interrupt_before,
"interrupt_after": interrupt_after,
@@ -5129,6 +5218,7 @@ class SyncCronClient:
input: dict | None = None,
metadata: dict | None = None,
config: Config | None = None,
context: Context | None = None,
checkpoint_during: bool | None = None,
interrupt_before: All | list[str] | None = None,
interrupt_after: All | list[str] | None = None,
@@ -5145,6 +5235,8 @@ class SyncCronClient:
input: The input to the graph.
metadata: Metadata to assign to the cron job runs.
config: The configuration for the assistant.
context: Static context to add to the assistant.
!!! version-added "Supported with langgraph>=0.6.0"
checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
interrupt_before: Nodes to interrupt immediately before they get executed.
interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
@@ -5165,7 +5257,7 @@ class SyncCronClient:
schedule="27 15 * * *",
input={"messages": [{"role": "user", "content": "hello!"}]},
metadata={"name":"my_run"},
config={"configurable": {"model_name": "openai"}},
context={"model_name": "openai"},
checkpoint_during=True,
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
@@ -5180,6 +5272,7 @@ class SyncCronClient:
"input": input,
"config": config,
"metadata": metadata,
"context": context,
"assistant_id": assistant_id,
"interrupt_before": interrupt_before,
"interrupt_after": interrupt_after,
+11
View File
@@ -12,6 +12,8 @@ from typing import (
TypedDict,
)
from typing_extensions import TypeAlias
Json = Optional[dict[str, Any]]
"""Represents a JSON-like structure, which can be None or a dictionary with string keys and any values."""
@@ -129,6 +131,8 @@ SortOrder = Literal["asc", "desc"]
The order to sort by.
"""
Context: TypeAlias = dict[str, Any]
class Config(TypedDict, total=False):
"""Configuration options for a call."""
@@ -183,6 +187,9 @@ class GraphSchema(TypedDict):
config_schema: dict | None
"""The schema for the graph config.
Missing if unable to generate JSON schema from graph."""
context_schema: dict | None
"""The schema for the graph context.
Missing if unable to generate JSON schema from graph."""
Subgraphs = dict[str, GraphSchema]
@@ -197,6 +204,8 @@ class AssistantBase(TypedDict):
"""The ID of the graph."""
config: Config
"""The assistant config."""
context: Context
"""The static context of the assistant."""
created_at: datetime
"""The time the assistant was created."""
metadata: Json
@@ -352,6 +361,8 @@ class RunCreate(TypedDict):
"""Additional metadata to associate with the run."""
config: Config | None
"""Configuration options for the run."""
context: Context | None
"""The static context of the run."""
checkpoint_id: str | None
"""The identifier of a checkpoint to resume from."""
interrupt_before: list[str] | None
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "langgraph-sdk"
version = "0.1.74"
version = "0.2.0"
description = "SDK for interacting with LangGraph API"
authors = []
requires-python = ">=3.9"
+1 -1
View File
@@ -119,7 +119,7 @@ wheels = [
[[package]]
name = "langgraph-sdk"
version = "0.1.74"
version = "0.2.0"
source = { editable = "." }
dependencies = [
{ name = "httpx" },