Skip to content

Commit

Permalink
Merge pull request #1782 from langchain-ai/nc/20sep/sdk-py-after-seconds
Browse files Browse the repository at this point in the history
sdk: Add support for scheduled runs
  • Loading branch information
nfcampos authored Sep 20, 2024
2 parents 662eae4 + 9121a1e commit fcff81d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions libs/sdk-py/langgraph_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ def stream(
on_disconnect: Optional[DisconnectMode] = None,
webhook: Optional[str] = None,
multitask_strategy: Optional[MultitaskStrategy] = None,
after_seconds: Optional[int] = None,
) -> AsyncIterator[StreamPart]: ...

@overload
Expand All @@ -988,6 +989,7 @@ def stream(
on_disconnect: Optional[DisconnectMode] = None,
webhook: Optional[str] = None,
on_completion: Optional[OnCompletionBehavior] = None,
after_seconds: Optional[int] = None,
) -> AsyncIterator[StreamPart]: ...

def stream(
Expand All @@ -1007,6 +1009,7 @@ def stream(
webhook: Optional[str] = None,
multitask_strategy: Optional[MultitaskStrategy] = None,
on_completion: Optional[OnCompletionBehavior] = None,
after_seconds: Optional[int] = None,
) -> AsyncIterator[StreamPart]:
"""Create a run and stream the results.
Expand All @@ -1030,6 +1033,10 @@ def stream(
Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
on_disconnect: The disconnect mode to use.
Must be one of 'cancel' or 'continue'.
on_completion: The on completion behavior to use.
Must be one of 'delete' or 'keep'.
after_seconds: The number of seconds to wait before starting the run.
Use to schedule future runs.
Returns:
AsyncIterator[StreamPart]: Asynchronous iterator of stream results.
Expand Down Expand Up @@ -1074,6 +1081,7 @@ def stream(
"multitask_strategy": multitask_strategy,
"on_disconnect": on_disconnect,
"on_completion": on_completion,
"after_seconds": after_seconds,
}
endpoint = (
f"/threads/{thread_id}/runs/stream"
Expand All @@ -1097,6 +1105,7 @@ async def create(
interrupt_after: Optional[list[str]] = None,
webhook: Optional[str] = None,
on_completion: Optional[OnCompletionBehavior] = None,
after_seconds: Optional[int] = None,
) -> Run: ...

@overload
Expand All @@ -1113,6 +1122,7 @@ async def create(
interrupt_after: Optional[list[str]] = None,
webhook: Optional[str] = None,
multitask_strategy: Optional[MultitaskStrategy] = None,
after_seconds: Optional[int] = None,
) -> Run: ...

async def create(
Expand All @@ -1129,6 +1139,7 @@ async def create(
webhook: Optional[str] = None,
multitask_strategy: Optional[MultitaskStrategy] = None,
on_completion: Optional[OnCompletionBehavior] = None,
after_seconds: Optional[int] = None,
) -> Run:
"""Create a background run.
Expand All @@ -1146,6 +1157,10 @@ async def create(
webhook: Webhook to call after LangGraph API call is done.
multitask_strategy: Multitask strategy to use.
Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
on_completion: The on completion behavior to use.
Must be one of 'delete' or 'keep'.
after_seconds: The number of seconds to wait before starting the run.
Use to schedule future runs.
Returns:
Run: The created background run.
Expand Down Expand Up @@ -1226,6 +1241,7 @@ async def create(
"checkpoint_id": checkpoint_id,
"multitask_strategy": multitask_strategy,
"on_completion": on_completion,
"after_seconds": after_seconds,
}
payload = {k: v for k, v in payload.items() if v is not None}
if thread_id:
Expand Down Expand Up @@ -1257,6 +1273,7 @@ async def wait(
webhook: Optional[str] = None,
on_disconnect: Optional[DisconnectMode] = None,
multitask_strategy: Optional[MultitaskStrategy] = None,
after_seconds: Optional[int] = None,
) -> Union[list[dict], dict[str, Any]]: ...

@overload
Expand All @@ -1273,6 +1290,7 @@ async def wait(
webhook: Optional[str] = None,
on_disconnect: Optional[DisconnectMode] = None,
on_completion: Optional[OnCompletionBehavior] = None,
after_seconds: Optional[int] = None,
) -> Union[list[dict], dict[str, Any]]: ...

async def wait(
Expand All @@ -1290,6 +1308,7 @@ async def wait(
on_disconnect: Optional[DisconnectMode] = None,
multitask_strategy: Optional[MultitaskStrategy] = None,
on_completion: Optional[OnCompletionBehavior] = None,
after_seconds: Optional[int] = None,
) -> Union[list[dict], dict[str, Any]]:
"""Create a run, wait until it finishes and return the final state.
Expand All @@ -1309,6 +1328,10 @@ async def wait(
Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
on_disconnect: The disconnect mode to use.
Must be one of 'cancel' or 'continue'.
on_completion: The on completion behavior to use.
Must be one of 'delete' or 'keep'.
after_seconds: The number of seconds to wait before starting the run.
Use to schedule future runs.
Returns:
Union[list[dict], dict[str, Any]]: The output of the run.
Expand Down Expand Up @@ -1370,6 +1393,7 @@ async def wait(
"multitask_strategy": multitask_strategy,
"on_disconnect": on_disconnect,
"on_completion": on_completion,
"after_seconds": after_seconds,
}
endpoint = (
f"/threads/{thread_id}/runs/wait" if thread_id is not None else "/runs/wait"
Expand Down

0 comments on commit fcff81d

Please sign in to comment.