
    =Ki                        S r SSKJr  SSKrSSKrSSKJrJrJrJ	r	  SSK
JrJr  SSKrSSKJr  SSKJr  SSKJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'   " S	 S
5      r(g)z,Async client for managing runs in LangGraph.    )annotationsN)AsyncIteratorCallableMappingSequence)Anyoverload)
HttpClient_get_run_metadata_from_response)AllBulkCancelRunsStatusCancelAction
CheckpointCommandConfigContextDisconnectMode
DurabilityIfNotExistsInputMultitaskStrategyOnCompletionBehaviorQueryParamTypesRun	RunCreateRunCreateMetadataRunSelectField	RunStatus
StreamMode
StreamPartc                     \ rS rSrSrS+S jr\SSSSSSSSSSSSSSSSSSSSSSS.                                                 S,S jj5       r\SSSSSSSSSSSSSSSSSSSS	.                                           S-S
 jj5       rSSSSSSSSSSSSSSSSSSSSSSSSS.                                                     S.S jjr\SSSSSSSSSSSSSSSSSSS.                                         S/S jj5       r\SSSSSSSSSSSSSSSSSSSSS.                                             S0S jj5       rSSSSSSSSSSSSSSSSSSSSSSS.                                                 S1S jjrSSS.       S2S jjr	\SSSSSSSSSSSSSSSSSSSS.                                           S3S jj5       r
\SSSSSSSSSSSSSSSSSS.                                       S4S jj5       r
SSSSSSSSSSSSSSSSSSSSSS.                                               S5S jjr
SSSSSSS.               S6S jjrSSS.         S7S  jjrSS!SSS".             S8S# jjrSSSS!SSS$.             S9S% jjrSSS.         S:S& jjrSSSSSS'.               S;S( jjrSSS.         S<S) jjrS*rg)=
RunsClient'   a  Client for managing runs in LangGraph.

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"

    ```python
    client = get_client(url="http://localhost:2024")
    run = await client.runs.create(assistant_id="asst_123", thread_id="thread_456", input={"query": "Hello"})
    ```
c                    Xl         g Nhttp)selfr(   s     [/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/langgraph_sdk/_async/runs.py__init__RunsClient.__init__5   s    	    NvaluesF)inputcommandstream_modestream_subgraphsstream_resumablemetadataconfigcontext
checkpointcheckpoint_idcheckpoint_duringinterrupt_beforeinterrupt_afterfeedback_keyson_disconnectwebhookmultitask_strategyif_not_existsafter_secondsheadersparamson_run_createdc                   g r&    )r)   	thread_idassistant_idr/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   s                            r*   streamRunsClient.stream8   s    8 %(r-   )r/   r0   r1   r2   r3   r4   r5   r9   r:   r;   r<   r=   on_completionr@   r>   rA   rB   rC   rD   c                   g r&   rF   )r)   rG   rH   r/   r0   r1   r2   r3   r4   r5   r9   r:   r;   r<   r=   rK   r@   r>   rA   rB   rC   rD   s                         r*   rI   rJ   V   s    2 %(r-   )r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   rK   r>   r?   r@   rA   rB   rC   rD   
durabilityc          
       ^ Ub  [         R                  " S[        SS9  0 SU_SU(       a,  UR                  5        VVs0 s H  u  nnUc  M  UU_M     snnOS_SU	_SU
_S	U_S
U_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_UUUUUS.EnUb  SU S3OSnSU4S jjnU R                  R                  USUR                  5        VVs0 s H  u  nnUc  M  UU_M     snnUUT(       a  US9$ SS9$ s  snnf s  snnf )a  Create a run and stream the results.

Args:
    thread_id: the thread ID to assign to the thread.
        If `None` will create a stateless run.
    assistant_id: The assistant ID or graph name to stream from.
        If using graph name, will default to first assistant created from that graph.
    input: The input to the graph.
    command: A command to execute. Cannot be combined with input.
    stream_mode: The stream mode(s) to use.
    stream_subgraphs: Whether to stream output from subgraphs.
    stream_resumable: Whether the stream is considered resumable.
        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 "Added in version 0.6.0"
    checkpoint: The checkpoint to resume from.
    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.
    on_disconnect: The disconnect mode to use.
        Must be one of 'cancel' or 'continue'.
    on_completion: Whether to delete or keep the thread created for a stateless run.
        Must be one of 'delete' or 'keep'.
    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'.
    if_not_exists: How to handle missing thread. Defaults to 'reject'.
        Must be either 'reject' (raise error if missing), or 'create' (create new thread).
    after_seconds: The number of seconds to wait before starting the run.
        Use to schedule future runs.
    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:
    Asynchronous iterator of stream results.

???+ example "Example Usage"

    ```python
    client = get_client(url="http://localhost:2024)
    async for chunk in client.runs.stream(
        thread_id=None,
        assistant_id="agent",
        input={"messages": [{"role": "user", "content": "how are you?"}]},
        stream_mode=["values","debug"],
        metadata={"name":"my_run"},
        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"],
        webhook="https://my.fake.webhook.com",
        multitask_strategy="interrupt"
    ):
        print(chunk)
    ```

    ```shell

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    StreamPart(event='metadata', data={'run_id': '1ef4a9b8-d7da-679a-a45a-872054341df2'})
    StreamPart(event='values', data={'messages': [{'content': 'how are you?', 'additional_kwargs': {}, 'response_metadata': {}, 'type': 'human', 'name': None, 'id': 'fe0a5778-cfe9-42ee-b807-0adaa1873c10', 'example': False}]})
    StreamPart(event='values', data={'messages': [{'content': 'how are you?', 'additional_kwargs': {}, 'response_metadata': {}, 'type': 'human', 'name': None, 'id': 'fe0a5778-cfe9-42ee-b807-0adaa1873c10', 'example': False}, {'content': "I'm doing well, thanks for asking! I'm an AI assistant created by Anthropic to be helpful, honest, and harmless.", 'additional_kwargs': {}, 'response_metadata': {}, 'type': 'ai', 'name': None, 'id': 'run-159b782c-b679-4830-83c6-cef87798fe8b', 'example': False, 'tool_calls': [], 'invalid_tool_calls': [], 'usage_metadata': None}]})
    StreamPart(event='end', data=None)
    ```

Nd`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.   
stacklevelr/   r0   r5   r6   r4   r1   r2   r3   rH   r:   r;   r<   r>   r7   r8   r9   r?   )r@   r=   rK   rA   rM   	/threads/z/runs/streamc                L   > T(       a  [        U 5      =n(       a	  T" U5        gggz)Callback function to handle the response.Nr   resr4   rD   s     r*   on_response&RunsClient.stream.<locals>.on_response  &    /Ns/S#S8#Sx( $T~r-   POSTjsonrC   rB   rX   rW   zhttpx.Response)warningswarnDeprecationWarningitemsr(   rI   ) r)   rG   rH   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   rK   r>   r?   r@   rA   rB   rC   rD   rM   kvpayloadendpointrX   s                             `      r*   rI   rJ   q   s   R (MMv"
U
GN'--/C/$!QQA/CTX

 f
 w
 
 ;
  0
  0
 L
  0
 
 ]
 w
  *!
" ]#
$  !2%
& !"4'
( +***$1
8 $ 	{,/ 		)
 yy#*==?D?41aa$!Q$?D'5   
 	
 <@   
 	
E DJ Es   
C5
C5

C;C;)r/   r0   r1   r2   r3   r4   r9   r5   r6   r:   r;   r>   rK   r@   rA   rB   rC   rD   c                  #    g 7fr&   rF   )r)   rG   rH   r/   r0   r1   r2   r3   r4   r9   r5   r6   r:   r;   r>   rK   r@   rA   rB   rC   rD   s                        r*   createRunsClient.create  s
     0    )r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r>   r?   r@   rA   rB   rC   rD   c                  #    g 7fr&   rF   )r)   rG   rH   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r>   r?   r@   rA   rB   rC   rD   s                          r*   rh   ri   )  s
     4 rj   )r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r>   r?   r@   rK   rA   rB   rC   rD   rM   c                 ^#    Ub  [         R                  " S[        SS9  0 SU_SU(       a,  UR                  5        VVs0 s H  u  nnUc  M  UU_M     snnOS_SU_SU_S	U_S
U	_SU
_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_UUUS.EnUR                  5        VVs0 s H  u  nnUc  M  UU_M     nnnSU4S jjnU R                  R                  U(       a  SU S3OSUUUT(       a  UOSS9I Sh  vN $ s  snnf s  snnf  N7f)a  Create a background run.

Args:
    thread_id: the thread ID to assign to the thread.
        If `None` will create a stateless run.
    assistant_id: The assistant ID or graph name to stream from.
        If using graph name, will default to first assistant created from that graph.
    input: The input to the graph.
    command: A command to execute. Cannot be combined with input.
    stream_mode: The stream mode(s) to use.
    stream_subgraphs: Whether to stream output from subgraphs.
    stream_resumable: Whether the stream is considered resumable.
        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 "Added in version 0.6.0"
    checkpoint: The checkpoint to resume from.
    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.
    multitask_strategy: Multitask strategy to use.
        Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
    on_completion: Whether to delete or keep the thread created for a stateless run.
        Must be one of 'delete' or 'keep'.
    if_not_exists: How to handle missing thread. Defaults to 'reject'.
        Must be either 'reject' (raise error if missing), or 'create' (create new thread).
    after_seconds: The number of seconds to wait before starting the run.
        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:
    The created background run.

???+ example "Example Usage"

    ```python

    background_run = await client.runs.create(
        thread_id="my_thread_id",
        assistant_id="my_assistant_id",
        input={"messages": [{"role": "user", "content": "hello!"}]},
        metadata={"name":"my_run"},
        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",
        multitask_strategy="interrupt"
    )
    print(background_run)
    ```

    ```shell
    --------------------------------------------------------------------------------

    {
        'run_id': 'my_run_id',
        'thread_id': 'my_thread_id',
        'assistant_id': 'my_assistant_id',
        'created_at': '2024-07-25T15:35:42.598503+00:00',
        'updated_at': '2024-07-25T15:35:42.598503+00:00',
        'metadata': {},
        'status': 'pending',
        'kwargs':
            {
                'input':
                    {
                        'messages': [
                            {
                                'role': 'user',
                                'content': 'how are you?'
                            }
                        ]
                    },
                'config':
                    {
                        'metadata':
                            {
                                'created_by': 'system'
                            },
                        'configurable':
                            {
                                'run_id': 'my_run_id',
                                'user_id': None,
                                'graph_id': 'agent',
                                'thread_id': 'my_thread_id',
                                'checkpoint_id': None,
                                'assistant_id': 'my_assistant_id'
                            },
                    },
                'context':
                    {
                        'model_name': 'openai'
                    }
                'webhook': "https://my.fake.webhook.com",
                'temporary': False,
                'stream_mode': ['values'],
                'feedback_keys': None,
                'interrupt_after': ["node_to_stop_after_1","node_to_stop_after_2"],
                'interrupt_before': ["node_to_stop_before_1","node_to_stop_before_2"]
            },
        'multitask_strategy': 'interrupt'
    }
    ```
NrO   rP   rQ   r/   r0   r1   r2   r3   r5   r6   r4   rH   r:   r;   r>   r7   r8   r9   r?   r@   )rK   rA   rM   c                L   > T(       a  [        U 5      =n(       a	  T" U5        gggrU   r   rV   s     r*   rX   &RunsClient.create.<locals>.on_response  rZ   r-   rS   /runsr\   r^   )r_   r`   ra   rb   r(   post)r)   rG   rH   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r>   r?   r@   rK   rA   rB   rC   rD   rM   rc   rd   re   rX   s                          `     r*   rh   ri   E  s    V (MMv"

U
GN'--/C/$!QQA/CTX

 ;
  0
  0
 f
 w
 
 L
  0
 
 w
 *
  ]!
"  !2#
$ !"4%
& ]'
( +*$-
0 %,MMOEODAqq41a4OE	)
 YY^^,5i	{%(7'54 $ 
 
 	
9 D* F
s7   =D 
C=
C=
AD"
D0D7AD8D	9DrB   rC   c                  #    SS jnU Vs/ s H
  oT" U5      PM     nnU R                   R                  SXbUS9I Sh  vN $ s  snf  N	7f)z,Create a batch of stateless background runs.c                b    U R                  5        VVs0 s H  u  pUc  M
  X_M     snn$ s  snnf r&   )rb   )re   rc   rd   s      r*   filter_payload/RunsClient.create_batch.<locals>.filter_payload  s(    %,]]_F_TQDAD_FFFs   	++z/runs/batchr]   rB   rC   N)re   r   )r(   rp   )r)   payloadsrB   rC   rt   re   filtereds          r*   create_batchRunsClient.create_batch  sX     	G <DD8N7+8DYY^^& $ 
 
 	
 E
s   
A	A A	A
A	T)r/   r0   r4   r5   r6   r7   r8   r9   r:   r;   r>   r=   r?   r@   rA   raise_errorrB   rC   rD   c                  #    g 7fr&   rF   )r)   rG   rH   r/   r0   r4   r5   r6   r7   r8   r9   r:   r;   r>   r=   r?   r@   rA   r{   rB   rC   rD   s                         r*   waitRunsClient.wait  s
     2 03rj   )r/   r0   r4   r5   r6   r9   r:   r;   r>   r=   rK   r@   rA   r{   rB   rC   rD   c                  #    g 7fr&   rF   )r)   rG   rH   r/   r0   r4   r5   r6   r9   r:   r;   r>   r=   rK   r@   rA   r{   rB   rC   rD   s                       r*   r}   r~   )  s
     . 03rj   )r/   r0   r4   r5   r6   r7   r8   r9   r:   r;   r>   r=   rK   r?   r@   rA   r{   rB   rC   rD   rM   c          
       ^#    U
b  [         R                  " S[        SS9  0 SU_SU(       a,  UR                  5        VVs0 s H  u  nnUc  M  UU_M     snnOS_SU_SU_S	U_S
U_SU_SU_SU_SU_SU	_SU_SU
_SU_SU_SU_SU_SU0EnUb  SU S3OSnS U4S jjnU R                  R                  USUR                  5        VVs0 s H  u  nnUc  M  UU_M     snnUUT(       a  UOSS9I Sh  vN nU(       ag  [        U[        5      (       aR  SU;   aL  [        US   [        5      (       a4  [        US   R                  S5       SUS   R                  S5       35      eU$ s  snnf s  snnf  N7f)!a:  Create a run, wait until it finishes and return the final state.

Args:
    thread_id: the thread ID to create the run on.
        If `None` will create a stateless run.
    assistant_id: The assistant ID or graph name to run.
        If using graph name, will default to first assistant created from that graph.
    input: The input to the graph.
    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 "Added in version 0.6.0"
    checkpoint: The checkpoint to resume from.
    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.
    on_disconnect: The disconnect mode to use.
        Must be one of 'cancel' or 'continue'.
    on_completion: Whether to delete or keep the thread created for a stateless run.
        Must be one of 'delete' or 'keep'.
    multitask_strategy: Multitask strategy to use.
        Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
    if_not_exists: How to handle missing thread. Defaults to 'reject'.
        Must be either 'reject' (raise error if missing), or 'create' (create new thread).
    after_seconds: The number of seconds to wait before starting the run.
        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:
    The output of the run.

???+ example "Example Usage"

    ```python
    client = get_client(url="http://localhost:2024")
    final_state_of_run = await client.runs.wait(
        thread_id=None,
        assistant_id="agent",
        input={"messages": [{"role": "user", "content": "how are you?"}]},
        metadata={"name":"my_run"},
        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",
        multitask_strategy="interrupt"
    )
    print(final_state_of_run)
    ```

    ```shell
    -------------------------------------------------------------------------------------------------------------------------------------------

    {
        'messages': [
            {
                'content': 'how are you?',
                'additional_kwargs': {},
                'response_metadata': {},
                'type': 'human',
                'name': None,
                'id': 'f51a862c-62fe-4866-863b-b0863e8ad78a',
                'example': False
            },
            {
                'content': "I'm doing well, thanks for asking! I'm an AI assistant created by Anthropic to be helpful, honest, and harmless.",
                'additional_kwargs': {},
                'response_metadata': {},
                'type': 'ai',
                'name': None,
                'id': 'run-bf1cd3c6-768f-4c16-b62d-ba6f17ad8b36',
                'example': False,
                'tool_calls': [],
                'invalid_tool_calls': [],
                'usage_metadata': None
            }
        ]
    }
    ```

NrO   rP   rQ   r/   r0   r5   r6   r4   rH   r:   r;   r>   r7   r8   r?   r9   r@   r=   rK   rA   rM   rS   z
/runs/waitc                L   > T(       a  [        U 5      =n(       a	  T" U5        gggrU   r   rV   s     r*   rX   $RunsClient.wait.<locals>.on_response  rZ   r-   r[   r\   	__error__errorz: messager^   )
r_   r`   ra   rb   r(   request_reconnect
isinstancedict	Exceptionget)r)   rG   rH   r/   r0   r4   r5   r6   r7   r8   r9   r:   r;   r>   r=   rK   r?   r@   rA   r{   rB   rC   rD   rM   rc   rd   re   rf   rX   responses                         `       r*   r}   r~   B  s"    d (MMv"

U
GN'--/C/$!QQA/CTX

 f
 w
 
 L
  0
 
 w
 *
 ]
 !"4
  !2
  ]!
" ]#
$ ]%
& ]'
( *)
. 2;1Fi	{*-L 		)
 44#*==?D?41aa$!Q$?D'54 5 
 
 8T**x'8K0$77K(,,W56b+9N9R9RS\9]8^_  [ D> E
s7   =E7 
E)
E)
A5E7

E/E/E74E55BE7
   r   )limitoffsetstatusselectrB   rC   c                  #    UUS.nUb  XHS'   U(       a  XXS'   U(       a  UR                  U5        U R                  R                  SU S3XS9I Sh  vN $  N7f)aK  List runs.

Args:
    thread_id: The thread ID to list runs for.
    limit: The maximum number of results to return.
    offset: The number of results to skip.
    status: The status of the run to filter by.
    headers: Optional custom headers to include with the request.
    params: Optional query parameters to include with the request.

Returns:
    The runs for the thread.

???+ example "Example Usage"

    ```python
    client = get_client(url="http://localhost:2024")
    await client.runs.list(
        thread_id="thread_id",
        limit=5,
        offset=5,
    )
    ```

)r   r   Nr   r   rS   ro   rC   rB   )updater(   r   )	r)   rG   r   r   r   r   rB   rC   query_paramss	            r*   listRunsClient.list  ss     J (
 %+"%+"'YY]]	{%( # 
 
 	
 
s   AAAAc               ^   #    U R                   R                  SU SU 3X4S9I Sh  vN $  N7f)a  Get a run.

Args:
    thread_id: The thread ID to get.
    run_id: The run ID to get.
    headers: Optional custom headers to include with the request.
    params: Optional query parameters to include with the request.

Returns:
    `Run` object.

???+ example "Example Usage"

    ```python
    client = get_client(url="http://localhost:2024")
    run = await client.runs.get(
        thread_id="thread_id_to_delete",
        run_id="run_id_to_delete",
    )
    ```

rS   /runs/rq   N)r(   r   r)   rG   run_idrB   rC   s        r*   r   RunsClient.get  s=     > YY]]	{&17 # 
 
 	
 
s   $-+-	interrupt)r}   actionrB   rC   c                 #    U(       a  SOSUS.nU(       a  UR                  U5        U(       a+  U R                  R                  SU SU S3SUUS9I S	h  vN $ U R                  R                  SU SU S3S	UUS
9I S	h  vN $  N/ N7f)a  Get a run.

Args:
    thread_id: The thread ID to cancel.
    run_id: The run ID to cancel.
    wait: Whether to wait until run has completed.
    action: Action to take when cancelling the run. Possible values
        are `interrupt` or `rollback`. Default is `interrupt`.
    headers: Optional custom headers to include with the request.
    params: Optional query parameters to include with the request.

Returns:
    `None`

???+ example "Example Usage"

    ```python
    client = get_client(url="http://localhost:2024")
    await client.runs.cancel(
        thread_id="thread_id_to_cancel",
        run_id="run_id_to_cancel",
        wait=True,
        action="interrupt"
    )
    ```

   r   )r}   r   rS   r   z/cancelr[   r   N)r]   rC   rB   )r   r(   r   rp   )r)   rG   r   r}   r   rB   rC   r   s           r*   cancelRunsClient.cancelA  s     L A1
 '44I;fVHG<#	 5    I;fVHG<#	 (   s$   AB
B*B
BB
B
)rG   run_idsr   r   rB   rC   c                  #    0 nU(       a  XS'   U(       a  X'S'   U(       a  X7S'   SU0nU(       a  UR                  U5        U R                  R                  SUUUS9I Sh  vN   g N7f)a  Cancel one or more runs.

Can cancel runs by thread ID and run IDs, or by status filter.

Args:
    thread_id: The ID of the thread containing runs to cancel.
    run_ids: List of run IDs to cancel.
    status: Filter runs by status to cancel. Must be one of
        `"pending"`, `"running"`, or `"all"`.
    action: Action to take when cancelling the run. Possible values
        are `"interrupt"` or `"rollback"`. Default is `"interrupt"`.
    headers: Optional custom headers to include with the request.
    params: Optional query parameters to include with the request.

Returns:
    `None`

???+ example "Example Usage"

    ```python
    client = get_client(url="http://localhost:2024")
    # Cancel all pending runs
    await client.runs.cancel_many(status="pending")
    # Cancel specific runs on a thread
    await client.runs.cancel_many(
        thread_id="my_thread_id",
        run_ids=["run_1", "run_2"],
        action="rollback",
    )
    ```

rG   r   r   r   z/runs/cancelrv   N)r   r(   rp   )	r)   rG   r   r   r   rB   rC   re   r   s	            r*   cancel_manyRunsClient.cancel_many{  st     T #%#,K !(I &H(0&'9'iinn	  
 	
 	
s   AA)!A'"A)c               d   #    U R                   R                  SU SU S3SUUS9I Sh  vN $  N7f)a  Block until a run is done. Returns the final state of the thread.

Args:
    thread_id: The thread ID to join.
    run_id: The run ID to join.
    headers: Optional custom headers to include with the request.
    params: Optional query parameters to include with the request.

Returns:
    `None`

???+ example "Example Usage"

    ```python
    client = get_client(url="http://localhost:2024")
    result =await client.runs.join(
        thread_id="thread_id_to_join",
        run_id="run_id_to_join"
    )
    ```

rS   r   z/joinGETrq   N)r(   r   r   s        r*   joinRunsClient.join  sH     < YY00	{&6	 1 
 
 	
 
s   '0.0)cancel_on_disconnectr1   rB   rC   last_event_idc                   UUS.nU(       a  UR                  U5        U R                  R                  SU SU S3SU0 U(       a  SU0O0 EU=(       d    0 E=(       d    SS9$ )	a  Stream output from a run in real-time, until the run is done.
Output is not buffered, so any output produced before this call will
not be received here.

Args:
    thread_id: The thread ID to join.
    run_id: The run ID to join.
    cancel_on_disconnect: Whether to cancel the run when the stream is disconnected.
    stream_mode: The stream mode(s) to use. Must be a subset of the stream modes passed
        when creating the run. Background runs default to having the union of all
        stream modes.
    headers: Optional custom headers to include with the request.
    params: Optional query parameters to include with the request.
    last_event_id: The last event ID to use for the stream.

Returns:
    The stream of parts.

???+ example "Example Usage"

    ```python
    client = get_client(url="http://localhost:2024")
    async for part in client.runs.join_stream(
        thread_id="thread_id_to_join",
        run_id="run_id_to_join",
        stream_mode=["values", "debug"]
    ):
        print(part)
    ```

)r   r1   rS   r   z/streamr   zLast-Event-IDNr   )r   r(   rI   )	r)   rG   r   r   r1   rB   rC   r   r   s	            r*   join_streamRunsClient.join_stream  s    V %9&
 'yy	{&87DO]3"=b     	
 		
r-   c               `   #    U R                   R                  SU SU 3X4S9I Sh  vN   g N7f)a  Delete a run.

Args:
    thread_id: The thread ID to delete.
    run_id: The run ID to delete.
    headers: Optional custom headers to include with the request.
    params: Optional query parameters to include with the request.

Returns:
    `None`

???+ example "Example Usage"

    ```python
    client = get_client(url="http://localhost:2024")
    await client.runs.delete(
        thread_id="thread_id_to_delete",
        run_id="run_id_to_delete"
    )
    ```

rS   r   rq   N)r(   deleter   s        r*   r   RunsClient.delete  s:     < ii	{&17  
 	
 	
s   $.,.r'   )r(   r
   returnNone)2rG   strrH   r   r/   Input | Noner0   Command | Noner1   !StreamMode | Sequence[StreamMode]r2   boolr3   r   r4   Mapping[str, Any] | Noner5   Config | Noner6   Context | Noner7   Checkpoint | Noner8   
str | Noner9   bool | Noner:   All | Sequence[str] | Noner;   r   r<   Sequence[str] | Noner=   DisconnectMode | Noner>   r   r?   MultitaskStrategy | Noner@   IfNotExists | NonerA   
int | NonerB   Mapping[str, str] | NonerC   QueryParamTypes | NonerD   *Callable[[RunCreateMetadata], None] | Noner   AsyncIterator[StreamPart]),rG   r   rH   r   r/   r   r0   r   r1   r   r2   r   r3   r   r4   r   r5   r   r9   r   r:   r   r;   r   r<   r   r=   r   rK   OnCompletionBehavior | Noner@   r   r>   r   rA   r   rB   r   rC   r   rD   r   r   r   )6rG   r   rH   r   r/   r   r0   r   r1   r   r2   r   r3   r   r4   r   r5   r   r6   r   r7   r   r8   r   r9   r   r:   r   r;   r   r<   r   r=   r   rK   r   r>   r   r?   r   r@   r   rA   r   rB   r   rC   r   rD   r   rM   Durability | Noner   r   )*rG   r   rH   r   r/   r   r0   r   r1   r   r2   r   r3   r   r4   r   r9   r   r5   r   r6   r   r:   r   r;   r   r>   r   rK   r   r@   r   rA   r   rB   r   rC   r   rD   r   r   r   ).rG   r   rH   r   r/   r   r0   r   r1   r   r2   r   r3   r   r4   r   r5   r   r6   r   r7   r   r8   r   r9   r   r:   r   r;   r   r>   r   r?   r   r@   r   rA   r   rB   r   rC   r   rD   r   r   r   )2rG   r   rH   r   r/   r   r0   r   r1   r   r2   r   r3   r   r4   r   r5   r   r6   r   r7   r   r8   r   r9   r   r:   r   r;   r   r>   r   r?   r   r@   r   rK   r   rA   r   rB   r   rC   r   rD   r   rM   r   r   r   )rw   zbuiltins.list[RunCreate]rB   r   rC   r   r   builtins.list[Run]),rG   r   rH   r   r/   r   r0   r   r4   r   r5   r   r6   r   r7   r   r8   r   r9   r   r:   r   r;   r   r>   r   r=   r   r?   r   r@   r   rA   r   r{   r   rB   r   rC   r   rD   r   r   $builtins.list[dict] | dict[str, Any])(rG   r   rH   r   r/   r   r0   r   r4   r   r5   r   r6   r   r9   r   r:   r   r;   r   r>   r   r=   r   rK   r   r@   r   rA   r   r{   r   rB   r   rC   r   rD   r   r   r   )0rG   r   rH   r   r/   r   r0   r   r4   r   r5   r   r6   r   r7   r   r8   r   r9   r   r:   r   r;   r   r>   r   r=   r   rK   r   r?   r   r@   r   rA   r   r{   r   rB   r   rC   r   rD   r   rM   r   r   r   )rG   r   r   intr   r   r   zRunStatus | Noner   z$builtins.list[RunSelectField] | NonerB   r   rC   r   r   r   )
rG   r   r   r   rB   r   rC   r   r   r   )rG   r   r   r   r}   r   r   r   rB   r   rC   r   r   r   )rG   r   r   r   r   zBulkCancelRunsStatus | Noner   r   rB   r   rC   r   r   r   )
rG   r   r   r   rB   r   rC   r   r   r   )rG   r   r   r   r   r   r1   z(StreamMode | Sequence[StreamMode] | NonerB   r   rC   r   r   r   r   r   )
rG   r   r   r   rB   r   rC   r   r   r   )__name__
__module____qualname____firstlineno____doc__r+   r	   rI   rh   ry   r}   r   r   r   r   r   r   r   __static_attributes__rF   r-   r*   r#   r#   '   s     #"&9A!&!&-1 $"&(,$()-7;6:.2/3"7;,0$(,0)-EI5(( (
 (  ( 7( ( ( +( (  ( &( "( '(  5!(" 4#($ ,%(& -'(( )(* 5+(, *-(. "/(0 *1(2 '3(4 C5(6 
#7( (:  #"&9A!&!&-1 $)-7;6:.2/359,0"$(,0)-EI/(( (
 (  ( 7( ( ( +( ( '( 5( 4( ,(  -!(" 3#($ *%(& '(( ")(* *+(, '-(. C/(0 
#1( (> #"&9A!&!&-1 $"&(,$()-7;6:.2/359"7;,0$(,0)-EI(,9\
\
 \

 \
  \
 7\
 \
 \
 +\
 \
  \
 &\
 "\
 '\
  5!\
" 4#\
$ ,%\
& -'\
( 3)\
* +\
, 5-\
. */\
0 "1\
2 *3\
4 '5\
6 C7\
8 &9\
: 
#;\
|  #"&9A!&!&-1)- $"&7;6:"59,0$(,0)-EI- 
    7   + '    5 4  !" 3#$ *%& "'( *)* '+, C-. 
/ 2  #"&9A!&!&-1 $"&(,$()-7;6:"7;,0$(,0)-EI1 
    7   +    & " '  5!" 4#$ %& 5'( *)* "+, *-. '/0 C12 
3 @ #"&9A!&!&-1 $"&(,$()-7;6:"7;,059$(,0)-EI(,5v
v
 v

 v
  v
 7v
 v
 v
 +v
 v
  v
 &v
 "v
 'v
  5!v
" 4#v
$ %v
& 5'v
( *)v
* 3+v
, "-v
. */v
0 '1v
2 C3v
4 &5v
6 
7v
x -1)-
*
 *	

 '
 

"  #"&-1 $"&(,$()-7;6:"/37;,0$( ,0)-EI/33 3
 3  3 +3 3  3 &3 "3 '3 53 43 3  -!3" 5#3$ *%3& "'3( )3* *+3, '-3. C/30 
.13 34  #"&-1 $"&)-7;6:"/359,0$( ,0)-EI+33 3
 3  3 +3 3  3 '3 53 43 3 -3 33  *!3" "#3$ %3& *'3( ')3* C+3, 
.-3 3: #"&-1 $"&(,$()-7;6:"/3597;,0$( ,0)-EI(,3hh h
 h  h +h h  h &h "h 'h 5h 4h h  -!h" 3#h$ 5%h& *'h( ")h* +h, *-h. '/h0 C1h2 &3h4 
.5h\ #'7;,0)-0
0
 	0

 0
 !0
 50
 *0
 '0
 
0
n -1)-!
!
 !

 *!
 '!
 
!
P *,0)-88 8
 8 8 *8 '8 
8z !%(,.2*,0)-9
 9
 &	9

 ,9
 9
 *9
 '9
 
9
@ -1)-#
#
 #

 *#
 '#
 
#
T &+@D,0)-$(9
9
 9

 #9
 >9
 *9
 '9
 "9
 
#9
@ -1)- 
 
  

 * 
 ' 
 
 
  
r-   r#   ))r   
__future__r   builtinsr_   collections.abcr   r   r   r   typingr   r	   httpxlanggraph_sdk._async.httpr
   langgraph_sdk._shared.utilitiesr   langgraph_sdk.schemar   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r#   rF   r-   r*   <module>r      sM    2 "   F F    0 K     2O
 O
r-   