|
|
|
@@ -15,6 +15,7 @@ import logging
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
import sys
|
|
|
|
|
import warnings
|
|
|
|
|
from collections.abc import AsyncIterator, Iterator, Mapping, Sequence
|
|
|
|
|
from types import TracebackType
|
|
|
|
|
from typing import (
|
|
|
|
@@ -45,6 +46,7 @@ from langgraph_sdk.schema import (
|
|
|
|
|
CronSelectField,
|
|
|
|
|
CronSortBy,
|
|
|
|
|
DisconnectMode,
|
|
|
|
|
Durability,
|
|
|
|
|
GraphSchema,
|
|
|
|
|
IfNotExists,
|
|
|
|
|
Item,
|
|
|
|
@@ -69,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
|
|
|
|
@@ -1682,6 +1685,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.
|
|
|
|
@@ -1772,7 +1822,7 @@ class RunsClient:
|
|
|
|
|
context: Context | None = None,
|
|
|
|
|
checkpoint: Checkpoint | None = None,
|
|
|
|
|
checkpoint_id: str | None = None,
|
|
|
|
|
checkpoint_during: bool | None = None,
|
|
|
|
|
checkpoint_during: bool | None = None, # deprecated
|
|
|
|
|
interrupt_before: All | Sequence[str] | None = None,
|
|
|
|
|
interrupt_after: All | Sequence[str] | None = None,
|
|
|
|
|
feedback_keys: Sequence[str] | None = None,
|
|
|
|
@@ -1785,6 +1835,7 @@ class RunsClient:
|
|
|
|
|
headers: Mapping[str, str] | None = None,
|
|
|
|
|
params: QueryParamTypes | None = None,
|
|
|
|
|
on_run_created: Callable[[RunCreateMetadata], None] | None = None,
|
|
|
|
|
durability: Durability | None = None,
|
|
|
|
|
) -> AsyncIterator[StreamPart]:
|
|
|
|
|
"""Create a run and stream the results.
|
|
|
|
|
|
|
|
|
@@ -1804,7 +1855,7 @@ class RunsClient:
|
|
|
|
|
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).
|
|
|
|
|
checkpoint_during: (deprecated) 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.
|
|
|
|
|
feedback_keys: Feedback keys to assign to run.
|
|
|
|
@@ -1822,6 +1873,10 @@ class RunsClient:
|
|
|
|
|
headers: Optional custom headers to include with the request.
|
|
|
|
|
params: Optional query parameters to include with the request.
|
|
|
|
|
on_run_created: Callback when a run is created.
|
|
|
|
|
durability: The durability to use for the run. Values are "sync", "async", or "exit".
|
|
|
|
|
"async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
|
|
|
|
|
"sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
|
|
|
|
|
"exit" means checkpoints are only persisted when the run exits, does not save intermediate steps
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
AsyncIterator[StreamPart]: Asynchronous iterator of stream results.
|
|
|
|
@@ -1857,6 +1912,13 @@ class RunsClient:
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
""" # noqa: E501
|
|
|
|
|
if checkpoint_during is not None:
|
|
|
|
|
warnings.warn(
|
|
|
|
|
"`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.",
|
|
|
|
|
DeprecationWarning,
|
|
|
|
|
stacklevel=2,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
payload = {
|
|
|
|
|
"input": input,
|
|
|
|
|
"command": (
|
|
|
|
@@ -1881,6 +1943,7 @@ class RunsClient:
|
|
|
|
|
"on_disconnect": on_disconnect,
|
|
|
|
|
"on_completion": on_completion,
|
|
|
|
|
"after_seconds": after_seconds,
|
|
|
|
|
"durability": durability,
|
|
|
|
|
}
|
|
|
|
|
endpoint = (
|
|
|
|
|
f"/threads/{thread_id}/runs/stream"
|
|
|
|
@@ -1971,7 +2034,7 @@ class RunsClient:
|
|
|
|
|
context: Context | None = None,
|
|
|
|
|
checkpoint: Checkpoint | None = None,
|
|
|
|
|
checkpoint_id: str | None = None,
|
|
|
|
|
checkpoint_during: bool | None = None,
|
|
|
|
|
checkpoint_during: bool | None = None, # deprecated
|
|
|
|
|
interrupt_before: All | Sequence[str] | None = None,
|
|
|
|
|
interrupt_after: All | Sequence[str] | None = None,
|
|
|
|
|
webhook: str | None = None,
|
|
|
|
@@ -1982,6 +2045,7 @@ class RunsClient:
|
|
|
|
|
headers: Mapping[str, str] | None = None,
|
|
|
|
|
params: QueryParamTypes | None = None,
|
|
|
|
|
on_run_created: Callable[[RunCreateMetadata], None] | None = None,
|
|
|
|
|
durability: Durability | None = None,
|
|
|
|
|
) -> Run:
|
|
|
|
|
"""Create a background run.
|
|
|
|
|
|
|
|
|
@@ -2001,7 +2065,7 @@ class RunsClient:
|
|
|
|
|
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).
|
|
|
|
|
checkpoint_during: (deprecated) 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.
|
|
|
|
|
webhook: Webhook to call after LangGraph API call is done.
|
|
|
|
@@ -2015,6 +2079,10 @@ class RunsClient:
|
|
|
|
|
Use to schedule future runs.
|
|
|
|
|
headers: Optional custom headers to include with the request.
|
|
|
|
|
on_run_created: Optional callback to call when a run is created.
|
|
|
|
|
durability: The durability to use for the run. Values are "sync", "async", or "exit".
|
|
|
|
|
"async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
|
|
|
|
|
"sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
|
|
|
|
|
"exit" means checkpoints are only persisted when the run exits, does not save intermediate steps
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
Run: The created background run.
|
|
|
|
@@ -2090,6 +2158,12 @@ class RunsClient:
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
""" # noqa: E501
|
|
|
|
|
if checkpoint_during is not None:
|
|
|
|
|
warnings.warn(
|
|
|
|
|
"`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.",
|
|
|
|
|
DeprecationWarning,
|
|
|
|
|
stacklevel=2,
|
|
|
|
|
)
|
|
|
|
|
payload = {
|
|
|
|
|
"input": input,
|
|
|
|
|
"command": (
|
|
|
|
@@ -2112,6 +2186,7 @@ class RunsClient:
|
|
|
|
|
"if_not_exists": if_not_exists,
|
|
|
|
|
"on_completion": on_completion,
|
|
|
|
|
"after_seconds": after_seconds,
|
|
|
|
|
"durability": durability,
|
|
|
|
|
}
|
|
|
|
|
payload = {k: v for k, v in payload.items() if v is not None}
|
|
|
|
|
|
|
|
|
@@ -2209,7 +2284,7 @@ class RunsClient:
|
|
|
|
|
context: Context | None = None,
|
|
|
|
|
checkpoint: Checkpoint | None = None,
|
|
|
|
|
checkpoint_id: str | None = None,
|
|
|
|
|
checkpoint_during: bool | None = None,
|
|
|
|
|
checkpoint_during: bool | None = None, # deprecated
|
|
|
|
|
interrupt_before: All | Sequence[str] | None = None,
|
|
|
|
|
interrupt_after: All | Sequence[str] | None = None,
|
|
|
|
|
webhook: str | None = None,
|
|
|
|
@@ -2222,6 +2297,7 @@ class RunsClient:
|
|
|
|
|
headers: Mapping[str, str] | None = None,
|
|
|
|
|
params: QueryParamTypes | None = None,
|
|
|
|
|
on_run_created: Callable[[RunCreateMetadata], None] | None = None,
|
|
|
|
|
durability: Durability | None = None,
|
|
|
|
|
) -> list[dict] | dict[str, Any]:
|
|
|
|
|
"""Create a run, wait until it finishes and return the final state.
|
|
|
|
|
|
|
|
|
@@ -2237,7 +2313,7 @@ class RunsClient:
|
|
|
|
|
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).
|
|
|
|
|
checkpoint_during: (deprecated) 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.
|
|
|
|
|
webhook: Webhook to call after LangGraph API call is done.
|
|
|
|
@@ -2253,6 +2329,10 @@ class RunsClient:
|
|
|
|
|
Use to schedule future runs.
|
|
|
|
|
headers: Optional custom headers to include with the request.
|
|
|
|
|
on_run_created: Optional callback to call when a run is created.
|
|
|
|
|
durability: The durability to use for the run. Values are "sync", "async", or "exit".
|
|
|
|
|
"async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
|
|
|
|
|
"sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
|
|
|
|
|
"exit" means checkpoints are only persisted when the run exits, does not save intermediate steps
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
Union[list[dict], dict[str, Any]]: The output of the run.
|
|
|
|
@@ -2306,6 +2386,12 @@ class RunsClient:
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
""" # noqa: E501
|
|
|
|
|
if checkpoint_during is not None:
|
|
|
|
|
warnings.warn(
|
|
|
|
|
"`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.",
|
|
|
|
|
DeprecationWarning,
|
|
|
|
|
stacklevel=2,
|
|
|
|
|
)
|
|
|
|
|
payload = {
|
|
|
|
|
"input": input,
|
|
|
|
|
"command": (
|
|
|
|
@@ -2326,6 +2412,7 @@ class RunsClient:
|
|
|
|
|
"on_disconnect": on_disconnect,
|
|
|
|
|
"on_completion": on_completion,
|
|
|
|
|
"after_seconds": after_seconds,
|
|
|
|
|
"durability": durability,
|
|
|
|
|
}
|
|
|
|
|
endpoint = (
|
|
|
|
|
f"/threads/{thread_id}/runs/wait" if thread_id is not None else "/runs/wait"
|
|
|
|
@@ -4733,6 +4820,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.
|
|
|
|
@@ -4823,7 +4958,7 @@ class SyncRunsClient:
|
|
|
|
|
context: Context | None = None,
|
|
|
|
|
checkpoint: Checkpoint | None = None,
|
|
|
|
|
checkpoint_id: str | None = None,
|
|
|
|
|
checkpoint_during: bool | None = None,
|
|
|
|
|
checkpoint_during: bool | None = None, # deprecated
|
|
|
|
|
interrupt_before: All | Sequence[str] | None = None,
|
|
|
|
|
interrupt_after: All | Sequence[str] | None = None,
|
|
|
|
|
feedback_keys: Sequence[str] | None = None,
|
|
|
|
@@ -4836,6 +4971,7 @@ class SyncRunsClient:
|
|
|
|
|
headers: Mapping[str, str] | None = None,
|
|
|
|
|
params: QueryParamTypes | None = None,
|
|
|
|
|
on_run_created: Callable[[RunCreateMetadata], None] | None = None,
|
|
|
|
|
durability: Durability | None = None,
|
|
|
|
|
) -> Iterator[StreamPart]:
|
|
|
|
|
"""Create a run and stream the results.
|
|
|
|
|
|
|
|
|
@@ -4855,7 +4991,7 @@ class SyncRunsClient:
|
|
|
|
|
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).
|
|
|
|
|
checkpoint_during: (deprecated) 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.
|
|
|
|
|
feedback_keys: Feedback keys to assign to run.
|
|
|
|
@@ -4872,6 +5008,11 @@ class SyncRunsClient:
|
|
|
|
|
Use to schedule future runs.
|
|
|
|
|
headers: Optional custom headers to include with the request.
|
|
|
|
|
on_run_created: Optional callback to call when a run is created.
|
|
|
|
|
durability: The durability to use for the run. Values are "sync", "async", or "exit".
|
|
|
|
|
"async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
|
|
|
|
|
"sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
|
|
|
|
|
"exit" means checkpoints are only persisted when the run exits, does not save intermediate steps
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
Iterator[StreamPart]: Iterator of stream results.
|
|
|
|
@@ -4904,6 +5045,12 @@ class SyncRunsClient:
|
|
|
|
|
StreamPart(event='end', data=None)
|
|
|
|
|
```
|
|
|
|
|
""" # noqa: E501
|
|
|
|
|
if checkpoint_during is not None:
|
|
|
|
|
warnings.warn(
|
|
|
|
|
"`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.",
|
|
|
|
|
DeprecationWarning,
|
|
|
|
|
stacklevel=2,
|
|
|
|
|
)
|
|
|
|
|
payload = {
|
|
|
|
|
"input": input,
|
|
|
|
|
"command": (
|
|
|
|
@@ -4928,6 +5075,7 @@ class SyncRunsClient:
|
|
|
|
|
"on_disconnect": on_disconnect,
|
|
|
|
|
"on_completion": on_completion,
|
|
|
|
|
"after_seconds": after_seconds,
|
|
|
|
|
"durability": durability,
|
|
|
|
|
}
|
|
|
|
|
endpoint = (
|
|
|
|
|
f"/threads/{thread_id}/runs/stream"
|
|
|
|
@@ -5018,7 +5166,7 @@ class SyncRunsClient:
|
|
|
|
|
context: Context | None = None,
|
|
|
|
|
checkpoint: Checkpoint | None = None,
|
|
|
|
|
checkpoint_id: str | None = None,
|
|
|
|
|
checkpoint_during: bool | None = None,
|
|
|
|
|
checkpoint_during: bool | None = None, # deprecated
|
|
|
|
|
interrupt_before: All | Sequence[str] | None = None,
|
|
|
|
|
interrupt_after: All | Sequence[str] | None = None,
|
|
|
|
|
webhook: str | None = None,
|
|
|
|
@@ -5029,6 +5177,7 @@ class SyncRunsClient:
|
|
|
|
|
headers: Mapping[str, str] | None = None,
|
|
|
|
|
params: QueryParamTypes | None = None,
|
|
|
|
|
on_run_created: Callable[[RunCreateMetadata], None] | None = None,
|
|
|
|
|
durability: Durability | None = None,
|
|
|
|
|
) -> Run:
|
|
|
|
|
"""Create a background run.
|
|
|
|
|
|
|
|
|
@@ -5048,7 +5197,7 @@ class SyncRunsClient:
|
|
|
|
|
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).
|
|
|
|
|
checkpoint_during: (deprecated) 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.
|
|
|
|
|
webhook: Webhook to call after LangGraph API call is done.
|
|
|
|
@@ -5062,6 +5211,10 @@ class SyncRunsClient:
|
|
|
|
|
Use to schedule future runs.
|
|
|
|
|
headers: Optional custom headers to include with the request.
|
|
|
|
|
on_run_created: Optional callback to call when a run is created.
|
|
|
|
|
durability: The durability to use for the run. Values are "sync", "async", or "exit".
|
|
|
|
|
"async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
|
|
|
|
|
"sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
|
|
|
|
|
"exit" means checkpoints are only persisted when the run exits, does not save intermediate steps
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
Run: The created background run.
|
|
|
|
@@ -5137,6 +5290,12 @@ class SyncRunsClient:
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
""" # noqa: E501
|
|
|
|
|
if checkpoint_during is not None:
|
|
|
|
|
warnings.warn(
|
|
|
|
|
"`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.",
|
|
|
|
|
DeprecationWarning,
|
|
|
|
|
stacklevel=2,
|
|
|
|
|
)
|
|
|
|
|
payload = {
|
|
|
|
|
"input": input,
|
|
|
|
|
"command": (
|
|
|
|
@@ -5159,6 +5318,7 @@ class SyncRunsClient:
|
|
|
|
|
"if_not_exists": if_not_exists,
|
|
|
|
|
"on_completion": on_completion,
|
|
|
|
|
"after_seconds": after_seconds,
|
|
|
|
|
"durability": durability,
|
|
|
|
|
}
|
|
|
|
|
payload = {k: v for k, v in payload.items() if v is not None}
|
|
|
|
|
|
|
|
|
@@ -5254,7 +5414,7 @@ class SyncRunsClient:
|
|
|
|
|
metadata: Mapping[str, Any] | None = None,
|
|
|
|
|
config: Config | None = None,
|
|
|
|
|
context: Context | None = None,
|
|
|
|
|
checkpoint_during: bool | None = None,
|
|
|
|
|
checkpoint_during: bool | None = None, # deprecated
|
|
|
|
|
checkpoint: Checkpoint | None = None,
|
|
|
|
|
checkpoint_id: str | None = None,
|
|
|
|
|
interrupt_before: All | Sequence[str] | None = None,
|
|
|
|
@@ -5269,6 +5429,7 @@ class SyncRunsClient:
|
|
|
|
|
headers: Mapping[str, str] | None = None,
|
|
|
|
|
params: QueryParamTypes | None = None,
|
|
|
|
|
on_run_created: Callable[[RunCreateMetadata], None] | None = None,
|
|
|
|
|
durability: Durability | None = None,
|
|
|
|
|
) -> list[dict] | dict[str, Any]:
|
|
|
|
|
"""Create a run, wait until it finishes and return the final state.
|
|
|
|
|
|
|
|
|
@@ -5284,7 +5445,7 @@ class SyncRunsClient:
|
|
|
|
|
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).
|
|
|
|
|
checkpoint_during: (deprecated) 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.
|
|
|
|
|
webhook: Webhook to call after LangGraph API call is done.
|
|
|
|
@@ -5301,6 +5462,10 @@ class SyncRunsClient:
|
|
|
|
|
raise_error: Whether to raise an error if the run fails.
|
|
|
|
|
headers: Optional custom headers to include with the request.
|
|
|
|
|
on_run_created: Optional callback to call when a run is created.
|
|
|
|
|
durability: The durability to use for the run. Values are "sync", "async", or "exit".
|
|
|
|
|
"async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
|
|
|
|
|
"sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
|
|
|
|
|
"exit" means checkpoints are only persisted when the run exits, does not save intermediate steps
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
Union[list[dict], dict[str, Any]]: The output of the run.
|
|
|
|
@@ -5355,6 +5520,12 @@ class SyncRunsClient:
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
""" # noqa: E501
|
|
|
|
|
if checkpoint_during is not None:
|
|
|
|
|
warnings.warn(
|
|
|
|
|
"`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.",
|
|
|
|
|
DeprecationWarning,
|
|
|
|
|
stacklevel=2,
|
|
|
|
|
)
|
|
|
|
|
payload = {
|
|
|
|
|
"input": input,
|
|
|
|
|
"command": (
|
|
|
|
@@ -5376,6 +5547,7 @@ class SyncRunsClient:
|
|
|
|
|
"on_completion": on_completion,
|
|
|
|
|
"after_seconds": after_seconds,
|
|
|
|
|
"raise_error": raise_error,
|
|
|
|
|
"durability": durability,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def on_response(res: httpx.Response):
|
|
|
|
|