
    >'hd                      U d Z ddlmZ ddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZmZmZmZmZmZmZmZ ddlZddlZddlmZ ddlZddlmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8 ddl9m:Z:m;Z;m<Z<  ejz                  e>      Z?dZ@d6d7d	ZA	 	 	 	 	 	 d8d
ZBd9dZCddddd	 	 	 	 	 	 	 	 	 d:dZD G d d      ZE G d d      ZFd;dZGd<dZH G d d      ZI G d d      ZJ G d d      ZK G d d      ZL G d d      ZMddddd	 	 	 	 	 	 	 	 	 d=dZN G d  d      ZO G d! d"      ZPd;d#ZQd<d$ZR G d% d&      ZS G d' d(      ZT G d) d*      ZU G d+ d,      ZV G d- d.      ZWd>d/ZXg ZYd0eZd1<   d?d2Z[ ej                  d34      d@d5       Z]eee^   e_ee^   ee^   ee^   ee^   f   ej                  f   Zay)Aa  The LangGraph client implementations connect to the LangGraph API.

This module provides both asynchronous ([get_client(url="http://localhost:2024"))](#get_client) or [LangGraphClient](#LangGraphClient))
and synchronous ([get_sync_client(url="http://localhost:2024"))](#get_sync_client) or [SyncLanggraphClient](#SyncLanggraphClient))
clients to interacting with the LangGraph API's core resources such as
Assistants, Threads, Runs, and Cron jobs, as well as its persistent
document Store.
    )annotationsN)AnyAsyncIteratorDictIteratorListLiteralOptionalSequenceTypeUnionoverload)QueryParamTypes)All	AssistantAssistantSortByAssistantVersionCancelAction
CheckpointCommandConfigCronDisconnectModeGraphSchemaIfNotExistsItemJsonListNamespaceResponseMultitaskStrategyOnCompletionBehaviorOnConflictBehaviorRun	RunCreate	RunStatusSearchItemsResponse	SortOrder
StreamMode
StreamPart	SubgraphsThreadThreadSortByThreadStateThreadStatusThreadUpdateStateResponse)
SSEDecoderaiter_lines_rawiter_lines_raw)	x-api-keyc                    | r| S dD ]L  }t        j                  | d      x}s|j                         j                  d      j                  d      c S  y)zGet the API key from the environment.
    Precedence:
        1. explicit argument
        2. LANGGRAPH_API_KEY
        3. LANGSMITH_API_KEY
        4. LANGCHAIN_API_KEY
    )	LANGGRAPH	LANGSMITH	LANGCHAIN_API_KEY"'N)osgetenvstrip)api_keyprefixenvs      [/home/kushmeetdev/Regenta/Chatbot/venv/lib/python3.12/site-packages/langgraph_sdk/client.py_get_api_keyrA   M   s]     9 5))vhh/003099;$$S)//445     c                    |xs i }t         D ]  }||v st        d| d       ddt        j                   i|}t	        |       } | r| |d<   |S )z1Combine api_key and custom user-provided headers.zCannot set reserved header 'r9   z
User-Agentzlanggraph-sdk-py/r2   )RESERVED_HEADERS
ValueErrorlanggraph_sdk__version__rA   )r=   custom_headersheaderheaderss       r@   _get_headersrK   ]   s     $)rN" G^#;F81EFFG
 	)-*C*C)DE
G 7#G&NrB   c                8   t        | d      r%t        | j                        r| j                         S t        | d      r%t        | j                        r| j                         S t	        | t
        t        f      rt        |       S t        dt        |        d      )N
model_dumpdictzObject of type z is not JSON serializable)
hasattrcallablerM   rN   
isinstanceset	frozensetlist	TypeErrortype)objs    r@   _orjson_defaultrX   q   sw    sL!hs~~&>~~	f	(388"4xxz	C#y)	*Cy/$s)4MNOOrB   )urlr=   rJ   timeoutLangGraphClientc           
        d}| gt         j                  j                  d      dk(  r* t               dd      }t        j                  |       d} n	 ddlm} d}  t               |d	      }|t        j                  d      }t        j                  | ||t        j                  |      nt        j                  dddd      t        ||            }t        |      S # t        $ r d
} Y w xY w)a  Get a LangGraphClient instance.

    Args:
        url: The URL of the LangGraph API.
        api_key: The API key. If not provided, it will be read from the environment.
            Precedence:
                1. explicit argument
                2. LANGGRAPH_API_KEY
                3. LANGSMITH_API_KEY
                4. LANGCHAIN_API_KEY
        headers: Optional custom headers
        timeout: Optional timeout configuration for the HTTP client.
            Accepts an httpx.Timeout instance, a float (seconds), or a tuple of timeouts.
            Tuple format is (connect, read, write, pool)
            If not provided, defaults to connect=5s, read=300s, write=300s, and pool=5s.

    Returns:
        LangGraphClient: The top-level client for accessing AssistantsClient,
        ThreadsClient, RunsClient, and CronClient.

    ???+ example "Example"

        ```python
        from langgraph_sdk import get_client

        # get top-level LangGraphClient
        client = get_client(url="http://localhost:8123")

        # example usage: client.<model>.<method_name>()
        assistants = await client.assistants.get(assistant_id="some_uuid")
        ```
    N$__LANGGRAPH_DEFER_LOOPBACK_TRANSPORTtruez/noauth)app	root_pathz
http://apir   )r_   )r`   http://localhost:8123   retries,  connectreadwritepoolbase_url	transportrZ   rJ   )r:   environgetget_asgi_transport_registered_transportsappendlanggraph_api.serverr_   	ExceptionhttpxAsyncHTTPTransportAsyncClientTimeoutrK   r[   )rY   r=   rJ   rZ   rm   r_   clients          r@   
get_clientrz   |   s    P 59I
{::>>@AVK,*,KI")))4C.4"0.0	J	 ,,Q7	 " MM'"qs#AFWg.	F 6""  .-.s   C   C.-C.c                      e Zd ZdZddZy)r[   a  Top-level client for LangGraph API.

    Attributes:
        assistants: Manages versioned configuration for your graphs.
        threads: Handles (potentially) multi-turn interactions, such as conversational threads.
        runs: Controls individual invocations of the graph.
        crons: Manages scheduled operations.
        store: Interfaces with persistent, shared data storage.
    c                (   t        |      | _        t        | j                        | _        t	        | j                        | _        t        | j                        | _        t        | j                        | _	        t        | j                        | _        y N)
HttpClienthttpAssistantsClient
assistantsThreadsClientthreads
RunsClientruns
CronClientcronsStoreClientstoreselfry   s     r@   __init__zLangGraphClient.__init__   s^    v&	*4995$TYY/tyy)			*
 +
rB   Nry   zhttpx.AsyncClientreturnNone__name__
__module____qualname____doc__r    rB   r@   r[   r[      s    ,rB   c                      e Zd ZdZddZddd	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 dd	Zddd
	 	 	 	 	 	 	 ddZ	dddd	 	 	 	 	 	 	 	 	 	 	 ddZ
y)r~   zHandle async requests to the LangGraph API.

    Adds additional error messaging & content handling above the
    provided httpx client.

    Attributes:
        client (httpx.AsyncClient): Underlying HTTPX async client.
    c                    || _         y r}   ry   r   s     r@   r   zHttpClient.__init__   	    rB   NparamsrJ   c                 K   | j                   j                  |||       d{   }	 |j                          t        |       d{   S 7 (# t        j                  $ rn}|j                          d{  7  j                         }t        j                  dk\  r|j                  |       |t        j                  d| |       |d}~ww xY w7 w)Send a GET request.r   N      Error from langgraph-api: exc_info)ry   ro   raise_for_statusru   HTTPStatusErrorareaddecodesysversion_infoadd_noteloggererror_adecode_jsonr   pathr   rJ   rebodys          r@   ro   zHttpClient.get   s      ++//$vw/GG	  #1%%% H $$ 	'')OO++-D7*

4  G 9$@1MG	 &sJ   "CACA CC	CC"C5A86ACCCrJ   c                 K   |t        |       d{   \  }}ni d}}|r|j                  |       | j                  j                  |||       d{   }	 |j	                          t        |       d{   S 7 i7 *# t
        j                  $ rn}|j                          d{  7  j                         }t        j                  dk\  r|j                  |       |t        j                  d| |       |d}~ww xY w7 wzSend a POST request.NrB   rJ   contentr   r   r   )_aencode_jsonupdatery   postr   ru   r   r   r   r   r   r   r   r   r   	r   r   jsonrJ   request_headersr   r   r   r   s	            r@   r   zHttpClient.post   s      -:4-@'@$OW')3WO""7+++""4'"RR	  #1%%%! (A S $$ 	'')OO++-D7*

4  G 9$@1MG	 &s_   DA=A DA?DB *D8D9D?DDC='B*(AC==DDc                 K   t        |       d{   \  }}|r|j                  |       | j                  j                  |||       d{   }	 |j	                          t        |       d{   S 7 d7 *# t
        j                  $ rn}|j                          d{  7  j                         }t        j                  dk\  r|j                  |       |t        j                  d| |       |d}~ww xY w7 w)Send a PUT request.Nr   r   r   r   )r   r   ry   putr   ru   r   r   r   r   r   r   r   r   r   r   s	            r@   r   zHttpClient.put  s      *7t)<#< ""7+++//$/QQ	  #1%%% $= R $$ 	'')OO++-D7*

4  G 9$@1MG	 &^   D A6;D A8D A: #D 1C>2D 8D :C;C6 B#!AC66C;;D c                 K   t        |       d{   \  }}|r|j                  |       | j                  j                  |||       d{   }	 |j	                          t        |       d{   S 7 d7 *# t
        j                  $ rn}|j                          d{  7  j                         }t        j                  dk\  r|j                  |       |t        j                  d| |       |d}~ww xY w7 w)Send a PATCH request.Nr   r   r   r   )r   r   ry   patchr   ru   r   r   r   r   r   r   r   r   r   r   s	            r@   r   zHttpClient.patch&  s      *7t)<#< ""7+++##D/7#SS	  #1%%% $= T $$ 	'')OO++-D7*

4  G 9$@1MG	 &r   r   rJ   c                 K   | j                   j                  d|||       d{   }	 |j                          y7 # t        j                  $ rn}|j                          d{  7  j                         }t        j                  dk\  r|j                  |       |t        j                  d| |       |d}~ww xY ww)Send a DELETE request.DELETEr   Nr   r   r   )ry   requestr   ru   r   r   r   r   r   r   r   r   r   r   r   rJ   r   r   r   s          r@   deletezHttpClient.delete9  s      ++%%h4%QQ	  R $$ 	'')OO++-D7*

4  G 9$@1MG	s;   #C<C> CB?B:$A'%AB::B??Cr   r   rJ   c              l  K   t        |       d{   \  }}d|d<   d|d<   |r|j                  |       | j                  j                  |||||      4 d{   }	 |j	                          |j                  j                  d
d      j!                  d      d   }d|vrt        j"                  d|      t%               }t'        |      2 3 d{   }|j                  |j)                  d            }|-| 37 7 # t
        j                  $ rn}	|j                          d{  7  j                         }
t        j                  dk\  r|	j                  |
       |	t        j                  d|
 |		       |	d}	~	ww xY w7 6 ddd      d{  7   y# 1 d{  7  sw Y   yxY ww)zStream results using SSE.Ntext/event-streamAcceptno-storeCache-ControlrJ   r   r   r   r   r   content-type ;r   JExpected response header Content-Type to contain 'text/event-stream', got    
)line)r   r   ry   streamr   ru   r   r   r   r   r   r   r   r   rJ   ro   	partitionTransportErrorr/   r0   rstripr   r   methodr   r   rJ   r   r   resr   r   content_typedecoderr   sses                  r@   r   zHttpClient.streamL  s     *7t)<#< $7!+5(""7+;;%%D/76 & 
 	 	$$& ;;??>2>HHMaPL",6**'*, 
 !lG-c2  dnn$++e*<n=?IA $=	 (( !iik))113##w.JJt$  LL#=dV!DqLQ 2-	 	 	 	 	s   F4DAF4DF4F D0AFFF
F$F<FF4F4FF,D/-AFFF
FFF4FF4F1%F(&F1-F4r   r   strr   Optional[QueryParamTypes]rJ   Optional[dict[str, str]]r   r   r   r   r   Optional[dict]rJ   r   r   r   r   r   r   rN   rJ   r   r   r   r   r   r   zOptional[Any]rJ   r   r   r   )r   r   r   r   r   r   r   r   rJ   r   r   AsyncIterator[StreamPart]r   r   r   r   r   ro   r   r   r   r   r   r   rB   r@   r~   r~      sD    -1,0&& *	&
 *& 
&2 -1&& 	&
 *& 
&8 MQ&&"&&1I&	&( MQ&&"&&1I&	&. #,0 	
 * 
0  $,0,0** *
 * ** ** 
#*rB   r~   c                  K   | i d fS t        j                         j                  d t        j                  | t
        t        j                  t        j                  z         d {   }t        t        |            }d}||d}||fS 7 #wNzapplication/json)zContent-LengthzContent-Type)
asyncioget_running_looprun_in_executororjsondumpsrX   OPT_SERIALIZE_NUMPYOPT_NON_STR_KEYSr   lenr   r   content_lengthr   rJ   s        r@   r   r   y  s     |4x))+;;""V%<%<< D T^N%L!/NGD=s   A"B
$B%$B
c                   K   | j                          d {   }|r;t        j                         j                  d t        j
                  |       d {   S d S 7 C7 wr}   )r   r   r   r   r   loadsr   r   s     r@   r   r     sT     ?D  &&(88v||TRR  Rs!   AA<AAAAc                     e Zd ZdZddZdd	 	 	 	 	 ddZddd	 	 	 	 	 	 	 ddZdd	 	 	 	 	 dd	Z	 	 ddd	 	 	 	 	 	 	 	 	 dd
Z	 dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	ddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ
dd	 	 	 	 	 ddZdddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d dZ	 	 	 d!dd	 	 	 	 	 	 	 	 	 	 	 d"dZdd	 	 	 	 	 	 	 d#dZy)$r   a]  Client for managing assistants in LangGraph.

    This class provides methods to interact with assistants,
    which are versioned configurations of your graph.

    ???+ example "Example"

        ```python
        client = get_client(url="http://localhost:2024")
        assistant = await client.assistants.get("assistant_id_123")
        ```
    c                    || _         y r}   r   r   r   s     r@   r   zAssistantsClient.__init__  	    	rB   Nr   c               ^   K   | j                   j                  d| |       d{   S 7 w)a  Get an assistant by ID.

        Args:
            assistant_id: The ID of the assistant to get.
            headers: Optional custom headers to include with the request.

        Returns:
            Assistant: Assistant Object.

        ???+ example "Example Usage"

            ```python
            assistant = await client.assistants.get(
                assistant_id="my_assistant_id"
            )
            print(assistant)
            ```

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

            {
                'assistant_id': 'my_assistant_id',
                'graph_id': 'agent',
                'created_at': '2024-06-25T17:10:33.109781+00:00',
                'updated_at': '2024-06-25T17:10:33.109781+00:00',
                'config': {},
                'metadata': {'created_by': 'system'},
                'version': 1,
                'name': 'my_assistant'
            }
            ```
        /assistants/r   Nr   ro   r   assistant_idrJ   s      r@   ro   zAssistantsClient.get  s-     H YY]]\,#@']RRRR   $-+-FxrayrJ   c               f   K   | j                   j                  d| dd|i|       d{   S 7 w)a  Get the graph of an assistant by ID.

        Args:
            assistant_id: The ID of the assistant to get the graph of.
            xray: Include graph representation of subgraphs. If an integer value is provided, only subgraphs with a depth less than or equal to the value will be included.
            headers: Optional custom headers to include with the request.

        Returns:
            Graph: The graph information for the assistant in JSON format.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            graph_info = await client.assistants.get_graph(
                assistant_id="my_assistant_id"
            )
            print(graph_info)
            ```

            ```shell

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

            {
                'nodes':
                    [
                        {'id': '__start__', 'type': 'schema', 'data': '__start__'},
                        {'id': '__end__', 'type': 'schema', 'data': '__end__'},
                        {'id': 'agent','type': 'runnable','data': {'id': ['langgraph', 'utils', 'RunnableCallable'],'name': 'agent'}},
                    ],
                'edges':
                    [
                        {'source': '__start__', 'target': 'agent'},
                        {'source': 'agent','target': '__end__'}
                    ]
            }
            ```


        r  /graphr  r   Nr  r   r  r  rJ   s       r@   	get_graphzAssistantsClient.get_graph  sB     ` YY]]<./PW # 
 
 	
 
   (1/1c               `   K   | j                   j                  d| d|       d{   S 7 w)ac  Get the schemas of an assistant by ID.

        Args:
            assistant_id: The ID of the assistant to get the schema of.
            headers: Optional custom headers to include with the request.

        Returns:
            GraphSchema: The graph schema for the assistant.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            schema = await client.assistants.get_schemas(
                assistant_id="my_assistant_id"
            )
            print(schema)
            ```

            ```shell

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

            {
                'graph_id': 'agent',
                'state_schema':
                    {
                        'title': 'LangGraphInput',
                        '$ref': '#/definitions/AgentState',
                        'definitions':
                            {
                                'BaseMessage':
                                    {
                                        'title': 'BaseMessage',
                                        'description': 'Base abstract Message class. Messages are the inputs and outputs of ChatModels.',
                                        'type': 'object',
                                        'properties':
                                            {
                                             'content':
                                                {
                                                    'title': 'Content',
                                                    'anyOf': [
                                                        {'type': 'string'},
                                                        {'type': 'array','items': {'anyOf': [{'type': 'string'}, {'type': 'object'}]}}
                                                    ]
                                                },
                                            'additional_kwargs':
                                                {
                                                    'title': 'Additional Kwargs',
                                                    'type': 'object'
                                                },
                                            'response_metadata':
                                                {
                                                    'title': 'Response Metadata',
                                                    'type': 'object'
                                                },
                                            'type':
                                                {
                                                    'title': 'Type',
                                                    'type': 'string'
                                                },
                                            'name':
                                                {
                                                    'title': 'Name',
                                                    'type': 'string'
                                                },
                                            'id':
                                                {
                                                    'title': 'Id',
                                                    'type': 'string'
                                                }
                                            },
                                        'required': ['content', 'type']
                                    },
                                'AgentState':
                                    {
                                        'title': 'AgentState',
                                        'type': 'object',
                                        'properties':
                                            {
                                                'messages':
                                                    {
                                                        'title': 'Messages',
                                                        'type': 'array',
                                                        'items': {'$ref': '#/definitions/BaseMessage'}
                                                    }
                                            },
                                        'required': ['messages']
                                    }
                            }
                    },
                'config_schema':
                    {
                        'title': 'Configurable',
                        'type': 'object',
                        'properties':
                            {
                                'model_name':
                                    {
                                        'title': 'Model Name',
                                        'enum': ['anthropic', 'openai'],
                                        'type': 'string'
                                    }
                            }
                    }
            }
            ```

        r  /schemasr   Nr  r  s      r@   get_schemaszAssistantsClient.get_schemas  s;     ` YY]]<.17 # 
 
 	
 
s   %.,.c                  K   |.| j                   j                  d| d| d|i|       d{   S | j                   j                  d| dd|i|       d{   S 7 07 w)a  Get the schemas of an assistant by ID.

        Args:
            assistant_id: The ID of the assistant to get the schema of.
            namespace: Optional namespace to filter by.
            recurse: Whether to recursively get subgraphs.
            headers: Optional custom headers to include with the request.

        Returns:
            Subgraphs: The graph schema for the assistant.

        Nr  /subgraphs/recurser   
/subgraphsr  r   r  	namespacer  rJ   s        r@   get_subgraphszAssistantsClient.get_subgraphsq  s     (  |nK	{C!7+ '    |nJ7!7+ '   s!   ,A#A+A#A!A#!A#metadatar  	if_existsnamerJ   descriptionc                  K   d|i}	|r||	d<   |r||	d<   |r||	d<   |r||	d<   |r||	d<   |r||	d<   | j                   j                  d|	|	       d
{   S 7 w)a  Create a new assistant.

        Useful when graph is configurable and you want to create different assistants based on different configurations.

        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.
            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.
                Must be either 'raise' (raise error if duplicate), or 'do_nothing' (return existing assistant).
            name: The name of the assistant. Defaults to 'Untitled' under the hood.
            headers: Optional custom headers to include with the request.
            description: Optional description of the assistant.
                The description field is available for langgraph-api server version>=0.0.45

        Returns:
            Assistant: The created assistant.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            assistant = await client.assistants.create(
                graph_id="agent",
                config={"configurable": {"model_name": "openai"}},
                metadata={"number":1},
                assistant_id="my-assistant-id",
                if_exists="do_nothing",
                name="my_name"
            )
            ```
        graph_idconfigr  r  r  r  r  /assistantsr   Nr   r   
r   r  r  r  r  r  r  rJ   r  payloads
             r@   createzAssistantsClient.create  s     \ #
  &GH"*GJ&2GN##,GK "GFO%0GM"YY^^M^QQQQs   AAAAr  r  r  r  rJ   r  c                  K   i }|r||d<   |r||d<   |r||d<   |r||d<   |r||d<   | j                   j                  d| ||       d{   S 7 w)	a  Update an assistant.

        Use this to point to a different graph, update the configuration, or change the metadata of an assistant.

        Args:
            assistant_id: Assistant to update.
            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.
            metadata: Metadata to merge with existing assistant metadata.
            name: The new name for the assistant.
            headers: Optional custom headers to include with the request.
            description: Optional description of the assistant.
                The description field is available for langgraph-api server version>=0.0.45

        Returns:
            Assistant: The updated assistant.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            assistant = await client.assistants.update(
                assistant_id='e280dad7-8618-443f-87f1-8e41841c180f',
                graph_id="other-graph",
                config={"configurable": {"model_name": "anthropic"}},
                metadata={"number":2}
            )
            ```

        r  r  r  r  r  r  r   Nr   r   	r   r  r  r  r  r  rJ   r  r#  s	            r@   r   zAssistantsClient.update  s     T #%"*GJ &GH"*GJ"GFO%0GM"YY__<.) % 
 
 	
 
   A
AAAc               `   K   | j                   j                  d| |       d{    y7 w)a  Delete an assistant.

        Args:
            assistant_id: The assistant ID to delete.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            await client.assistants.delete(
                assistant_id="my_assistant_id"
            )
            ```

        r  r   Nr   r   r  s      r@   r   zAssistantsClient.delete  s,     2 iil^<gNNN   $.,.
   r   )r  r  limitoffsetsort_by
sort_orderrJ   c                  K   ||d}|r||d<   |r||d<   |r||d<   |r||d<   | j                   j                  d||       d{   S 7 w)	a  Search for assistants.

        Args:
            metadata: Metadata to filter by. Exact match filter for each KV pair.
            graph_id: The ID of the graph to filter by.
                The graph ID is normally set in your langgraph.json configuration.
            limit: The maximum number of results to return.
            offset: The number of results to skip.
            sort_by: The field to sort by.
            sort_order: The order to sort by.
            headers: Optional custom headers to include with the request.

        Returns:
            list[Assistant]: A list of assistants.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            assistants = await client.assistants.search(
                metadata = {"name":"my_name"},
                graph_id="my_graph_id",
                limit=5,
                offset=5
            )
            ```
        r.  r/  r  r  r0  r1  /assistants/searchr   Nr!  )	r   r  r  r.  r/  r0  r1  rJ   r#  s	            r@   searchzAssistantsClient.search&  sy     N #
 "*GJ"*GJ!(GI$.GL!YY^^  $ 
 
 	
 
s   AAA
Ac               z   K   ||d}|r||d<   | j                   j                  d| d||       d{   S 7 w)a  List all versions of an assistant.

        Args:
            assistant_id: The assistant ID to get versions for.
            metadata: Metadata to filter versions by. Exact match filter for each KV pair.
            limit: The maximum number of versions to return.
            offset: The number of versions to skip.
            headers: Optional custom headers to include with the request.

        Returns:
            list[AssistantVersion]: A list of assistant versions.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            assistant_versions = await client.assistants.get_versions(
                assistant_id="my_assistant_id"
            )
            ```
        r3  r  r  	/versionsr   Nr!  r   r  r  r.  r/  rJ   r#  s          r@   get_versionszAssistantsClient.get_versions^  sY     @ #
 "*GJYY^^<.	2' $ 
 
 	
 
   2;9;c               j   K   d|i}| j                   j                  d| d||       d{   S 7 w)aP  Change the version of an assistant.

        Args:
            assistant_id: The assistant ID to delete.
            version: The version to change to.
            headers: Optional custom headers to include with the request.

        Returns:
            Assistant: Assistant Object.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            new_version_assistant = await client.assistants.set_latest(
                assistant_id="my_assistant_id",
                version=3
            )
            ```

        versionr  /latestr   Nr!  r   r  r<  rJ   r#  s        r@   
set_latestzAssistantsClient.set_latest  sF     : $-g"6YY^^<.0w $ 
 
 	
 
s   *313r   r~   r   r   r  r   rJ   r   r   r   r  r   r  zUnion[int, bool]rJ   r   r   zdict[str, list[dict[str, Any]]]r  r   rJ   r   r   r   NF
r  r   r  Optional[str]r  boolrJ   r   r   r)   r}   r  rF  r  Optional[Config]r  r   r  rF  r  Optional[OnConflictBehavior]r  rF  rJ   r   r  rF  r   r   r  r   r  rF  r  rI  r  r   r  rF  rJ   r   r  rF  r   r   r  r   rJ   r   r   r   )r  r   r  rF  r.  intr/  rM  r0  zOptional[AssistantSortBy]r1  Optional[SortOrder]rJ   r   r   list[Assistant]Nr-  r   r  r   r  r   r.  rM  r/  rM  rJ   r   r   zlist[AssistantVersion]r  r   r<  rM  rJ   r   r   r   r   r   r   r   r   ro   r  r  r  r$  r   r   r5  r9  r?  r   rB   r@   r   r     s    IM$S$S-E$S	$ST "',02
2
 	2

 *2
 
)2
j IMr
r
-Er
	r
n $(	 -1 ! 	 * 
H $(<R
 &*26",0%)<R<R !<R
 <R $<R 0<R <R *<R #<R 
<RD #'#'",0%)9
9
  	9

 !9
 9
 9
 *9
 #9
 
9
~ -1	OO *	O
 
O< "&-1*.,06
 6
  	6

 6
 6
 +6
 (6
 *6
 
6
v '
 -1'
'
 '
 	'

 '
 *'
 
 '
\ -1!
!
 !

 *!
 
!
rB   r   c            	      v   e Zd ZdZddZdd	 	 	 	 	 ddZddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 ddZdd	 	 	 	 	 dd	Zdddd
ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	dd	 	 	 	 	 ddZ
	 	 dddd	 	 	 	 	 	 	 	 	 	 	 ddZddddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZd
ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy) r   a  Client for managing threads in LangGraph.

    A thread maintains the state of a graph across multiple interactions/invocations (aka runs).
    It accumulates and persists the graph's state, allowing for continuity between separate
    invocations of the graph.

    ???+ example "Example"

        ```python
        client = get_client(url="http://localhost:2024"))
        new_thread = await client.threads.create(metadata={"user_id": "123"})
        ```
    c                    || _         y r}   r   r   s     r@   r   zThreadsClient.__init__  r   rB   Nr   c               ^   K   | j                   j                  d| |       d{   S 7 w)aQ  Get a thread by ID.

        Args:
            thread_id: The ID of the thread to get.
            headers: Optional custom headers to include with the request.

        Returns:
            Thread: Thread object.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            thread = await client.threads.get(
                thread_id="my_thread_id"
            )
            print(thread)
            ```

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

            {
                'thread_id': 'my_thread_id',
                'created_at': '2024-07-18T18:35:15.540834+00:00',
                'updated_at': '2024-07-18T18:35:15.540834+00:00',
                'metadata': {'graph_id': 'agent'}
            }
            ```

        	/threads/r   Nr  r   	thread_idrJ   s      r@   ro   zThreadsClient.get  s-     F YY]]Yyk#:G]LLLLr  r  rY  r  
superstepsr  rJ   c               D  K   i }|r||d<   |s|ri |xs i |rd|ini |d<   |r||d<   |rA|D 	cg c]0  }d|d   D 	cg c]  }	|	d   |	j                  d      |	d   d	 c}	i2 c}	}|d
<   | j                  j                  d||       d{   S c c}	w c c}	}w 7 w)ax  Create a new thread.

        Args:
            metadata: Metadata to add to thread.
            thread_id: ID of thread.
                If None, ID will be a randomly generated UUID.
            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 thread).
            supersteps: Apply a list of supersteps when creating a thread, each containing a sequence of updates.
                Each update has `values` or `command` and `as_node`. Used for copying a thread between deployments.
            graph_id: Optional graph ID to associate with the thread.
            headers: Optional custom headers to include with the request.

        Returns:
            Thread: The created thread.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            thread = await client.threads.create(
                metadata={"number":1},
                thread_id="my-thread-id",
                if_exists="raise"
            )
            ```
        rY  r  r  r  updatesvaluescommandas_noder^  r_  r`  r[  /threadsr   Nro   r   r   
r   r  rY  r  r[  r  rJ   r#  sus
             r@   r$  zThreadsClient.create  s     J #%#,GK x#>r#-5J)2#GJ #,GK  $%   "#9  	 '(k'(uuY'7'(| 	%GL! YY^^JWg^NNN % Os3   /B B"B B&(B BB BB c               d   K   | j                   j                  d| d|i|       d{   S 7 w)a=  Update a thread.

        Args:
            thread_id: ID of thread to update.
            metadata: Metadata to merge with existing thread metadata.
            headers: Optional custom headers to include with the request.

        Returns:
            Thread: The created thread.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            thread = await client.threads.update(
                thread_id="my-thread-id",
                metadata={"number":1},
            )
            ```
        rW  r  r   Nr'  r   rY  r  rJ   s       r@   r   zThreadsClient.update"  s?     6 YY__	{#:x*@' % 
 
 	
 
   '0.0c               `   K   | j                   j                  d| |       d{    y7 w)a  Delete a thread.

        Args:
            thread_id: The ID of the thread to delete.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost2024)
            await client.threads.delete(
                thread_id="my_thread_id"
            )
            ```

        rW  r   Nr+  rX  s      r@   r   zThreadsClient.deleteA  s,     , ii9+6HHHr,  r-  r   )r  r^  statusr.  r/  r0  r1  rJ   c                  K   ||d}	|r||	d<   |r||	d<   |r||	d<   |r||	d<   |r||	d<   | j                   j                  d|	|       d	{   S 7 w)
a  Search for threads.

        Args:
            metadata: Thread metadata to filter on.
            values: State values to filter on.
            status: Thread status to filter on.
                Must be one of 'idle', 'busy', 'interrupted' or 'error'.
            limit: Limit on number of threads to return.
            offset: Offset in threads table to start search from.
            sort_by: Sort by field.
            sort_order: Sort order.
            headers: Optional custom headers to include with the request.

        Returns:
            list[Thread]: List of the threads matching the search parameters.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            threads = await client.threads.search(
                metadata={"number":1},
                status="interrupted",
                limit=15,
                offset=5
            )
            ```

        r3  r  r^  rk  r0  r1  /threads/searchr   Nr!  )
r   r  r^  rk  r.  r/  r0  r1  rJ   r#  s
             r@   r5  zThreadsClient.searchY  s     T #
 "*GJ &GH &GH!(GI$.GL!YY^^ $ 
 
 	
 
r)  c               b   K   | j                   j                  d| dd|       d{   S 7 w)a  Copy a thread.

        Args:
            thread_id: The ID of the thread to copy.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024)
            await client.threads.copy(
                thread_id="my_thread_id"
            )
            ```

        rW  /copyNr   r!  rX  s      r@   copyzThreadsClient.copy  s<     , YY^^	{%(tW $ 
 
 	
 
s   &/-/F	subgraphsrJ   c               ,  K   |r-| j                   j                  d| d||d|       d{   S |r.| j                   j                  d| d| d|i|       d{   S | j                   j                  d| d	d|i|       d{   S 7 `7 27 w)
a  Get the state of a thread.

        Args:
            thread_id: The ID of the thread to get the state of.
            checkpoint: The checkpoint to get the state of.
            checkpoint_id: (deprecated) The checkpoint ID to get the state of.
            subgraphs: Include subgraphs states.
            headers: Optional custom headers to include with the request.

        Returns:
            ThreadState: the thread of the state.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024)
            thread_state = await client.threads.get_state(
                thread_id="my_thread_id",
                checkpoint_id="my_checkpoint_id"
            )
            print(thread_state)
            ```

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

            {
                'values': {
                    '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
                        }
                    ]
                },
                'next': [],
                'checkpoint':
                    {
                        'thread_id': 'e2496803-ecd5-4e0c-a779-3226296181c2',
                        'checkpoint_ns': '',
                        'checkpoint_id': '1ef4a9b8-e6fb-67b1-8001-abd5184439d1'
                    }
                'metadata':
                    {
                        'step': 1,
                        'run_id': '1ef4a9b8-d7da-679a-a45a-872054341df2',
                        'source': 'loop',
                        'writes':
                            {
                                'agent':
                                    {
                                        'messages': [
                                            {
                                                'id': 'run-159b782c-b679-4830-83c6-cef87798fe8b',
                                                'name': None,
                                                'type': 'ai',
                                                'content': "I'm doing well, thanks for asking! I'm an AI assistant created by Anthropic to be helpful, honest, and harmless.",
                                                'example': False,
                                                'tool_calls': [],
                                                'usage_metadata': None,
                                                'additional_kwargs': {},
                                                'response_metadata': {},
                                                'invalid_tool_calls': []
                                            }
                                        ]
                                    }
                            },
                'user_id': None,
                'graph_id': 'agent',
                'thread_id': 'e2496803-ecd5-4e0c-a779-3226296181c2',
                'created_by': 'system',
                'assistant_id': 'fe096781-5601-53d2-b2f6-0d3403f7e9ca'},
                'created_at': '2024-07-25T15:35:44.184703+00:00',
                'parent_config':
                    {
                        'thread_id': 'e2496803-ecd5-4e0c-a779-3226296181c2',
                        'checkpoint_ns': '',
                        'checkpoint_id': '1ef4a9b8-d80d-6fa7-8000-9300467fad0f'
                    }
            }
            ```
        rW  /state/checkpoint
checkpointrr  r   N/state/rr  r   /stater   r   ro   r   rY  rv  checkpoint_idrr  rJ   s         r@   	get_statezThreadsClient.get_state  s     X I;&78$.YG (   
 I;gm_=#Y/ '    I;f-#Y/ '   s3   +BB/BB+B	B
BBBr`  rv  r{  rJ   c                  K   d|i}|r||d<   |r||d<   |r||d<   | j                   j                  d| d||       d{   S 7 w)	a  Update the state of a thread.

        Args:
            thread_id: The ID of the thread to update.
            values: The values to update the state with.
            as_node: Update the state as if this node had just executed.
            checkpoint: The checkpoint to update the state of.
            checkpoint_id: (deprecated) The checkpoint ID to update the state of.
            headers: Optional custom headers to include with the request.

        Returns:
            ThreadUpdateStateResponse: Response after updating a thread's state.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024)
            response = await client.threads.update_state(
                thread_id="my_thread_id",
                values={"messages":[{"role": "user", "content": "hello!"}]},
                as_node="my_node",
            )
            print(response)
            ```
            ```shell

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

            {
                'checkpoint': {
                    'thread_id': 'e2496803-ecd5-4e0c-a779-3226296181c2',
                    'checkpoint_ns': '',
                    'checkpoint_id': '1ef4a9b8-e6fb-67b1-8001-abd5184439d1',
                    'checkpoint_map': {}
                }
            }
            ```
        r^  r{  rv  r`  rW  rx  r   Nr!  r   rY  r^  r`  rv  r{  rJ   r#  s           r@   update_statezThreadsClient.update_state/  sr     b f#
 '4GO$$.GL!!(GIYY^^	{&) $ 
 
 	
 
   ?AAAr.  beforer  rv  rJ   c                  K   d|i}|r||d<   |r||d<   |r||d<   | j                   j                  d| d||       d{   S 7 w)	aB  Get the state history of a thread.

        Args:
            thread_id: The ID of the thread to get the state history for.
            checkpoint: Return states for this subgraph. If empty defaults to root.
            limit: The maximum number of states to return.
            before: Return states before this checkpoint.
            metadata: Filter states by metadata key-value pairs.
            headers: Optional custom headers to include with the request.

        Returns:
            list[ThreadState]: the state history of the thread.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024)
            thread_state = await client.threads.get_history(
                thread_id="my_thread_id",
                limit=5,
            )
            ```

        r.  r  r  rv  rW  /historyr   Nr!  r   rY  r.  r  r  rv  rJ   r#  s           r@   get_historyzThreadsClient.get_historyl  sr     F U#
  &GH"*GJ$.GL!YY^^	{(+'7 $ 
 
 	
 
r  r@  rY  r   rJ   r   r   r*   r  r   rY  rF  r  rJ  r[  z7Optional[Sequence[dict[str, Sequence[dict[str, Any]]]]]r  rF  rJ   r   r   r*   rY  r   r  dict[str, Any]rJ   r   r   r*   rY  r   rJ   r   r   r   )r  r   r^  r   rk  Optional[ThreadStatus]r.  rM  r/  rM  r0  zOptional[ThreadSortBy]r1  rN  rJ   r   r   list[Thread]NNrY  r   rv  Optional[Checkpoint]r{  rF  rr  rG  rJ   r   r   r,   rY  r   r^  z%Optional[Union[dict, Sequence[dict]]]r`  rF  rv  r  r{  rF  rJ   r   r   r.   rY  r   r.  rM  r  zOptional[str | Checkpoint]r  r   rv  r  rJ   r   r   zlist[ThreadState]r   r   r   r   r   ro   r$  r   r   r5  rp  r|  r  r  r   rB   r@   r   r     s    FJ#M#M*B#M	#MP #'26NR"&,0>O >O !	>O
 0>O L>O  >O *>O 
>OJ -1

 !	

 *
 

@ FJII*BI	I6 )-*.*.,0;
 ;
 	;

 ';
 ;
 ;
 (;
 (;
 *;
 
;
| FJ

*B
	
: ,0'+	}  ,0}} )} %	} } *} 
}H "&+/'+,0;
;
 6;

 ;
 );
 %;
 *;
 
#;
B -1#'+/,0-
-
 	-

 +-
 !-
 )-
 *-
 
-
rB   r   c                  b   e Zd ZdZd'dZeddddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(d       Zeddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)d	       Zdddddddddddddddddddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d*dZeddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d+d       Zeddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d,d       Zdddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d-dZd.dZeddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d/d       Z	eddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d0d       Z	dddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d1dZ	ddddd	 	 	 	 	 	 	 	 	 	 	 d2dZ
dd	 	 	 	 	 	 	 d3dZdd dd!	 	 	 	 	 	 	 	 	 	 	 d4d"Zdd	 	 	 	 	 	 	 d5d#Zdddd$	 	 	 	 	 	 	 	 	 	 	 d6d%Zdd	 	 	 	 	 	 	 d7d&Zy)8r   a  Client for managing runs in LangGraph.

    A run is a single assistant invocation with optional input, config, 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                    || _         y r}   r   r   s     r@   r   zRunsClient.__init__  r   rB   Nr^  Finputr_  stream_modestream_subgraphsr  r  rv  r{  checkpoint_duringinterrupt_beforeinterrupt_afterfeedback_keyson_disconnectwebhookmultitask_strategyif_not_existsafter_secondsrJ   c                    y r}   r   r   rY  r  r  r_  r  r  r  r  rv  r{  r  r  r  r  r  r  r  r  r  rJ   s                        r@   r   zRunsClient.stream  s    0 %(rB   r  r_  r  r  r  r  r  r  r  r  r  on_completionr  r  r  rJ   c                    y r}   r   r   rY  r  r  r_  r  r  r  r  r  r  r  r  r  r  r  r  r  rJ   s                      r@   r   zRunsClient.stream  s    , %(rB   r  r_  r  r  r  r  rv  r{  r  r  r  r  r  r  r  r  r  r  rJ   c          
     |   i d|d|r'|j                         D ci c]  \  }}|	|| c}}ndd|d|d|d|d|d	|d
|d|d|d|	d|
d|d|d|d|||d}|d| dnd}| j                  j                  |d|j                         D ci c]  \  }}|	|| c}}|      S c c}}w c c}}w )aB  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.
            metadata: Metadata to assign to the run.
            config: The configuration for the assistant.
            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.
            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.

        Returns:
            AsyncIterator[StreamPart]: 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"},
                config={"configurable": {"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)
            ```

        r  r_  Nr  r  r  r  r  r  r  r  r  rv  r{  r  r  r  r  r  r  rW  /runs/streamPOSTr   itemsr   r   r   rY  r  r  r_  r  r  r  r  rv  r{  r  r  r  r  r  r  r  r  r  r  rJ   kvr#  endpoints                             r@   r   zRunsClient.stream  sw   r
U
GN'--/C$!QQ]ACTX

 f
 
 ;
  0
 L
  0
 
 ]
 w
 *
 ]
   !2!
" !"4#
$ ]%
& ]'
( +*+
2 $ 	{,/ 	
 yy#*==?D41aam!Q$D	   
 	
3 D8 E   
B2
B2

B8#B8)r  r_  r  r  r  r  r  r  r  r  r  r  r  rJ   c                  K   y wr}   r   )r   rY  r  r  r_  r  r  r  r  r  r  r  r  r  r  r  rJ   s                    r@   r$  zRunsClient.create[  s     (    r  r_  r  r  r  r  rv  r{  r  r  r  r  r  r  r  rJ   c                  K   y wr}   r   r   rY  r  r  r_  r  r  r  r  rv  r{  r  r  r  r  r  r  r  rJ   s                      r@   r$  zRunsClient.createq  s     , r  )r  r_  r  r  r  r  rv  r{  r  r  r  r  r  r  r  r  rJ   c                 K   i d|d|r'|j                         D ci c]  \  }}|	|| c}}ndd|d|d|d|d|d	|d
|d|d|	d|
d|d|d|d|d|}|j                         D ci c]  \  }}|	|| }}}|r)| j                  j                  d| d|       d{   S | j                  j                  d|       d{   S c c}}w c c}}w 7 57 w)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.
            metadata: Metadata to assign to the run.
            config: The configuration for the assistant.
            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.
            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.

        Returns:
            Run: 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"},
                config={"configurable": {"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,
                                        'model_name': "openai",
                                        'assistant_id': 'my_assistant_id'
                                    }
                            },
                        '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'
            }
            ```
        r  r_  Nr  r  r  r  r  r  r  r  rv  r{  r  r  r  r  r  rW  /runsr   r  r   r   )r   rY  r  r  r_  r  r  r  r  rv  r{  r  r  r  r  r  r  r  r  rJ   r  r  r#  s                          r@   r$  zRunsClient.create  sw    t
U
GN'--/C$!QQ]ACTX

 ;
  0
 f
 
 L
  0
 
 w
 *
 ]
  !2
  !"4!
" ]#
$ ]%
& ]'
* %,MMOEDAqq}1a4EE)I;e(D7SSSg>>>- D$ FS>sE   C'
C
C
AC'4
C?C)C'-C#.$C'C%C'%C'c                   K   dd}|D cg c]
  } ||       }}| j                   j                  d|       d{   S c c}w 7 	w),Create a batch of stateless background runs.c                \    | j                         D ci c]  \  }}|	|| c}}S c c}}w r}   r  r#  r  r  s      r@   filter_payloadz/RunsClient.create_batch.<locals>.filter_payload!  (    %,]]_FTQAqDFFF   
((/runs/batchr  Nr#  r#   r!  )r   payloadsr  r#  s       r@   create_batchzRunsClient.create_batch  sJ     	G <DDN7+DDYY^^M^AAA EAs   	AA"AA
AT)r  r_  r  r  rv  r{  r  r  r  r  r  r  r  r  raise_errorrJ   c                  K   y wr}   r   )r   rY  r  r  r_  r  r  rv  r{  r  r  r  r  r  r  r  r  r  rJ   s                      r@   waitzRunsClient.wait'  s     , -0r  )r  r_  r  r  r  r  r  r  r  r  r  r  r  rJ   c                  K   y wr}   r   )r   rY  r  r  r_  r  r  r  r  r  r  r  r  r  r  r  rJ   s                    r@   r  zRunsClient.wait?  s     ( -0r  )r  r_  r  r  rv  r{  r  r  r  r  r  r  r  r  r  r  rJ   c          	     D  K   i d|d|r'|j                         D ci c]  \  }}|	|| c}}ndd|d|d|d|
d|d	|d
|d|d|d|	d|d|d|d|}|d| dnd}| j                  j                  ||j                         D ci c]  \  }}|	|| c}}|       d{   }|r[t        |t              rKd|v rGt        |d   t              r4t        |d   j                  d       d|d   j                  d             |S c c}}w c c}}w 7 ow)aI  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.
            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.
            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.

        Returns:
            Union[list[dict], dict[str, Any]]: 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"},
                config={"configurable": {"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
                    }
                ]
            }
            ```

        r  r_  Nr  r  r  r  r  r  rv  r{  r  r  r  r  r  r  rW  
/runs/waitr   	__error__r   z: message)r  r   r   rQ   rN   rt   ro   )r   rY  r  r  r_  r  r  rv  r{  r  r  r  r  r  r  r  r  r  r  rJ   r  r  r#  r  responses                            r@   r  zRunsClient.waitU  s    N
U
GN'--/C$!QQ]ACTX

 f
 
 L
  0
 
 w
 *
 ]
 !"4
  !2
 ]
  ]!
" ]#
$ ]%
* 2;1Fi	{*-L 	 #*==?D41aam!Q$D ( 
 
 8T*x'8K0$7K(,,W56b+9N9R9RS\9]8^_  E D, E
s4   D 
D
D
A$D 
DD!D .D/A0D r-  r   )r.  r/  rk  rJ   c               z   K   ||d}|||d<   | j                   j                  d| d||       d{   S 7 w)a  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.

        Returns:
            List[Run]: 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,
            )
            ```

        r3  Nrk  rW  r  r   r  )r   rY  r.  r/  rk  rJ   r   s          r@   rT   zRunsClient.list  s\     D 
 %F8YY]]	{%( # 
 
 	
 
r:  r   c               d   K   | j                   j                  d| d| |       d{   S 7 w)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.

        Returns:
            Run: 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",
            )
            ```

        rW  /runs/r   Nr  r   rY  run_idrJ   s       r@   ro   zRunsClient.get  s>     2 YY]]	{&17 # 
 
 	
 
ri  	interruptr  actionrJ   c          
     z   K   | j                   j                  d| d| d|rdnd d| d|       d{   S 7 w)	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.

        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"
            )
            ```

        rW  r  /cancel?wait=   r   &action=Nr   r!  r   rY  r  r  r  rJ   s         r@   cancelzRunsClient.cancel+  sV     F YY^^	{&4aQ=OxX^W_` $ 
 
 	
 
r:  c               f   K   | j                   j                  d| d| d|       d{   S 7 w)a8  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.

        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"
            )
            ```

        rW  r  /joinr   Nr  r  s       r@   joinzRunsClient.joinT  s@     0 YY]]	{&6 # 
 
 	
 
r  )cancel_on_disconnectr  rJ   c               T    | j                   j                  d| d| dd||d|      S )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.

        Returns:
            None

        ???+ 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)
            ```

        rW  r  /streamGET)r  r  r   r   r   )r   rY  r  r  r  rJ   s         r@   join_streamzRunsClient.join_streamp  sF    L yy	{&8(<*    
 	
rB   c               f   K   | j                   j                  d| d| |       d{    y7 w)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.

        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"
            )
            ```

        rW  r  r   Nr+  r  s       r@   r   zRunsClient.delete  s2     0 ii9+VF8DgVVVs   '1/1r@  )*rY  r   r  r   r  r   r_  Optional[Command]r  'Union[StreamMode, Sequence[StreamMode]]r  rG  r  r   r  rI  rv  r  r{  rF  r  Optional[bool]r  #Optional[Union[All, Sequence[str]]]r  r  r  Optional[Sequence[str]]r  Optional[DisconnectMode]r  rF  r  Optional[MultitaskStrategy]r  Optional[IfNotExists]r  Optional[int]rJ   r   r   r   )&rY  r   r  r   r  r   r_  r  r  r  r  rG  r  r   r  rI  r  r  r  r  r  r  r  r  r  r  r  Optional[OnCompletionBehavior]r  r  r  rF  r  r  rJ   r   r   r   ),rY  rF  r  r   r  r   r_  r  r  r  r  rG  r  r   r  rI  rv  r  r{  rF  r  r  r  r  r  r  r  r  r  r  r  r  r  rF  r  r  r  r  r  r  rJ   r   r   r   )"rY  r   r  r   r  r   r_  r  r  r  r  rG  r  r   r  r  r  rI  r  r  r  r  r  rF  r  r  r  r  r  r  rJ   r   r   r"   &rY  r   r  r   r  r   r_  r  r  r  r  rG  r  r   r  rI  rv  r  r{  rF  r  r  r  r  r  r  r  rF  r  r  r  r  r  r  rJ   r   r   r"   )(rY  rF  r  r   r  r   r_  r  r  r  r  rG  r  r   r  rI  rv  r  r{  rF  r  r  r  r  r  r  r  rF  r  r  r  r  r  r  r  r  rJ   r   r   r"   )r  list[RunCreate]r   	list[Run])&rY  r   r  r   r  r   r_  r  r  r   r  rI  rv  r  r{  rF  r  r  r  r  r  r  r  rF  r  r  r  r  r  r  r  r  r  rG  rJ   r   r   !Union[list[dict], dict[str, Any]])"rY  r   r  r   r  r   r_  r  r  r   r  rI  r  r  r  r  r  r  r  rF  r  r  r  r  r  r  r  r  r  rG  rJ   r   r   r  )(rY  rF  r  r   r  r   r_  r  r  r   r  rI  rv  r  r{  rF  r  r  r  r  r  r  r  rF  r  r  r  r  r  r  r  r  r  r  r  rG  rJ   r   r   r  )rY  r   r.  rM  r/  rM  rk  zOptional[RunStatus]rJ   r   r   	List[Run]rY  r   r  r   rJ   r   r   r"   rY  r   r  r   r  rG  r  r   rJ   r   r   r   rY  r   r  r   rJ   r   r   rN   )rY  r   r  r   r  rG  r  1Optional[Union[StreamMode, Sequence[StreamMode]]]rJ   r   r   r   rY  r   r  r   rJ   r   r   r   r   r   r   r   r   r   r   r$  r  r  rT   ro   r  r  r  r   r   rB   r@   r   r     s
     !%%)?G!&#'#'+/'+,0@D?C1526!%:>/3'+,0-(( (
 ( #( =( ( !( !( )( %( *( >( =(  /!(" 0#($ %(& 8'(( -)(* %+(, *-(. 
#/( (2  !%%)?G!&#'#',0@D?C15268</3!%'+,0)(( (
 ( #( =( ( !( !( *( >( =( /( 0(  6!(" -#($ %(& %'(( *)(* 
#+( (8 !%%)?G!&#'#'+/'+,0@D?C15268<!%:>/3'+,0/z
 z
 z

 z
 #z
 =z
 z
 !z
 !z
 )z
 %z
 *z
 >z
 =z
  /!z
" 0#z
$ 6%z
& 'z
( 8)z
* -+z
, %-z
. */z
0 
#1z
x  !%%)?G!&#',0#'@D?C!%8</3'+,0% 
  # =  ! * ! > =  6  -!" %#$ *%& 
' *  !%%)?G!&#'#'+/'+,0@D?C!%:>/3'+,0) 
  # =  ! ! ) % * > =  !" 8#$ -%& %'( *)* 
+ 8 !%%)?G!&#'#'+/'+,0@D?C!%:>/38<'+,0+S? S? S?
 S? #S? =S? S? !S? !S? )S? %S? *S? >S? =S?  !S?" 8#S?$ -%S?& 6'S?( %)S?* *+S?, 
-S?jB  !%%)#'#'+/'+,0@D?C!%26:>/3'+ ,0)00 0
 0 #0 !0 !0 )0 %0 *0 >0 =0 0 00  8!0" -#0$ %%0& '0( *)0* 
++0 0.  !%%)#'#',0@D?C!%268</3'+ ,0%00 0
 0 #0 !0 !0 *0 >0 =0 0 00 60 -0  %!0" #0$ *%0& 
+'0 04 !%%)#'#'+/'+,0@D?C!%268<:>/3'+ ,0+L L L
 L #L !L !L )L %L *L >L =L L 0L  6!L" 8#L$ -%L& %'L( )L* *+L, 
+-Ld &*,0)
)
 	)

 )
 $)
 *)
 
)
X SW

&)
7O
	
D *,0'
'
 '

 '
 '
 *'
 
'
T SW

&)
7O
	
B &+IM,0.
.
 .

 #.
 G.
 *.
 
#.
b SWWW&)W7OW	WrB   r   c            
          e Zd ZdZddZdddddddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdddddddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 ddZdddd	dd
	 	 	 	 	 	 	 	 	 	 	 ddZy)r   a  Client for managing recurrent runs (cron jobs) in LangGraph.

    A run is a single invocation of an assistant with optional input and config.
    This client allows scheduling recurring runs to occur automatically.

    ???+ example "Example Usage"

        ```python
        client = get_client(url="http://localhost:2024"))
        cron_job = await client.crons.create_for_thread(
            thread_id="thread_123",
            assistant_id="asst_456",
            schedule="0 9 * * *",
            input={"message": "Daily update"}
        )
        ```

    !!! note "Feature Availability"
        The crons client functionality is not supported on all licenses.
        Please check the relevant license documentation for the most up-to-date
        details on feature availability.
    c                    || _         y r}   r   r   http_clients     r@   r   zCronClient.__init__  	    	rB   N	r  r  r  r  r  r  r  r  rJ   c       
   
        K   ||||||||	|
d	}|r||d<   |j                         D ci c]  \  }}|	|| }}}| j                  j                  d| d||       d{   S c c}}w 7 
w)a  Create a cron job for a thread.

        Args:
            thread_id: the thread ID to run the cron job on.
            assistant_id: The assistant ID or graph name to use for the cron job.
                If using graph name, will default to first assistant created from that graph.
            schedule: The cron schedule to execute this job on.
            input: The input to the graph.
            metadata: Metadata to assign to the cron job runs.
            config: The configuration for the assistant.
            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.

            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'.
            headers: Optional custom headers to include with the request.

        Returns:
            Run: The cron run.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            cron_run = await client.crons.create_for_thread(
                thread_id="my-thread-id",
                assistant_id="agent",
                schedule="27 15 * * *",
                input={"messages": [{"role": "user", "content": "hello!"}]},
                metadata={"name":"my_run"},
                config={"configurable": {"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"
            )
            ```
        	scheduler  r  r  r  r  r  r  r  r  NrW  /runs/cronsr   r  )r   rY  r  r	  r  r  r  r  r  r  r  r  rJ   r#  r  r  s                   r@   create_for_threadzCronClient.create_for_thread  s     t ! (!2 0.

 ,>G()$+MMOEDAqq}1a4EEYY^^	{+.Wg $ 
 
 	
 F
s    'A.
A&A&(A.!A,"A.c       
   
        K   |||||||||	d	}|
r|
|d<   |j                         D ci c]  \  }}|	|| }}}| j                  j                  d||       d{   S c c}}w 7 
w)a   Create a cron run.

        Args:
            assistant_id: The assistant ID or graph name to use for the cron job.
                If using graph name, will default to first assistant created from that graph.
            schedule: The cron schedule to execute this job on.
            input: The input to the graph.
            metadata: Metadata to assign to the cron job runs.
            config: The configuration for the assistant.
            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.
            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'.
            headers: Optional custom headers to include with the request.

        Returns:
            Run: The cron run.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            cron_run = client.crons.create(
                assistant_id="agent",
                schedule="27 15 * * *",
                input={"messages": [{"role": "user", "content": "hello!"}]},
                metadata={"name":"my_run"},
                config={"configurable": {"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"
            )
            ```

        r  r  Nr
  r   r  r   r  r	  r  r  r  r  r  r  r  r  rJ   r#  r  r  s                  r@   r$  zCronClient.create!	  s     l ! (!2 0.

 ,>G()$+MMOEDAqq}1a4EEYY^^M^QQQ FQs    'A*
A"A"$A*A(A*c                `   K   | j                   j                  d| |       d{    y7 w)a  Delete a cron.

        Args:
            cron_id: The cron ID to delete.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            await client.crons.delete(
                cron_id="cron_to_delete"
            )
            ```

        /runs/crons/r   Nr+  r   cron_idrJ   s      r@   r   zCronClient.deletef	  s,     0 iigY7IIIr,  r-  r   r  rY  r.  r/  rJ   c                  K   ||||d}|j                         D ci c]  \  }}|	|| }}}| j                  j                  d||       d{   S c c}}w 7 
w)a  Get a list of cron jobs.

        Args:
            assistant_id: The assistant ID or graph name to search for.
            thread_id: the thread ID to search for.
            limit: The maximum number of results to return.
            offset: The number of results to skip.
            headers: Optional custom headers to include with the request.

        Returns:
            list[Cron]: The list of cron jobs returned by the search,

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            cron_jobs = await client.crons.search(
                assistant_id="my_assistant_id",
                thread_id="my_thread_id",
                limit=5,
                offset=5,
            )
            print(cron_jobs)
            ```
            ```shell

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

            [
                {
                    'cron_id': '1ef3cefa-4c09-6926-96d0-3dc97fd5e39b',
                    'assistant_id': 'my_assistant_id',
                    'thread_id': 'my_thread_id',
                    'user_id': None,
                    'payload':
                        {
                            'input': {'start_time': ''},
                            'schedule': '4 * * * *',
                            'assistant_id': 'my_assistant_id'
                        },
                    'schedule': '4 * * * *',
                    'next_run_date': '2024-07-25T17:04:00+00:00',
                    'end_time': None,
                    'created_at': '2024-07-08T06:02:23.073257+00:00',
                    'updated_at': '2024-07-08T06:02:23.073257+00:00'
                }
            ]
            ```

        r  rY  r.  r/  N/runs/crons/searchr   r  	r   r  rY  r.  r/  rJ   r#  r  r  s	            r@   r5  zCronClient.search	  sj     x )"	
 %,MMOEDAqq}1a4EEYY^^$8wPW^XXX FXs    A
AA$AAA)r  r~   r   r   )rY  r   r  r   r	  r   r  r   r  r   r  rI  r  r  r  Optional[Union[All, list[str]]]r  r  r  rF  r  rF  rJ   r   r   r"   r  r   r	  r   r  r   r  r   r  rI  r  r  r  r  r  r  r  rF  r  rF  rJ   r   r   r"   r}   r  r   rJ   r   r   r   r  rF  rY  rF  r.  rM  r/  rM  rJ   r   r   z
list[Cron]	r   r   r   r   r   r  r$  r   r5  r   rB   r@   r   r     s   .  !%#'#',0<@;?!%,0,0I
I
 I

 I
 I
 !I
 !I
 *I
 :I
 9I
 I
 *I
 *I
 
I
` !%#'#',0<@;?!%,0,0CRCR 	CR
 CR !CR !CR *CR :CR 9CR CR *CR *CR 
CRP -1JJ *J 
	J: '+#',0BY $BY !	BY
 BY BY *BY 
BYrB   r   c                      e Zd ZdZd
dZ	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddd	 	 	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Z	y)r   a  Client for interacting with the graph's shared storage.

    The Store provides a key-value storage system for persisting data across graph executions,
    allowing for stateful operations and data sharing across threads.

    ???+ example "Example"

        ```python
        client = get_client(url="http://localhost:2024")
        await client.store.put_item(["users", "user123"], "mem-123451342", {"name": "Alice", "score": 100})
        ```
    c                    || _         y r}   r   r   s     r@   r   zStoreClient.__init__	  r   rB   Nc                  K   |D ]  }d|v st        d| d       |||||d}| j                  j                  dt        |      |       d{    y7 w)a  Store or update an item.

        Args:
            namespace: A list of strings representing the namespace path.
            key: The unique identifier for the item within the namespace.
            value: A dictionary containing the item's data.
            index: Controls search indexing - None (use defaults), False (disable), or list of field paths to index.
            ttl: Optional time-to-live in minutes for the item, or None for no expiration.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            await client.store.put_item(
                ["documents", "user123"],
                key="item456",
                value={"title": "My Document", "content": "Hello World"}
            )
            ```
        .Invalid namespace label '1'. Namespace labels cannot contain periods ('.').r  keyvalueindexttl/store/itemsr   NrE   r   r   _provided_vals	r   r  r#  r$  r%  r&  rJ   labelr#  s	            r@   put_itemzStoreClient.put_item	  s~     D  	Ee| /w6gh 	 #
 iimm!8'  
 	
 	
s   
AAAAArefresh_ttlrJ   c                 K   |D ]  }d|v st        d| d       dj                  |      |d}|||d<   | j                  j                  d||       d{   S 7 w)	ay  Retrieve a single item.

        Args:
            key: The unique identifier for the item.
            namespace: Optional list of strings representing the namespace path.
            refresh_ttl: Whether to refresh the TTL on this read operation. If None, uses the store's default behavior.

        Returns:
            Item: The retrieved item.
            headers: Optional custom headers to include with the request.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            item = await client.store.get_item(
                ["documents", "user123"],
                key="item456",
            )
            print(item)
            ```
            ```shell

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

            {
                'namespace': ['documents', 'user123'],
                'key': 'item456',
                'value': {'title': 'My Document', 'content': 'Hello World'},
                'created_at': '2024-07-30T12:00:00Z',
                'updated_at': '2024-07-30T12:00:00Z'
            }
            ```
        r  r   r!  r  r#  Nr.  r'  r   rE   r  r   ro   r   r  r#  r.  rJ   r+  r   s          r@   get_itemzStoreClient.get_item
  s}     V  	Ee| /w6gh 	
  #xx	23?"$/F=!YY]]>&']RRRRs   
A AA AA c               b   K   | j                   j                  d||d|       d{    y7 w)a'  Delete an item.

        Args:
            key: The unique identifier for the item.
            namespace: Optional list of strings representing the namespace path.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            await client.store.delete_item(
                ["documents", "user123"],
                key="item456",
            )
            ```
        r'  r0  r   Nr+  r   r  r#  rJ   s       r@   delete_itemzStoreClient.delete_item=
  s7     6 ii(5  
 	
 	
s   %/-/c               ~   K   ||||||d}| j                   j                  dt        |      |       d{   S 7 w)a  Search for items within a namespace prefix.

        Args:
            namespace_prefix: List of strings representing the namespace prefix.
            filter: Optional dictionary of key-value pairs to filter results.
            limit: Maximum number of items to return (default is 10).
            offset: Number of items to skip before returning results (default is 0).
            query: Optional query for natural language search.
            refresh_ttl: Whether to refresh the TTL on items returned by this search. If None, uses the store's default behavior.
            headers: Optional custom headers to include with the request.

        Returns:
            List[Item]: A list of items matching the search criteria.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            items = await client.store.search_items(
                ["documents"],
                filter={"author": "John Doe"},
                limit=5,
                offset=0
            )
            print(items)
            ```
            ```shell

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

            {
                "items": [
                    {
                        "namespace": ["documents", "user123"],
                        "key": "item789",
                        "value": {
                            "title": "Another Document",
                            "author": "John Doe"
                        },
                        "created_at": "2024-07-30T12:00:00Z",
                        "updated_at": "2024-07-30T12:00:00Z"
                    },
                    # ... additional items ...
                ]
            }
            ```
        namespace_prefixfilterr.  r/  queryr.  /store/items/searchr   Nr   r   r)  	r   r9  r:  r.  r/  r;  r.  rJ   r#  s	            r@   search_itemszStoreClient.search_items^
  sV     v !1&
 YY^^!( $ 
 
 	
 
s   4=;=c                |   K   |||||d}| j                   j                  dt        |      |       d{   S 7 w)a  List namespaces with optional match conditions.

        Args:
            prefix: Optional list of strings representing the prefix to filter namespaces.
            suffix: Optional list of strings representing the suffix to filter namespaces.
            max_depth: Optional integer specifying the maximum depth of namespaces to return.
            limit: Maximum number of namespaces to return (default is 100).
            offset: Number of namespaces to skip before returning results (default is 0).
            headers: Optional custom headers to include with the request.

        Returns:
            List[List[str]]: A list of namespaces matching the criteria.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            namespaces = await client.store.list_namespaces(
                prefix=["documents"],
                max_depth=3,
                limit=10,
                offset=0
            )
            print(namespaces)

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

            [
                ["documents", "user123", "reports"],
                ["documents", "user456", "invoices"],
                ...
            ]
            ```
        r>   suffix	max_depthr.  r/  /store/namespacesr   Nr=  r   r>   rB  rC  r.  r/  rJ   r#  s           r@   list_namespaceszStoreClient.list_namespaces
  sS     X "
 YY^^( $ 
 
 	
 
s   3<:<r@  NNNr#  r   r$  r  r%  z*Optional[Union[Literal[False], list[str]]]r&  r  rJ   r   r  Sequence[str]r   r   
r#  r   r  rI  r.  r  rJ   r   r   r   r}   r#  r   rJ   r   r  rI  r   r   Nr-  r   NNNr:  zOptional[dict[str, Any]]r.  rM  r/  rM  r;  rF  r.  r  rJ   r   r9  rI  r   r%   NNNd   r   Nr>   Optional[List[str]]rB  rQ  rC  r  r.  rM  r/  rM  rJ   r   r   r   
r   r   r   r   r   r,  r3  r6  r?  rF  r   rB   r@   r   r   	  s    =A!,00
 	0

 0
 :0
 0
 *0
 0
 
0
p '+,03S 	3S 3S $3S *3S 
3St -1
 	

 *
 
 

J ,0#&*,0G
 )	G

 G
 G
 G
 $G
 *G
'G
 
G
V '+&*#',06
#6
 $6
 !	6

 6
 6
 *6
 
6
rB   r   SyncLangGraphClientc           
         | d} t        j                  d      }t        j                  | ||t        j                  |      nt        j                  dddd      t	        ||            }t        |      S )a  Get a synchronous LangGraphClient instance.

    Args:
        url: The URL of the LangGraph API.
        api_key: The API key. If not provided, it will be read from the environment.
            Precedence:
                1. explicit argument
                2. LANGGRAPH_API_KEY
                3. LANGSMITH_API_KEY
                4. LANGCHAIN_API_KEY
        headers: Optional custom headers
        timeout: Optional timeout configuration for the HTTP client.
            Accepts an httpx.Timeout instance, a float (seconds), or a tuple of timeouts.
            Tuple format is (connect, read, write, pool)
            If not provided, defaults to connect=5s, read=300s, write=300s, and pool=5s.
    Returns:
        SyncLangGraphClient: The top-level synchronous client for accessing AssistantsClient,
        ThreadsClient, RunsClient, and CronClient.

    ???+ example "Example"

        ```python
        from langgraph_sdk import get_sync_client

        # get top-level synchronous LangGraphClient
        client = get_sync_client(url="http://localhost:8123")

        # example usage: client.<model>.<method_name>()
        assistant = client.assistants.get(assistant_id="some_uuid")
        ```
    ra   rb   rc   re   rf   rk   )ru   HTTPTransportClientrx   rK   rS  )rY   r=   rJ   rZ   rm   ry   s         r@   get_sync_clientrW  
  sr    N {%##A.I\\ " MM'"qs#AFWg.	F v&&rB   c                      e Zd ZdZddZy)rS  a~  Synchronous client for interacting with the LangGraph API.

    This class provides synchronous access to LangGraph API endpoints for managing
    assistants, threads, runs, cron jobs, and data storage.

    ???+ example "Example"

        ```python
        client = get_sync_client(url="http://localhost:2024")
        assistant = client.assistants.get("asst_123")
        ```
    c                (   t        |      | _        t        | j                        | _        t	        | j                        | _        t        | j                        | _        t        | j                        | _	        t        | j                        | _        y r}   )SyncHttpClientr   SyncAssistantsClientr   SyncThreadsClientr   SyncRunsClientr   SyncCronClientr   SyncStoreClientr   r   s     r@   r   zSyncLangGraphClient.__init__&  s^    "6*	.tyy9(3"499-	#DII.
$TYY/
rB   Nry   zhttpx.Clientr   r   r   r   rB   r@   rS  rS    s    0rB   c                      e Zd ZdZddZddd	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 dd	Zddd
	 	 	 	 	 	 	 ddZ	dddd	 	 	 	 	 	 	 	 	 	 	 ddZ
y)rZ  a8  Handle synchronous requests to the LangGraph API.

    Provides error messaging and content handling enhancements above the
    underlying httpx client, mirroring the interface of [HttpClient](#HttpClient)
    but for sync usage.

    Attributes:
        client (httpx.Client): Underlying HTTPX sync client.
    c                    || _         y r}   r   r   s     r@   r   zSyncHttpClient.__init__:  r   rB   Nr   c               l   | j                   j                  |||      }	 |j                          t        |      S # t        j                  $ re}|j                         j                         }t        j                  dk\  r|j                  |       |t        j                  d| |       |d}~ww xY w)r   r   r   r   r   N)ry   ro   r   ru   r   rh   r   r   r   r   r   r   _decode_jsonr   s          r@   ro   zSyncHttpClient.get=  s     KKOODOA	  A $$ 	668??$D7*

4  G 9$@1MG	s   ; B3A B..B3r   c                  |t        |      \  }}ni d}}|r|j                  |       | j                  j                  |||      }	 |j	                          t        |      S # t
        j                  $ re}|j                         j                         }t        j                  dk\  r|j                  |       |t        j                  d| |       |d}~ww xY wr   )_encode_jsonr   ry   r   r   ru   r   rh   r   r   r   r   r   r   rd  r   s	            r@   r   zSyncHttpClient.postQ  s     '3D'9$OW')3WO""7+KKT?GL	  A $$ 	668??$D7*

4  G 9$@1MG	s   A# #C6A CCc                  t        |      \  }}|r|j                  |       | j                  j                  |||      }	 |j	                          t        |      S # t
        j                  $ re}|j                         j                         }t        j                  dk\  r|j                  |       |t        j                  d| |       |d}~ww xY w)r   r   r   r   r   N)rf  r   ry   r   r   ru   r   rh   r   r   r   r   r   r   rd  r   s	            r@   r   zSyncHttpClient.putk  s     $0#5 ""7+KKOOD/7OK	  A $$ 	668??$D7*

4  G 9$@1MG	   A C/A CCc                  t        |      \  }}|r|j                  |       | j                  j                  |||      }	 |j	                          t        |      S # t
        j                  $ re}|j                         j                         }t        j                  dk\  r|j                  |       |t        j                  d| |       |d}~ww xY w)r   r   r   r   r   N)rf  r   ry   r   r   ru   r   rh   r   r   r   r   r   r   rd  r   s	            r@   r   zSyncHttpClient.patch  s     $0#5 ""7+KKdOWM	  A $$ 	668??$D7*

4  G 9$@1MG	rh  r   c               Z   | j                   j                  d|||      }	 |j                          y# t        j                  $ re}|j                         j                         }t        j                  dk\  r|j                  |       |t        j                  d| |       |d}~ww xY w)r   r   r   r   r   r   N)ry   r   r   ru   r   rh   r   r   r   r   r   r   r   s          r@   r   zSyncHttpClient.delete  s     KK$T7K	 $$ 	668??$D7*

4  G 9$@1MG	s   2 B*A B%%B*r   c             #    K   t        |      \  }}d|d<   d|d<   |r|j                  |       | j                  j                  |||||      5 }	 |j	                          |j                  j                  d
d      j!                  d      d   }d|vrt        j"                  d|      t%               }t'        |      D ])  }|j                  |j)                  d            }|&| + 	 d	d	d	       y	# t
        j                  $ re}	|j                         j                         }
t        j                  dk\  r|	j                  |
       |	t        j                  d|
 |	       |	d	}	~	ww xY w# 1 sw Y   y	xY ww)z*Stream the results of a request using SSE.r   r   r   r   r   r   r   r   Nr   r   r   r   r   r   )rf  r   ry   r   r   ru   r   rh   r   r   r   r   r   r   rJ   ro   r   r   r/   r1   r   r   s                  r@   r   zSyncHttpClient.stream  s     $0#5 $7!+5(""7+[[D/76   
 	$$& ;;??>2>HHMaPL",6**'*, 
 !lG&s+ nnT[[%78?I-	 	 (( 
**,##w.JJt$  LL#=dV!DqLQ	 	sJ   AE<E0C5 BE0%E0,	E<5E-A E((E--E00E95E<r`  r   r   r   r   )r   r   r   r   r   r   r   r   rJ   r   r   Iterator[StreamPart]r   r   rB   r@   rZ  rZ  /  sD    -1,0 *	
 * 
2 -1 	
 * 
6 MQ"&1I	* MQ"&1I	. #,0 	
 * 
0  $,0,0(( (
 ( *( *( 
(rB   rZ  c                    t        j                  | t        t         j                  t         j                  z        }t        t        |            }d}||d}||fS r   )r   r   rX   r   r   r   r   r   s        r@   rf  rf    sR    <<""V%<%<<D
 T^N%L!/NGD=rB   c                T    | j                         }|rt        j                  |      S d S r}   )rh   r   r   r   s     r@   rd  rd    s#    668D!%6<</4/rB   c                     e Zd ZdZddZdd	 	 	 	 	 ddZddd	 	 	 	 	 	 	 ddZdd	 	 	 	 	 dd	Z	 	 ddd	 	 	 	 	 	 	 	 	 dd
Z	 dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	ddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ
dd	 	 	 	 	 ddZdddddd	 	 	 	 	 	 	 	 	 	 	 d dZ	 	 	 d!dd	 	 	 	 	 	 	 	 	 	 	 d"dZdd	 	 	 	 	 	 	 d#dZy)$r[  ag  Client for managing assistants in LangGraph synchronously.

    This class provides methods to interact with assistants, which are versioned configurations of your graph.

    ???+ example "Examples"

        ```python
        client = get_sync_client(url="http://localhost:2024")
        assistant = client.assistants.get("assistant_id_123")
        ```
    c                    || _         y r}   r   r   s     r@   r   zSyncAssistantsClient.__init__  r   rB   Nr   c               B    | j                   j                  d| |      S )a  Get an assistant by ID.

        Args:
            assistant_id: The ID of the assistant to get OR the name of the graph (to use the default assistant).
            headers: Optional custom headers to include with the request.

        Returns:
            Assistant: Assistant Object.

        ???+ example "Example Usage"

            ```python
            assistant = client.assistants.get(
                assistant_id="my_assistant_id"
            )
            print(assistant)
            ```

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

            {
                'assistant_id': 'my_assistant_id',
                'graph_id': 'agent',
                'created_at': '2024-06-25T17:10:33.109781+00:00',
                'updated_at': '2024-06-25T17:10:33.109781+00:00',
                'config': {},
                'metadata': {'created_by': 'system'}
            }
            ```

        r  r   r  r  s      r@   ro   zSyncAssistantsClient.get  s#    L yy}}|L>:G}LLrB   Fr  c               J    | j                   j                  d| dd|i|      S )a  Get the graph of an assistant by ID.

        Args:
            assistant_id: The ID of the assistant to get the graph of.
            xray: Include graph representation of subgraphs. If an integer value is provided, only subgraphs with a depth less than or equal to the value will be included.
            headers: Optional custom headers to include with the request.

        Returns:
            Graph: The graph information for the assistant in JSON format.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            graph_info = client.assistants.get_graph(
                assistant_id="my_assistant_id"
            )
            print(graph_info)

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

            {
                'nodes':
                    [
                        {'id': '__start__', 'type': 'schema', 'data': '__start__'},
                        {'id': '__end__', 'type': 'schema', 'data': '__end__'},
                        {'id': 'agent','type': 'runnable','data': {'id': ['langgraph', 'utils', 'RunnableCallable'],'name': 'agent'}},
                    ],
                'edges':
                    [
                        {'source': '__start__', 'target': 'agent'},
                        {'source': 'agent','target': '__end__'}
                    ]
            }
            ```

        r  r
  r  r   r  r  s       r@   r  zSyncAssistantsClient.get_graph  s4    X yy}}<./PW  
 	
rB   c               D    | j                   j                  d| d|      S )ab  Get the schemas of an assistant by ID.

        Args:
            assistant_id: The ID of the assistant to get the schema of.
            headers: Optional custom headers to include with the request.

        Returns:
            GraphSchema: The graph schema for the assistant.

        ???+ example "  Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            schema = client.assistants.get_schemas(
                assistant_id="my_assistant_id"
            )
            print(schema)
            ```
            ```shell
            ----------------------------------------------------------------------------------------------------------------------------

            {
                'graph_id': 'agent',
                'state_schema':
                    {
                        'title': 'LangGraphInput',
                        '$ref': '#/definitions/AgentState',
                        'definitions':
                            {
                                'BaseMessage':
                                    {
                                        'title': 'BaseMessage',
                                        'description': 'Base abstract Message class. Messages are the inputs and outputs of ChatModels.',
                                        'type': 'object',
                                        'properties':
                                            {
                                             'content':
                                                {
                                                    'title': 'Content',
                                                    'anyOf': [
                                                        {'type': 'string'},
                                                        {'type': 'array','items': {'anyOf': [{'type': 'string'}, {'type': 'object'}]}}
                                                    ]
                                                },
                                            'additional_kwargs':
                                                {
                                                    'title': 'Additional Kwargs',
                                                    'type': 'object'
                                                },
                                            'response_metadata':
                                                {
                                                    'title': 'Response Metadata',
                                                    'type': 'object'
                                                },
                                            'type':
                                                {
                                                    'title': 'Type',
                                                    'type': 'string'
                                                },
                                            'name':
                                                {
                                                    'title': 'Name',
                                                    'type': 'string'
                                                },
                                            'id':
                                                {
                                                    'title': 'Id',
                                                    'type': 'string'
                                                }
                                            },
                                        'required': ['content', 'type']
                                    },
                                'AgentState':
                                    {
                                        'title': 'AgentState',
                                        'type': 'object',
                                        'properties':
                                            {
                                                'messages':
                                                    {
                                                        'title': 'Messages',
                                                        'type': 'array',
                                                        'items': {'$ref': '#/definitions/BaseMessage'}
                                                    }
                                            },
                                        'required': ['messages']
                                    }
                            }
                    },
                'config_schema':
                    {
                        'title': 'Configurable',
                        'type': 'object',
                        'properties':
                            {
                                'model_name':
                                    {
                                        'title': 'Model Name',
                                        'enum': ['anthropic', 'openai'],
                                        'type': 'string'
                                    }
                            }
                    }
            }
            ```

        r  r  r   r  r  s      r@   r  z SyncAssistantsClient.get_schemasI  s%    b yy}}|L>BG}TTrB   c                   |&| j                   j                  d| d| d|i|      S | j                   j                  d| dd|i|      S )a  Get the schemas of an assistant by ID.

        Args:
            assistant_id: The ID of the assistant to get the schema of.
            headers: Optional custom headers to include with the request.

        Returns:
            Subgraphs: The graph schema for the assistant.

        r  r  r  r   r  r  r  s        r@   r  z"SyncAssistantsClient.get_subgraphs  sr    $  99==|nK	{C!7+ !   99==|nJ7!7+ !  rB   r  c                   d|i}	|r||	d<   |r||	d<   |r||	d<   |r||	d<   |r||	d<   |r||	d<   | j                   j                  d|	|	      S )
a  Create a new assistant.

        Useful when graph is configurable and you want to create different assistants based on different configurations.

        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.
            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.
                Must be either 'raise' (raise error if duplicate), or 'do_nothing' (return existing assistant).
            name: The name of the assistant. Defaults to 'Untitled' under the hood.
            headers: Optional custom headers to include with the request.
            description: Optional description of the assistant.
                The description field is available for langgraph-api server version>=0.0.45

        Returns:
            Assistant: The created assistant.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            assistant = client.assistants.create(
                graph_id="agent",
                config={"configurable": {"model_name": "openai"}},
                metadata={"number":1},
                assistant_id="my-assistant-id",
                if_exists="do_nothing",
                name="my_name"
            )
            ```
        r  r  r  r  r  r  r  r   r   r!  r"  s
             r@   r$  zSyncAssistantsClient.create  sy    \ #
  &GH"*GJ&2GN##,GK "GFO%0GM"yy~~m'7~KKrB   r%  c                   i }|r||d<   |r||d<   |r||d<   |r||d<   |r||d<   | j                   j                  d| ||      S )a  Update an assistant.

        Use this to point to a different graph, update the configuration, or change the metadata of an assistant.

        Args:
            assistant_id: Assistant to update.
            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.
            metadata: Metadata to merge with existing assistant metadata.
            name: The new name for the assistant.
            headers: Optional custom headers to include with the request.
            description: Optional description of the assistant.
                The description field is available for langgraph-api server version>=0.0.45

        Returns:
            Assistant: The updated assistant.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            assistant = client.assistants.update(
                assistant_id='e280dad7-8618-443f-87f1-8e41841c180f',
                graph_id="other-graph",
                config={"configurable": {"model_name": "anthropic"}},
                metadata={"number":2}
            )
            ```
        r  r  r  r  r  r  r   r'  r(  s	            r@   r   zSyncAssistantsClient.update  st    R #%"*GJ &GH"*GJ"GFO%0GM"yy<.)  
 	
rB   c               D    | j                   j                  d| |       y)a  Delete an assistant.

        Args:
            assistant_id: The assistant ID to delete.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            client.assistants.delete(
                assistant_id="my_assistant_id"
            )
            ```

        r  r   Nr+  r  s      r@   r   zSyncAssistantsClient.deleteS  s"    2 			<~6HrB   r-  r   )r  r  r.  r/  rJ   c               d    ||d}|r||d<   |r||d<   | j                   j                  d||      S )ab  Search for assistants.

        Args:
            metadata: Metadata to filter by. Exact match filter for each KV pair.
            graph_id: The ID of the graph to filter by.
                The graph ID is normally set in your langgraph.json configuration.
            limit: The maximum number of results to return.
            offset: The number of results to skip.
            headers: Optional custom headers to include with the request.

        Returns:
            list[Assistant]: A list of assistants.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            assistants = client.assistants.search(
                metadata = {"name":"my_name"},
                graph_id="my_graph_id",
                limit=5,
                offset=5
            )
            ```
        r3  r  r  r4  r   r!  )r   r  r  r.  r/  rJ   r#  s          r@   r5  zSyncAssistantsClient.searchn  sQ    F #
 "*GJ"*GJyy~~   
 	
rB   c               ^    ||d}|r||d<   | j                   j                  d| d||      S )a  List all versions of an assistant.

        Args:
            assistant_id: The assistant ID to get versions for.
            metadata: Metadata to filter versions by. Exact match filter for each KV pair.
            limit: The maximum number of versions to return.
            offset: The number of versions to skip.
            headers: Optional custom headers to include with the request.

        Returns:
            list[Assistant]: A list of assistants.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            assistant_versions = client.assistants.get_versions(
                assistant_id="my_assistant_id"
            )
            ```

        r3  r  r  r7  r   r!  r8  s          r@   r9  z!SyncAssistantsClient.get_versions  sK    B #
 "*GJyy~~<.	2'  
 	
rB   c               N    d|i}| j                   j                  d| d||      S )aO  Change the version of an assistant.

        Args:
            assistant_id: The assistant ID to delete.
            version: The version to change to.
            headers: Optional custom headers to include with the request.

        Returns:
            Assistant: Assistant Object.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            new_version_assistant = client.assistants.set_latest(
                assistant_id="my_assistant_id",
                version=3
            )
            ```

        r<  r  r=  r   r!  r>  s        r@   r?  zSyncAssistantsClient.set_latest  s8    : $-g"6yy~~<.0w  
 	
rB   r   rZ  r   r   rA  rB  rC  rD  rE  r}   rH  rK  rL  )r  r   r  rF  r.  rM  r/  rM  rJ   r   r   rO  rP  rQ  rR  rS  r   rB   r@   r[  r[    s   
 -1	&M&M *	&M
 
&MX "',0.
.
 	.

 *.
 
).
h -1	qUqU *	qU
 
qUl $(	 -1 ! 	 * 
D $(<L
 &*26",0%)<L<L !<L
 <L $<L 0<L <L *<L #<L 
<LD #'#'",0%)8
8
  	8

 !8
 8
 8
 *8
 #8
 
8
| -1	II *	I
 
I< "&,0.
 .
  	.

 .
 .
 *.
 
.
f (
 -1(
(
 (
 	(

 (
 *(
 
 (
^ -1!
!
 !

 *!
 
!
rB   r[  c                  j   e Zd ZdZddZdd	 	 	 	 	 ddZddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 ddZdd	 	 	 	 	 dd	Zdddd
ddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	dd	 	 	 	 	 ddZ
	 	 dddd	 	 	 	 	 	 	 	 	 	 	 ddZddddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZd
ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy) r\  a}  Synchronous client for managing threads in LangGraph.

    This class provides methods to create, retrieve, and manage threads,
    which represent conversations or stateful interactions.

    ???+ example "Example"

        ```python
        client = get_sync_client(url="http://localhost:2024")
        thread = client.threads.create(metadata={"user_id": "123"})
        ```
    c                    || _         y r}   r   r   s     r@   r   zSyncThreadsClient.__init__  r   rB   Nr   c               B    | j                   j                  d| |      S )aO  Get a thread by ID.

        Args:
            thread_id: The ID of the thread to get.
            headers: Optional custom headers to include with the request.

        Returns:
            Thread: Thread object.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            thread = client.threads.get(
                thread_id="my_thread_id"
            )
            print(thread)
            ```
            ```shell
            -----------------------------------------------------

            {
                'thread_id': 'my_thread_id',
                'created_at': '2024-07-18T18:35:15.540834+00:00',
                'updated_at': '2024-07-18T18:35:15.540834+00:00',
                'metadata': {'graph_id': 'agent'}
            }
            ```

        rW  r   r  rX  s      r@   ro   zSyncThreadsClient.get  s#    J yy}}y4g}FFrB   rZ  c               (   i }|r||d<   |s|ri |xs i |rd|ini |d<   |r||d<   |rA|D 	cg c]0  }d|d   D 	cg c]  }	|	d   |	j                  d      |	d   d	 c}	i2 c}	}|d
<   | j                  j                  d||      S c c}	w c c}	}w )a  Create a new thread.

        Args:
            metadata: Metadata to add to thread.
            thread_id: ID of thread.
                If None, ID will be a randomly generated UUID.
            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 thread).
            supersteps: Apply a list of supersteps when creating a thread, each containing a sequence of updates.
                Each update has `values` or `command` and `as_node`. Used for copying a thread between deployments.
            graph_id: Optional graph ID to associate with the thread.
            headers: Optional custom headers to include with the request.

        Returns:
            Thread: The created thread.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            thread = client.threads.create(
                metadata={"number":1},
                thread_id="my-thread-id",
                if_exists="raise"
            )
            ```
            )
        rY  r  r  r  r]  r^  r_  r`  ra  r[  rb  r   rc  rd  s
             r@   r$  zSyncThreadsClient.create$  s    L #%#,GK x#>r#-5J)2#GJ #,GK  $%   "#9  	 '(k'(uuY'7'(| 	%GL! yy~~jw~HH %s   B"B	B	Bc               H    | j                   j                  d| d|i|      S )a<  Update a thread.

        Args:
            thread_id: ID of thread to update.
            metadata: Metadata to merge with existing thread metadata.
            headers: Optional custom headers to include with the request.

        Returns:
            Thread: The created thread.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            thread = client.threads.update(
                thread_id="my-thread-id",
                metadata={"number":1},
            )
            ```
        rW  r  r   r'  rh  s       r@   r   zSyncThreadsClient.updatee  s1    6 yy	{#:x*@'  
 	
rB   c               D    | j                   j                  d| |       y)at  Delete a thread.

        Args:
            thread_id: The ID of the thread to delete.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client.threads.delete(
                thread_id="my_thread_id"
            )
            ```

        rW  r   Nr+  rX  s      r@   r   zSyncThreadsClient.delete  s"    0 			9YK0'BrB   r-  r   )r  r^  rk  r.  r/  rJ   c               r    ||d}|r||d<   |r||d<   |r||d<   | j                   j                  d||      S )av  Search for threads.

        Args:
            metadata: Thread metadata to filter on.
            values: State values to filter on.
            status: Thread status to filter on.
                Must be one of 'idle', 'busy', 'interrupted' or 'error'.
            limit: Limit on number of threads to return.
            offset: Offset in threads table to start search from.
            headers: Optional custom headers to include with the request.

        Returns:
            list[Thread]: List of the threads matching the search parameters.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            threads = client.threads.search(
                metadata={"number":1},
                status="interrupted",
                limit=15,
                offset=5
            )
            ```
        r3  r  r^  rk  rm  r   r!  )r   r  r^  rk  r.  r/  rJ   r#  s           r@   r5  zSyncThreadsClient.search  sU    J #
 "*GJ &GH &GHyy~~/gw~OOrB   c               F    | j                   j                  d| dd|      S )a  Copy a thread.

        Args:
            thread_id: The ID of the thread to copy.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            client.threads.copy(
                thread_id="my_thread_id"
            )
            ```

        rW  ro  Nr   r!  rX  s      r@   rp  zSyncThreadsClient.copy  s&    2 yy~~	)E:w~WWrB   Frq  c                   |r%| j                   j                  d| d||d|      S |r&| j                   j                  d| d| d|i|      S | j                   j                  d| dd|i|      S )	ao  Get the state of a thread.

        Args:
            thread_id: The ID of the thread to get the state of.
            checkpoint: The checkpoint to get the state of.
            subgraphs: Include subgraphs states.
            headers: Optional custom headers to include with the request.

        Returns:
            ThreadState: the thread of the state.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            thread_state = client.threads.get_state(
                thread_id="my_thread_id",
                checkpoint_id="my_checkpoint_id"
            )
            print(thread_state)
            ```

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

            {
                'values': {
                    '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
                        }
                    ]
                },
                'next': [],
                'checkpoint':
                    {
                        'thread_id': 'e2496803-ecd5-4e0c-a779-3226296181c2',
                        'checkpoint_ns': '',
                        'checkpoint_id': '1ef4a9b8-e6fb-67b1-8001-abd5184439d1'
                    }
                'metadata':
                    {
                        'step': 1,
                        'run_id': '1ef4a9b8-d7da-679a-a45a-872054341df2',
                        'source': 'loop',
                        'writes':
                            {
                                'agent':
                                    {
                                        'messages': [
                                            {
                                                'id': 'run-159b782c-b679-4830-83c6-cef87798fe8b',
                                                'name': None,
                                                'type': 'ai',
                                                'content': "I'm doing well, thanks for asking! I'm an AI assistant created by Anthropic to be helpful, honest, and harmless.",
                                                'example': False,
                                                'tool_calls': [],
                                                'usage_metadata': None,
                                                'additional_kwargs': {},
                                                'response_metadata': {},
                                                'invalid_tool_calls': []
                                            }
                                        ]
                                    }
                            },
                'user_id': None,
                'graph_id': 'agent',
                'thread_id': 'e2496803-ecd5-4e0c-a779-3226296181c2',
                'created_by': 'system',
                'assistant_id': 'fe096781-5601-53d2-b2f6-0d3403f7e9ca'},
                'created_at': '2024-07-25T15:35:44.184703+00:00',
                'parent_config':
                    {
                        'thread_id': 'e2496803-ecd5-4e0c-a779-3226296181c2',
                        'checkpoint_ns': '',
                        'checkpoint_id': '1ef4a9b8-d80d-6fa7-8000-9300467fad0f'
                    }
            }
            ```

        rW  rt  ru  r   rw  rr  r   rx  ry  rz  s         r@   r|  zSyncThreadsClient.get_state  s    X 99>>I;&78$.YG "  
 99==I;gm_=#Y/ !   99==I;f-#Y/ !  rB   r}  c               x    d|i}|r||d<   |r||d<   |r||d<   | j                   j                  d| d||      S )a  Update the state of a thread.

        Args:
            thread_id: The ID of the thread to update.
            values: The values to update the state with.
            as_node: Update the state as if this node had just executed.
            checkpoint: The checkpoint to update the state of.
            headers: Optional custom headers to include with the request.

        Returns:
            ThreadUpdateStateResponse: Response after updating a thread's state.

        ???+ example "Example Usage"

            ```python

            response = await client.threads.update_state(
                thread_id="my_thread_id",
                values={"messages":[{"role": "user", "content": "hello!"}]},
                as_node="my_node",
            )
            print(response)

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

            {
                'checkpoint': {
                    'thread_id': 'e2496803-ecd5-4e0c-a779-3226296181c2',
                    'checkpoint_ns': '',
                    'checkpoint_id': '1ef4a9b8-e6fb-67b1-8001-abd5184439d1',
                    'checkpoint_map': {}
                }
            }
            ```

        r^  r{  rv  r`  rW  rx  r   r!  r  s           r@   r  zSyncThreadsClient.update_stateh  sd    ^ f#
 '4GO$$.GL!!(GIyy~~	{&)  
 	
rB   r  c               x    d|i}|r||d<   |r||d<   |r||d<   | j                   j                  d| d||      S )aT  Get the state history of a thread.

        Args:
            thread_id: The ID of the thread to get the state history for.
            checkpoint: Return states for this subgraph. If empty defaults to root.
            limit: The maximum number of states to return.
            before: Return states before this checkpoint.
            metadata: Filter states by metadata key-value pairs.
            headers: Optional custom headers to include with the request.

        Returns:
            list[ThreadState]: the state history of the thread.

        ???+ example "Example Usage"

            ```python

            thread_state = client.threads.get_history(
                thread_id="my_thread_id",
                limit=5,
                before="my_timestamp",
                metadata={"name":"my_name"}
            )
            ```

        r.  r  r  rv  rW  r  r   r!  r  s           r@   r  zSyncThreadsClient.get_history  sd    J U#
  &GH"*GJ$.GL!yy~~	{(+'7  
 	
rB   r{  r  r  r  r  )r  r   r^  r   rk  r  r.  rM  r/  rM  rJ   r   r   r  r  r  r  r  r  r   rB   r@   r\  r\    s    -1	%G%G *	%G
 
%GT #'26NR"&,0?I ?I !	?I
 0?I L?I  ?I *?I 
?IL -1

 !	

 *
 

F -1	CC *	C
 
C: )-,0.P .P 	.P
 '.P .P .P *.P 
.Ph -1	XX *	X
 
X< ,0'+	}  ,0}} )} %	} } *} 
}H "&+/'+,09
9
 69

 9
 )9
 %9
 *9
 
#9
~ -1#'+/,0/
/
 	/

 +/
 !/
 )/
 */
 
/
rB   r\  c                  Z   e Zd ZdZd&dZeddddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d'd       Zeddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(d	       Zdddddddddddddddddddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)dZeddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d*d       Zeddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d+d       Zdddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d,dZdd	 	 	 	 	 d-dZedddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d.d       Z	edddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d/d       Z	ddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d0dZ	dddd	 	 	 	 	 	 	 	 	 d1dZ
dd	 	 	 	 	 	 	 d2dZdddd 	 	 	 	 	 	 	 	 	 	 	 d3d!Zdd	 	 	 	 	 	 	 d4d"Zdddd#	 	 	 	 	 	 	 	 	 	 	 d5d$Zdd	 	 	 	 	 	 	 d6d%Zy)7r]  a~  Synchronous client for managing runs in LangGraph.

    This class provides methods to create, retrieve, and manage runs, which represent
    individual executions of graphs.

    ???+ example "Example"

        ```python
        client = get_sync_client(url="http://localhost:2024")
        run = client.runs.create(thread_id="thread_123", assistant_id="asst_456")
        ```
    c                    || _         y r}   r   r   s     r@   r   zSyncRunsClient.__init__  r   rB   Nr^  Fr  c                    y r}   r   r  s                        r@   r   zSyncRunsClient.stream  s    0  #rB   r  c                    y r}   r   r  s                      r@   r   zSyncRunsClient.stream   s    ,  #rB   r  c          
     |   i d|d|r'|j                         D ci c]  \  }}|	|| c}}ndd|d|d|d|d|d	|d
|d|d|d|	d|
d|d|d|d|||d}|d| dnd}| j                  j                  |d|j                         D ci c]  \  }}|	|| c}}|      S c c}}w c c}}w )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: The command to execute.
            stream_mode: The stream mode(s) to use.
            stream_subgraphs: Whether to stream output from subgraphs.
            metadata: Metadata to assign to the run.
            config: The configuration for the assistant.
            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.
            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.

        Returns:
            Iterator[StreamPart]: Iterator of stream results.

        ???+ example "Example Usage"

            ```python
            client = get_sync_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"},
                config={"configurable": {"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)
            ```
        r  r_  Nr  r  r  r  r  r  r  r  r  rv  r{  r  r  r  r  r  rW  r  r  r   r  r  s                             r@   r   zSyncRunsClient.stream  sw   n
U
GN'--/C$!QQ]ACTX

 f
 
 ;
  0
 L
  0
 
 ]
 w
 *
 ]
   !2!
" !"4#
$ ]%
& ]'
( +*+
2 $ 	{,/ 	
 yy#*==?D41aam!Q$D	   
 	
3 D8 Er  )r  r_  r  r  r  r  r  r  r  r  r  r  r  rJ   c                    y r}   r   )r   rY  r  r  r_  r  r  r  r  r  r  r  r  r  r  r  rJ   s                    r@   r$  zSyncRunsClient.create  s    ( rB   r  c                    y r}   r   r  s                      r@   r$  zSyncRunsClient.create  s    , rB   )r  r_  r  r  r  r  rv  r{  r  r  r  r  r  r  r  r  rJ   c                  i d|d|r'|j                         D ci c]  \  }}|	|| c}}ndd|d|d|d|d|d	|d
|d|d|	d|
d|d|d|d|d|}|j                         D ci c]  \  }}|	|| }}}|r"| j                  j                  d| d||      S | j                  j                  d||      S c c}}w c c}}w )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: The command to execute.
            stream_mode: The stream mode(s) to use.
            stream_subgraphs: Whether to stream output from subgraphs.
            metadata: Metadata to assign to the run.
            config: The configuration for the assistant.
            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.
            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.

        Returns:
            Run: The created background run.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            background_run = client.runs.create(
                thread_id="my_thread_id",
                assistant_id="my_assistant_id",
                input={"messages": [{"role": "user", "content": "hello!"}]},
                metadata={"name":"my_run"},
                config={"configurable": {"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,
                                        'model_name': "openai",
                                        'assistant_id': 'my_assistant_id'
                                    }
                            },
                        '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'
            }
            ```
        r  r_  Nr  r  r  r  r  r  r  r  rv  r{  r  r  r  r  r  rW  r  r   r  )r   rY  r  r  r_  r  r  r  r  rv  r{  r  r  r  r  r  r  r  r  rJ   r  r  r#  s                          r@   r$  zSyncRunsClient.create  st   t
U
GN'--/C$!QQ]ACTX

 ;
  0
 f
 
 L
  0
 
 w
 *
 ]
  !2
  !"4!
" ]#
$ ]%
& ]'
* %,MMOEDAqq}1a4EE99>>I;e,7G "   99>>'>II1 D$ Fs   
C
C
2
C=Cr   c               z    dd}|D cg c]
  } ||       }}| j                   j                  d||      S c c}w )r  c                \    | j                         D ci c]  \  }}|	|| c}}S c c}}w r}   r  r  s      r@   r  z3SyncRunsClient.create_batch.<locals>.filter_payload\  r  r  r  r   r  r!  )r   r  rJ   r  r#  s        r@   r  zSyncRunsClient.create_batchW  sB    
	G <DDN7+DDyy~~m(G~LL Es   8)r  r_  r  r  rv  r{  r  r  r  r  r  r  r  r  rJ   c                    y r}   r   )r   rY  r  r  r_  r  r  rv  r{  r  r  r  r  r  r  r  r  rJ   s                     r@   r  zSyncRunsClient.waitb  s    * -0rB   )r  r_  r  r  r  r  r  r  r  r  r  r  rJ   c                    y r}   r   )r   rY  r  r  r_  r  r  r  r  r  r  r  r  r  r  rJ   s                   r@   r  zSyncRunsClient.waity  s    & -0rB   )r  r_  r  r  r  rv  r{  r  r  r  r  r  r  r  r  rJ   c          	     j   i d|d|r'|j                         D ci c]  \  }}|	|| c}}ndd|d|d|d|
d|d	|d
|d|	d|d|d|d|d|d|}|d| dnd}| j                  j                  ||j                         D ci c]  \  }}|	|| c}}|      S c c}}w c c}}w )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: The command to execute.
            metadata: Metadata to assign to the run.
            config: The configuration for the assistant.
            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.
            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.

        Returns:
            Union[list[dict], dict[str, Any]]: The output of the run.

        ???+ example "Example Usage"

            ```python

            final_state_of_run = client.runs.wait(
                thread_id=None,
                assistant_id="agent",
                input={"messages": [{"role": "user", "content": "how are you?"}]},
                metadata={"name":"my_run"},
                config={"configurable": {"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
                    }
                ]
            }
            ```

        r  r_  Nr  r  r  r  r  r  rv  r{  r  r  r  r  r  r  rW  r  r   r  )r   rY  r  r  r_  r  r  r  rv  r{  r  r  r  r  r  r  r  r  rJ   r  r  r#  r  s                          r@   r  zSyncRunsClient.wait  sT   N
U
GN'--/C$!QQ]ACTX

 f
 
 L
  0
 
 w
 *
 ]
 !"4
 ]
 ]
   !2!
" ]#
$ ]%
* 2;1Fi	{*-L 	 yy~~#*==?D41aam!Q$D  
 	
) D, Es   
B)
B)

B/B/r-  r   )r.  r/  rJ   c               N    | j                   j                  d| d| d| |      S )aj  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.
            headers: Optional custom headers to include with the request.

        Returns:
            List[Run]: The runs for the thread.

        ???+ example "Example Usage"

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

        rW  z/runs?limit=z&offset=r   r  )r   rY  r.  r/  rJ   s        r@   rT   zSyncRunsClient.list  s7    > yy}}	{,ugXfXFPW  
 	
rB   c               H    | j                   j                  d| d| |      S )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.

        Returns:
            Run: Run object.

        ???+ example "Example Usage"

            ```python

            run = client.runs.get(
                thread_id="thread_id_to_delete",
                run_id="run_id_to_delete",
            )
            ```
        rW  r  r   r  r  s       r@   ro   zSyncRunsClient.get5  s(    8 yy}}y6&BG}TTrB   r  r  c          
     ^    | j                   j                  d| d| d|rdnd d| d|      S )	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.

        Returns:
            None

        ???+ example "Example Usage"

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

        rW  r  r  r  r   r  Nr   r!  r  s         r@   r  zSyncRunsClient.cancelS  sH    F yy~~	{&4aQ=OxX^W_`  
 	
rB   c               J    | j                   j                  d| d| d|      S )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.

        Returns:
            None

        ???+ example "Example Usage"

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

        rW  r  r  r   r  r  s       r@   r  zSyncRunsClient.join|  s2    8 yy}}	{&6  
 	
rB   )r  r  rJ   c               T    | j                   j                  d| d| dd||d|      S )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.
            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.
            cancel_on_disconnect: Whether to cancel the run when the stream is disconnected.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            client.runs.join_stream(
                thread_id="thread_id_to_join",
                run_id="run_id_to_join",
                stream_mode=["values", "debug"]
            )
            ```

        rW  r  r  r  )r  r  r   r  )r   rY  r  r  r  rJ   s         r@   r  zSyncRunsClient.join_stream  sF    J yy	{&8*(<    
 	
rB   c               J    | j                   j                  d| d| |       y)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.

        Returns:
            None

        ???+ example "Example Usage"

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

        rW  r  r   Nr+  r  s       r@   r   zSyncRunsClient.delete  s(    8 			9YKvfX>PrB   r{  )*rY  r   r  r   r  r   r_  r  r  r  r  rG  r  r   r  rI  rv  r  r{  rF  r  r  r  r  r  r  r  r  r  r  r  rF  r  r  r  r  r  r  rJ   r   r   rl  )&rY  r   r  r   r  r   r_  r  r  r  r  rG  r  r   r  rI  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rF  r  r  rJ   r   r   rl  ),rY  rF  r  r   r  r   r_  r  r  r  r  rG  r  r   r  rI  rv  r  r{  rF  r  r  r  r  r  r  r  r  r  r  r  r  r  rF  r  r  r  r  r  r  rJ   r   r   rl  )"rY  r   r  r   r  r   r_  r  r  r  r  rG  r  r   r  rI  r  r  r  r  r  r  r  rF  r  r  r  r  r  r  rJ   r   r   r"   r  )(rY  rF  r  r   r  r   r_  r  r  r  r  rG  r  r   r  rI  rv  r  r{  rF  r  r  r  r  r  r  r  rF  r  r  r  r  r  r  r  r  rJ   r   r   r"   )r  r  rJ   r   r   r  )$rY  r   r  r   r  r   r_  r  r  r   r  rI  rv  r  r{  rF  r  r  r  r  r  r  r  rF  r  r  r  r  r  r  r  r  rJ   r   r   r  ) rY  r   r  r   r  r   r_  r  r  r   r  rI  r  r  r  r  r  r  r  rF  r  r  r  r  r  r  r  r  rJ   r   r   r  )&rY  rF  r  r   r  r   r_  r  r  r   r  rI  r  r  rv  r  r{  rF  r  r  r  r  r  rF  r  r  r  r  r  r  r  r  r  r  rJ   r   r   r  )
rY  r   r.  rM  r/  rM  rJ   r   r   r  r  r  r  )rY  r   r  r   r  r  r  rG  rJ   r   r   rl  r  r   r   rB   r@   r]  r]    s
     !%%)?G!&#'#'+/'+,0@D?C1526!%:>/3'+,0-## #
 # ## =# # !# !# )# %# *# ># =#  /!#" 0##$ %#& 8'#( -)#* %+#, *-#. 
/# #2  !%%)?G!&#'#',0@D?C15268</3!%'+,0)## #
 # ## =# # !# !# *# ># =# /# 0#  6!#" -##$ %#& %'#( *)#* 
+# #8 !%%)?G!&#'#'+/'+,0@D?C15268<!%:>/3'+,0/x
 x
 x

 x
 #x
 =x
 x
 !x
 !x
 )x
 %x
 *x
 >x
 =x
  /!x
" 0#x
$ 6%x
& 'x
( 8)x
* -+x
, %-x
. */x
0 
1x
t  !%%)?G!&#'#',0@D?C!%8</3'+,0% 
  # =  ! ! * > =  6  -!" %#$ *%& 
' *  !%%)?G!&#'#'+/'+,0@D?C!%:>/3'+,0) 
  # =  ! ! ) % * > =  !" 8#$ -%& %'( *)* 
+ 8 !%%)?G!&#'#'+/'+,0@D?C!%:>8</3'+,0+UJ UJ UJ
 UJ #UJ =UJ UJ !UJ !UJ )UJ %UJ *UJ >UJ =UJ  !UJ" 8#UJ$ 6%UJ& -'UJ( %)UJ* *+UJ, 
-UJp QU	M'	M5M	M		M  !%%)#'#'+/'+,0@D?C!%26:>/3'+,0'00 0
 0 #0 !0 !0 )0 %0 *0 >0 =0 0 00  8!0" -#0$ %%0& *'0( 
+)0 0,  !%%)#'#',0@D?C!%268</3'+,0#00 0
 0 #0 !0 !0 *0 >0 =0 0 00 60 -0  %!0" *#0$ 
+%0 02 !%%)#'#',0+/'+@D?C!%268<:>/3'+,0)B
 B
 B

 B
 #B
 !B
 !B
 *B
 )B
 %B
 >B
 =B
 B
 0B
  6!B
" 8#B
$ -%B
& %'B
( *)B
* 
++B
P ,0!
!
 	!

 !
 *!
 
!
P -1UU U
 *U 
UF *,0'
'
 '

 '
 '
 *'
 
'
\ -1

 

 *
 

J JN%*,0-
-
 -

 G-
 #-
 *-
 
-
h -1QQ Q
 *Q 
QrB   r]  c            
          e Zd ZdZddZdddddddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdddddddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdd	 	 	 	 	 dd	Zddd
ddd	 	 	 	 	 	 	 	 	 	 	 ddZy)r^  a  Synchronous client for managing cron jobs in LangGraph.

    This class provides methods to create and manage scheduled tasks (cron jobs) for automated graph executions.

    ???+ example "Example"

        ```python
        client = get_sync_client(url="http://localhost:8123")
        cron_job = client.crons.create_for_thread(thread_id="thread_123", assistant_id="asst_456", schedule="0 * * * *")
        ```

    !!! note "Feature Availability"
        The crons client functionality is not supported on all licenses.
        Please check the relevant license documentation for the most up-to-date
        details on feature availability.
    c                    || _         y r}   r   r  s     r@   r   zSyncCronClient.__init__  r  rB   N)	r  r  r  r  r  r  r  r  rJ   c       
            |||||||	||
|d
}|j                         D ci c]  \  }}|	|| }}}| j                  j                  d| d||      S c c}}w )a  Create a cron job for a thread.

        Args:
            thread_id: the thread ID to run the cron job on.
            assistant_id: The assistant ID or graph name to use for the cron job.
                If using graph name, will default to first assistant created from that graph.
            schedule: The cron schedule to execute this job on.
            input: The input to the graph.
            metadata: Metadata to assign to the cron job runs.
            config: The configuration for the assistant.
            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.
            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'.
            headers: Optional custom headers to include with the request.

        Returns:
            Run: The cron run.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:8123")
            cron_run = client.crons.create_for_thread(
                thread_id="my-thread-id",
                assistant_id="agent",
                schedule="27 15 * * *",
                input={"messages": [{"role": "user", "content": "hello!"}]},
                metadata={"name":"my_run"},
                config={"configurable": {"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"
            )
            ```
        )
r	  r  r  r  r  r  r  r  r  r  rW  r
  r   r  )r   rY  r  r	  r  r  r  r  r  r  r  r  rJ   r#  r  r  s                   r@   r  z SyncCronClient.create_for_thread  s    p ! ( 0.!2"4
 %,MMOEDAqq}1a4EEyy~~	{+.Wg  
 	
 Fs
   
AAr  c       
            ||||||||	||
d
}|j                         D ci c]  \  }}|	|| }}}| j                  j                  d||      S c c}}w )a-  Create a cron run.

        Args:
            assistant_id: The assistant ID or graph name to use for the cron job.
                If using graph name, will default to first assistant created from that graph.
            schedule: The cron schedule to execute this job on.
            input: The input to the graph.
            metadata: Metadata to assign to the cron job runs.
            config: The configuration for the assistant.
            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.
            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'.
            headers: Optional custom headers to include with the request.

        Returns:
            Run: The cron run.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:8123")
            cron_run = client.crons.create(
                assistant_id="agent",
                schedule="27 15 * * *",
                input={"messages": [{"role": "user", "content": "hello!"}]},
                metadata={"name":"my_run"},
                config={"configurable": {"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"],
                webhook="https://my.fake.webhook.com",
                multitask_strategy="interrupt"
            )
            ```

        )
r	  r  r  r  r  r  r  r  r  r  r
  r   r  r  s                  r@   r$  zSyncCronClient.createG  sp    n ! ( 0.!2"4
 %,MMOEDAqq}1a4EEyy~~m'7~KK Fs
   
AAr   c               D    | j                   j                  d| |       y)a  Delete a cron.

        Args:
            cron_id: The cron ID to delete.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:8123")
            client.crons.delete(
                cron_id="cron_to_delete"
            )
            ```

        r  r   Nr+  r  s      r@   r   zSyncCronClient.delete  s"    2 			<y17CrB   r-  r   r  c                   ||||d}|j                         D ci c]  \  }}|	|| }}}| j                  j                  d||      S c c}}w )a  Get a list of cron jobs.

        Args:
            assistant_id: The assistant ID or graph name to search for.
            thread_id: the thread ID to search for.
            limit: The maximum number of results to return.
            offset: The number of results to skip.
            headers: Optional custom headers to include with the request.

        Returns:
            list[Cron]: The list of cron jobs returned by the search,

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:8123")
            cron_jobs = client.crons.search(
                assistant_id="my_assistant_id",
                thread_id="my_thread_id",
                limit=5,
                offset=5,
            )
            print(cron_jobs)
            ```

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

            [
                {
                    'cron_id': '1ef3cefa-4c09-6926-96d0-3dc97fd5e39b',
                    'assistant_id': 'my_assistant_id',
                    'thread_id': 'my_thread_id',
                    'user_id': None,
                    'payload':
                        {
                            'input': {'start_time': ''},
                            'schedule': '4 * * * *',
                            'assistant_id': 'my_assistant_id'
                        },
                    'schedule': '4 * * * *',
                    'next_run_date': '2024-07-25T17:04:00+00:00',
                    'end_time': None,
                    'created_at': '2024-07-08T06:02:23.073257+00:00',
                    'updated_at': '2024-07-08T06:02:23.073257+00:00'
                }
            ]
            ```
        r  r  r   r  r  s	            r@   r5  zSyncCronClient.search  s_    v )"	
 %,MMOEDAqq}1a4EEyy~~2'~RR Fs
   
AA)r  rZ  r   r   )rY  r   r  r   r	  r   r  r   r  r   r  r  r  rI  r  r  r  r  r  rF  r  rF  rJ   r   r   r"   r  r  r  r  r   rB   r@   r^  r^    s   "  !%#',0#'<@;?!%,0,0F
F
 F

 F
 F
 !F
 *F
 !F
 :F
 9F
 F
 *F
 *F
 
F
Z !%#'#',0<@;?!%,0,0CLCL 	CL
 CL !CL !CL *CL :CL 9CL CL *CL *CL 
CLR -1	DD *	D
 
D< '+#',0AS $AS !	AS
 AS AS *AS 
ASrB   r^  c                      e Zd ZdZd
dZ	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddd	 	 	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Z	y)r_  a  A client for synchronous operations on a key-value store.

    Provides methods to interact with a remote key-value store, allowing
    storage and retrieval of items within namespaced hierarchies.

    ???+ example "Example"

        ```python
        client = get_sync_client(url="http://localhost:2024"))
        client.store.put_item(["users", "profiles"], "user123", {"name": "Alice", "age": 30})
        ```
    c                    || _         y r}   r   r   s     r@   r   zSyncStoreClient.__init__  r   rB   Nc                   |D ]  }d|v st        d| d       |||||d}| j                  j                  dt        |      |       y)a  Store or update an item.

        Args:
            namespace: A list of strings representing the namespace path.
            key: The unique identifier for the item within the namespace.
            value: A dictionary containing the item's data.
            index: Controls search indexing - None (use defaults), False (disable), or list of field paths to index.
            ttl: Optional time-to-live in minutes for the item, or None for no expiration.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:8123")
            client.store.put_item(
                ["documents", "user123"],
                key="item456",
                value={"title": "My Document", "content": "Hello World"}
            )
            ```
        r  r   r!  r"  r'  r   Nr(  r*  s	            r@   r,  zSyncStoreClient.put_item  sj    D  	Ee| /w6gh 	 #
 			n>'+BGTrB   r-  c                  |D ]  }d|v st        d| d       |dj                  |      d}|||d<   | j                  j                  d||      S )ax  Retrieve a single item.

        Args:
            key: The unique identifier for the item.
            namespace: Optional list of strings representing the namespace path.
            refresh_ttl: Whether to refresh the TTL on this read operation. If None, uses the store's default behavior.
            headers: Optional custom headers to include with the request.

        Returns:
            Item: The retrieved item.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:8123")
            item = client.store.get_item(
                ["documents", "user123"],
                key="item456",
            )
            print(item)
            ```

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

            {
                'namespace': ['documents', 'user123'],
                'key': 'item456',
                'value': {'title': 'My Document', 'content': 'Hello World'},
                'created_at': '2024-07-30T12:00:00Z',
                'updated_at': '2024-07-30T12:00:00Z'
            }
            ```
        r  r   r!  r#  r  r.  r'  r   r1  r2  s          r@   r3  zSyncStoreClient.get_item,  ss    V  	Ee| /w6gh 	 388I+>?"$/F=!yy}}^FG}LLrB   c               F    | j                   j                  d||d|       y)a&  Delete an item.

        Args:
            key: The unique identifier for the item.
            namespace: Optional list of strings representing the namespace path.
            headers: Optional custom headers to include with the request.

        Returns:
            None

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:8123")
            client.store.delete_item(
                ["documents", "user123"],
                key="item456",
            )
            ```
        r'  r  r   Nr+  r5  s       r@   r6  zSyncStoreClient.delete_itemb  s'    6 			9!Ew 	 	
rB   c               b    ||||||d}| j                   j                  dt        |      |      S )a  Search for items within a namespace prefix.

        Args:
            namespace_prefix: List of strings representing the namespace prefix.
            filter: Optional dictionary of key-value pairs to filter results.
            limit: Maximum number of items to return (default is 10).
            offset: Number of items to skip before returning results (default is 0).
            query: Optional query for natural language search.
            refresh_ttl: Whether to refresh the TTL on items returned by this search. If None, uses the store's default behavior.
            headers: Optional custom headers to include with the request.

        Returns:
            List[Item]: A list of items matching the search criteria.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:8123")
            items = client.store.search_items(
                ["documents"],
                filter={"author": "John Doe"},
                limit=5,
                offset=0
            )
            print(items)
            ```
            ```shell
            ----------------------------------------------------------------

            {
                "items": [
                    {
                        "namespace": ["documents", "user123"],
                        "key": "item789",
                        "value": {
                            "title": "Another Document",
                            "author": "John Doe"
                        },
                        "created_at": "2024-07-30T12:00:00Z",
                        "updated_at": "2024-07-30T12:00:00Z"
                    },
                    # ... additional items ...
                ]
            }
            ```
        r8  r<  r   r=  r>  s	            r@   r?  zSyncStoreClient.search_items  sF    t !1&
 yy~~!w(?  
 	
rB   c                `    |||||d}| j                   j                  dt        |      |      S )a  List namespaces with optional match conditions.

        Args:
            prefix: Optional list of strings representing the prefix to filter namespaces.
            suffix: Optional list of strings representing the suffix to filter namespaces.
            max_depth: Optional integer specifying the maximum depth of namespaces to return.
            limit: Maximum number of namespaces to return (default is 100).
            offset: Number of namespaces to skip before returning results (default is 0).
            headers: Optional custom headers to include with the request.

        Returns:
            List[List[str]]: A list of namespaces matching the criteria.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:8123")
            namespaces = client.store.list_namespaces(
                prefix=["documents"],
                max_depth=3,
                limit=10,
                offset=0
            )
            print(namespaces)
            ```

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

            [
                ["documents", "user123", "reports"],
                ["documents", "user456", "invoices"],
                ...
            ]
            ```
        rA  rD  r   r=  rE  s           r@   rF  zSyncStoreClient.list_namespaces  sC    \ "
 yy~~nW&=w  
 	
rB   r{  rG  rH  rJ  r}   rK  rL  rM  rN  rP  rR  r   rB   r@   r_  r_    s    =A!,0.U 	.U
 .U :.U .U *.U .U 
.Ul '+,04M 	4M 4M $4M *4M 
4Mv -1
 	

 *
 
 

F ,0#&*,0C
 )	C

 C
 C
 C
 $C
 *C
'C
 
C
N '+&*#',06
#6
 $6
 !	6

 6
 6
 *6
 
6
rB   r_  c                \    | j                         D ci c]  \  }}|	|| c}}S c c}}w r}   r  )dr  r  s      r@   r)  r)    s(    WWY8TQ!-AqD888r  zlist[httpx.ASGITransport]rq   c                (    t         D ]	  }| |_         y r}   )rq   r_   )r_   rm   s     r@   configure_loopback_transportsr    s    + 		rB   r  )maxsizec                 f    	 ddl m}  | j                  S # t        $ r t        j                  cY S w xY w)Nr   asgi_transport)langgraph_apir  ASGITransportImportErrorru   r  s    r@   rp   rp     s1    #0+++ #"""#s    00r}   )r=   rF  r   rF  )r=   rF  rH   r   r   zdict[str, str])rW   r   r   r   )
rY   rF  r=   rF  rJ   r   rZ   Optional[TimeoutTypes]r   r[   )r   r   r   ztuple[dict[str, str], bytes])r   zhttpx.Responser   r   )
rY   rF  r=   rF  rJ   r   rZ   r  r   rS  )r  rN   )r_   r   r   r   )r   zType[httpx.ASGITransport])br   
__future__r   r   	functoolsloggingr:   r   typingr   r   r   r   r   r	   r
   r   r   r   r   ru   r   httpx._typesr   rF   langgraph_sdk.schemar   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   langgraph_sdk.sser/   r0   r1   	getLoggerr   r   rD   rA   rK   rX   rz   r[   r~   r   r   r   r   r   r   r   rW  rS  rZ  rf  rd  r[  r\  r]  r^  r_  r)  rq   __annotations__r  	lru_cacherp   floattuplerx   TimeoutTypesr   rB   r@   <module>r     s   #    	 
      (                  B J I			8	$ "  ,D(P !(,&*D#	D# D# &	D#
 $D# D#N, ,(_ _D V
 V
rn
 n
b\W \W~GY GYTX
 X
z !(,&*5'	5' 5' &	5'
 $5' 5'p0 0.^ ^B	0
H
 H
Vf
 f
RRQ RQj~S ~SBQ
 Q
h9 57 1 6
 Q#  # UO	(5/8E?HUOXe_
LM	MMrB   