
    9i,                   `   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Zddl	Z	ddl
mZmZmZmZmZ ddlmZ ddlmZmZmZmZ ddlZddlZddlZddlmZm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/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZH dd	lImJZJmKZKmLZL  ej                  eN      ZOd
ZP ed eQ             ZReRfd:dZS	 	 	 	 	 	 d;dZTd<dZU ej                  d      ZW	 	 	 	 d=dZXdeRddd	 	 	 	 	 	 	 	 	 d>dZY G d d      ZZ G d d      Z[d?dZ\d@dZ] G d d      Z^ G d d      Z_ G d d      Z` G d d      Za G d  d!      ZbdeRddd	 	 	 	 	 	 	 	 	 dAd#Zc G d$ d"      Zd G d% d&      ZedBd'Zfd@d(Zg G d) d*      Zh G d+ d,      Zi G d- d.      Zj G d/ d0      Zk G d1 d2      ZldCd3Zmg Znd4eod5<   dDd6Zp ej                  d78      dEd9       Zrdesz  etesdz  esdz  f   z  etesdz  esdz  esdz  esdz  f   z  ej                  z  Zvy)Fa  The LangGraph client implementations connect to the LangGraph API.

This module provides both asynchronous (`get_client(url="http://localhost:2024")` or
`LangGraphClient`) and synchronous (`get_sync_client(url="http://localhost:2024")` or
`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)AsyncIteratorCallableIteratorMappingSequence)TracebackType)AnyLiteralcastoverload)_araise_for_status_typed_raise_for_status_typed)+All	AssistantAssistantSelectFieldAssistantSortByAssistantsSearchResponseAssistantVersionCancelAction
CheckpointCommandConfigContextCronCronSelectField
CronSortByDisconnectMode
DurabilityGraphSchemaIfNotExistsInputItemJsonListNamespaceResponseMultitaskStrategyOnCompletionBehaviorOnConflictBehaviorQueryParamTypesRun	RunCreateRunCreateMetadataRunSelectField	RunStatusSearchItemsResponse	SortOrder
StreamMode
StreamPart	SubgraphsThreadThreadSelectFieldThreadSortByThreadStateThreadStatusThreadStreamModeThreadUpdateStateResponse)
SSEDecoderaiter_lines_rawiter_lines_raw)	x-api-keyc                    t        | t              r| S | t        u rQdD ]L  }t        j                  | d      x}s|j                         j                  d      j                  d      c S  y)a  Get the API key from the environment.
    Precedence:
        1. explicit string argument
        2. LANGGRAPH_API_KEY (if api_key not provided)
        3. LANGSMITH_API_KEY (if api_key not provided)
        4. LANGCHAIN_API_KEY (if api_key not provided)

    Args:
        api_key: The API key to use. Can be:
            - A string: use this exact API key
            - None: explicitly skip loading from environment
            - NOT_PROVIDED (default): auto-load from environment variables
    )	LANGGRAPH	LANGSMITH	LANGCHAIN_API_KEY"'N)
isinstancestrNOT_PROVIDEDosgetenvstrip)api_keyprefixenvs      ^/var/www/html/backtest/airagagent/rag_env/lib/python3.12/site-packages/langgraph_sdk/client.py_get_api_keyrP   X   sl     '3,= 	9Fii6(( 344s4yy{((-33C88	9     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 'rE   z
User-Agentzlanggraph-sdk-py/r>   )RESERVED_HEADERS
ValueErrorlanggraph_sdk__version__rP   )rL   custom_headersheaderheadersresolved_api_keys        rO   _get_headersr[   q   s    
 $)rN" G^#;F81EFFG
 	)-*C*C)DE
G $G,/NrQ   c                   t        | t              }t        | d      r8t        | j                        r#|rt        d| d|       | j	                         S t        | d      r8t        | j                        r#|rt        d| d|       | j                         S t        | t        t        f      rt        |       S t        dt        |        d      )N
model_dumpz#Cannot JSON-serialize type object: zI. Did you mean to pass an instance of the object instead?
Received type: dictzObject of type z is not JSON serializable)
rF   typehasattrcallabler]   	TypeErrorr^   set	frozensetlist)objis_classs     rO   _orjson_defaultrh      s    #t$HsL!hs~~&>5cW =$$'7,  ~~	f	(388"45cW =$$'7,  xxz	C#y)	*Cy/$s)4MNOOrQ   z5(\/threads\/(?P<thread_id>.+))?\/runs\/(?P<run_id>.+)c                    | j                   j                  d      x}rFt        j                  |      x}r/t	        |j                  d      |j                  d      xs d      S y)z/Extract run metadata from the response headers.zContent-Locationrun_id	thread_idN)rj   rk   )rY   get_RUN_METADATA_PATTERNsearchr,   group)responsecontent_locationmatchs      rO   _get_run_metadata_from_responsers      sh     %,,001CDDD&--.>??? ;;x(kk+.6$
 	

 rQ   )urlrL   rY   timeoutLangGraphClientc           
     V   d}| ed} t         j                  j                  d      dk(  r( t               dd      }t        j                  |       n	 ddlm}  t               |d	      }|t        j                  d      }t        j                  | ||t        j                  |      nt        j                  dddd      t        ||            }t!        |      S # t        $ rA t        j                  d
d        t               dd      }t        j                  |       Y w xY w)a
  Create and configure a LangGraphClient.

    The client provides programmatic access to LangSmith Deployment. It supports
    both remote servers and local in-process connections (when running inside a LangGraph server).

    Args:
        url:
            Base URL of the LangGraph API.
            - If `None`, the client first attempts an in-process connection via ASGI transport.
              If that fails, it defers registration until after app initialization. This
              only works if the client is used from within the Agent server.
        api_key:
            API key for authentication. Can be:
              - A string: use this exact API key
              - `None`: explicitly skip loading from environment variables
              - Not provided (default): auto-load from environment in this order:
                1. `LANGGRAPH_API_KEY`
                2. `LANGSMITH_API_KEY`
                3. `LANGCHAIN_API_KEY`
        headers:
            Additional HTTP headers to include in requests. Merged with authentication headers.
        timeout:
            HTTP timeout configuration. May be:
              - `httpx.Timeout` instance
              - float (total seconds)
              - tuple `(connect, read, write, pool)` in seconds
            Defaults: connect=5, read=300, write=300, pool=5.

    Returns:
        LangGraphClient:
            A top-level client exposing sub-clients for assistants, threads,
            runs, and cron operations.

    ???+ example "Connect to a remote server:"

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

    ???+ example "Connect in-process to a running LangGraph server:"

        ```python
        from langgraph_sdk import get_client

        client = get_client(url=None)

        async def my_node(...):
            subagent_result = await client.runs.wait(
                thread_id=None,
                assistant_id="agent",
                input={"messages": [{"role": "user", "content": "Foo"}]},
            )
        ```

    ???+ example "Skip auto-loading API key from environment:"

        ```python
        from langgraph_sdk import get_client

        # Don't load API key from environment variables
        client = get_client(
            url="http://localhost:8123",
            api_key=None
        )
        ```
    Nz
http://api$__LANGGRAPH_DEFER_LOOPBACK_TRANSPORTtruez/noauth)app	root_pathr   )rz   )r{   zJFailed to connect to in-process LangGraph server. Deferring configuration.Texc_info   retries,  connectreadwritepoolbase_url	transportru   rY   )rI   environrl   get_asgi_transport_registered_transportsappendlanggraph_api.serverrz   	ExceptionloggerdebughttpxAsyncHTTPTransportAsyncClientTimeoutr[   rv   )rt   rL   rY   ru   r   rz   clients          rO   
get_clientr      s   ` 26I
{::>>@AVK,*,KI")))4
940.0	J	 ,,Q7	 " MM'"qs#AFWg.	F 6"")  9`!   1.0TYO	&--i89s   C AD('D(c                  @    e Zd ZdZddZddZ	 	 	 	 	 	 	 	 d	dZd
dZy)rv   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selfr   s     rO   __init__zLangGraphClient.__init__.  s^    v&	*4995$TYY/tyy)			*
 +
rQ   c                   K   | S w)z Enter the async context manager. r   s    rO   
__aenter__zLangGraphClient.__aenter__6  s     s   c                @   K   | j                          d{    y7 w)zExit the async context manager.N)acloser   exc_typeexc_valexc_tbs       rO   	__aexit__zLangGraphClient.__aexit__:  s      kkms   c                   K   t        | d      r-| j                  j                  j                          d{    yy7 wz!Close the underlying HTTP client.r   N)r`   r   r   r   r   s    rO   r   zLangGraphClient.acloseC  s4     4 ))""))+++ !+s   4?=?Nr   zhttpx.AsyncClientreturnNone)r   rv   r   ztype[BaseException] | Noner   zBaseException | Noner   zTracebackType | Noner   r   r   r   )__name__
__module____qualname____doc__r   r   r   r   r   rQ   rO   rv   rv   #  sA    ,, & %	
 
,rQ   c                  @   e Zd ZdZddZdddd	 	 	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 	 	 	 	 ddZdd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
d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   r   r   s     rO   r   zHttpClient.__init__S  	    rQ   NparamsrY   on_responsec                  K   | j                   j                  |||       d{   }|r ||       t        |       d{    t        |       d{   S 7 47 7 w)Send a `GET` request.r   rY   N)r   rl   r   _adecode_jsonr   pathr   rY   r   rs         rO   rl   zHttpClient.getV  sY      ++//$vw/GGN&q)))"1%%%	 H 	*%s3   "AAAAAAAAAc               (  K   |t        |       d{   \  }}ni d}}|r|j                  |       | j                  j                  ||||       d{   }|r ||       t	        |       d{    t        |       d{   S 7 v7 67 7 
w)Send a `POST` request.NrQ   rY   contentr   )_aencode_jsonupdater   postr   r   	r   r   jsonr   rY   r   request_headersr   r   s	            rO   r   zHttpClient.poste  s      -:4-@'@$OW')3WO""7+++""/76 # 
 
 N&q)))"1%%% (A

 	*%sF   BB
ABBB2B3BBBBBBc                 K   t        |       d{   \  }}|r|j                  |       | j                  j                  ||||       d{   }|r ||       t	        |       d{    t        |       d{   S 7 q7 67 7 
w)Send a `PUT` request.Nr   )r   r   r   putr   r   r   s	            rO   r   zHttpClient.put~  s      *7t)<#< ""7+++///76 " 
 
 N&q)))"1%%% $=

 	*%E   BB<BBB+B,B>B	?BBB	Bc                 K   t        |       d{   \  }}|r|j                  |       | j                  j                  ||||       d{   }|r ||       t	        |       d{    t        |       d{   S 7 q7 67 7 
w)Send a `PATCH` request.Nr   )r   r   r   patchr   r   r   s	            rO   r   zHttpClient.patch  s      *7t)<#< ""7+++##/76 $ 
 
 N&q)))"1%%% $=

 	*%r   r   r   rY   r   c                  K   | j                   j                  d||||       d{   }|r ||       t        |       d{    y7 "7 wzSend a `DELETE` request.DELETEr   r   rY   N)r   requestr   r   r   r   r   rY   r   r   s          rO   deletezHttpClient.delete  sV      ++%%dfg & 
 
 N&q)))

 	*s!   $AA	AAAAr~   r   r   rY   r   reconnect_limitc          	       K   t        |       d{   \  }}	|r|j                  |       | j                  j                  ||||	|      4 d{   }
|r ||
       	 |
j	                          |
j                  j                  d      }|dk  s|s$t!        |
       d{   cddd      d{    S 	 t!        |
       d{   cddd      d{    S 7 7 # t
        j                  $ rn}|
j                          d{  7  j                         }t        j                  dk\  r|j                  |       |t        j                  d| |       |d}~ww xY w7 7 7 7 # t
        j"                  $ ri t%        j&                  d| d	
       |
j)                          d{  7   | j+                  |d||dz
         d{  7  cY cddd      d{  7   S w xY w# 1 d{  7  sw Y   yxY ww)@Send a request that automatically reconnects to Location header.Nr         Error from langgraph-api: r|   locationr   2Request failed, attempting reconnect to Location:    
stacklevelGET   rY   r   )r   r   r   streamraise_for_statusr   HTTPStatusErrorareaddecodesysversion_infoadd_noter   errorrY   rl   r   	HTTPErrorwarningswarnr   request_reconnectr   r   methodr   r   rY   r   r   r   r   r   ebodylocs                 rO   r  zHttpClient.request_reconnect  s     *7t)<#< ""7+;;%%D/76 & 
 	 	A""$ ))--
+C!#3*1--!	 	 	"*1--%	 	 	 $=	 (( ggi//1##w.JJt$  LL#=dV!DqLQ .!	$ .%	& ?? HN  hhj  !33+$3a$7 4    3	 	 	&'	 	 	s  G?C>G?CG?G* C00G* E#!G*$G?0E%1G?7E+E'E+	G?E)G?G?E 2EDAEE  G*%G?'E+)G?+A G'+F., G'GG'G*G?G" G?&G''G**G<0G31G<8G?c              :  K   t        |       d{   \  }}d|d<   d|d<   |r|j                  |       |j                         D 	
ci c]  \  }	}
|	j                         dvr|	|
 }}	}
d}d}d}d}	 t	        ||n|      }|||d
<   ||nd}||nd}||nd}d}| j
                  j                  ||xs ||||      4 d{   }|
|r ||       t        |       d{    |j                  j                  dd      j                  d      d   }d|vrt        j                  d|      |j                  j                  d      }|r|}t               }	 t        |      2 3 d{   }|j                  t!        d|      j#                  d            }|7|j$                  |j$                  }|j&                  s|j(                  h| n7 c c}
}	w 7 7 7 w6 	 |j                  d      x}rT|j$                  |j$                  }|j&                  s|j(                  $| n# t        j*                  $ r | d	}Y nw xY wddd      d{  7   n# 1 d{  7  sw Y   nxY w|r!|dz  }||kD  rt        j                  d      'yw)zStream results using SSE.Ntext/event-streamAcceptno-storeCache-Control   content-lengthcontent-typer   r~   TLast-Event-IDr   Fr   r   ;JExpected response header Content-Type to contain 'text/event-stream', got r   bytes   
)linerQ   r   *Exceeded maximum SSE reconnection attempts)r   r   itemslowerr^   r   r   r   rY   rl   	partitionr   TransportErrorr;   r<   r   r   rstriplast_event_ideventdatar   r   r   r  r   r   rY   r   r   r   keyvaluereconnect_headersr  reconnect_pathreconnect_attemptsmax_reconnect_attemptscurrent_headerscurrent_methodcurrent_contentcurrent_paramsretryrescontent_typereconnect_locationdecoderr  sses                              rO   r   zHttpClient.stream  s      *7t)<#< $7!+5(""7+ .335
Uyy{"DD J
 
 %)%)!""#1#9?PO (3@0'5'=V5N)7)?gTO'5'=V4NE{{))&$''% *  0& 0& !)k$.s333"{{~rBLLSQRST&l:..+.0 
 &)[[__Z%@"%%7N %,&&5c&: * *d%nn$w2E2L2LU2SnT?&44@070E0E"yyCHH,@&)	} $=
.0& 4 *&: &nnS11s1"00<,3,A,AM99(<
 #&I  ! &- E!C0& 0& 0& 0& 0&b "a'"%(>>..D  s   JG7J	G(AJG J
I"%G#&A7I"H2)G'-G%.G'1.H2 0H2H2JJ#I"%G''H2)A	I"2I
I"II"JIJ"I4(I+)I40+Jr   
r   rG   r   QueryParamTypes | NonerY   Mapping[str, str] | Noner   'Callable[[httpx.Response], None] | Noner   r
   r   rG   r   zdict[str, Any] | list | Noner   r3  rY   r4  r   r5  r   r
   r   rG   r   r^   r   r3  rY   r4  r   r5  r   r
   r   rG   r   z
Any | Noner   r3  rY   r4  r   r5  r   r   r   rG   r  rG   r   dict[str, Any] | Noner   r3  rY   r4  r   r5  r   intr   r
   )r   rG   r  rG   r   r:  r   r3  rY   r4  r   r5  r   AsyncIterator[StreamPart]r   r   r   r   r   rl   r   r   r   r   r  r   r   rQ   rO   r   r   I  s;    *.,0?C&& '	&
 *& =& 
&( *.,0?C&& +	&
 '& *& =& 
&< *.,0?C&& 	&
 '& *& =& 
&4 *.,0?C&& 	&
 '& *& =& 
&2  )-,0?C** 	*
 '* ** =* 
*, '+)-,0?C .. .
 $. '. *. =. . 
.j '+)-,0?Caa a
 $a 'a *a =a 
#arQ   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dumpsrh   OPT_SERIALIZE_NUMPYOPT_NON_STR_KEYSrG   lenr   r  content_lengthr.  rY   s        rO   r   r   M  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@  rA  rB  rC  loadsr   r  s     rO   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dZdddd	 	 	 	 	 	 	 	 	 ddZddd	 	 	 	 	 	 	 dd	Z	 	 d ddd	 	 	 	 	 	 	 	 	 	 	 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Z
ddd	 	 	 	 	 	 	 d%dZe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       Zdddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(dZdddddd	 	 	 	 	 	 	 	 	 	 	 d)dZ	 	 	 d*ddd	 	 	 	 	 	 	 	 	 	 	 	 	 d+dZd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     rO   r   zAssistantsClient.__init__t  	    	rQ   NrY   r   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.
            params: Optional query parameters 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/rR  Nr   rl   r   assistant_idrY   r   s       rO   rl   zAssistantsClient.getw  s;     R YY]]<.)76 # 
 
 	
 
   %.,.FxrayrY   r   c                  K   d|i}|r|j                  |       | j                  j                  d| d||       d{   S 7 w)aI  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.
            params: Optional query parameters 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__'}
                    ]
            }
            ```


        rZ  rT  /graphr   Nr   r   rl   r   rW  rZ  rY   r   query_paramss         rO   	get_graphzAssistantsClient.get_graph  sW     d ~'YY]]<./g # 
 
 	
 
s   =AA Ac               b   K   | j                   j                  d| d||       d{   S 7 w)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.
            params: Optional query parameters 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']
                                    }
                            }
                    },
                'context_schema':
                    {
                        'title': 'Context',
                        'type': 'object',
                        'properties':
                            {
                                'model_name':
                                    {
                                        'title': 'Model Name',
                                        'enum': ['anthropic', 'openai'],
                                        'type': 'string'
                                    }
                            }
                    }
            }
            ```

        rT  /schemasrR  NrU  rV  s       rO   get_schemaszAssistantsClient.get_schemas  s=     j YY]]<.176 # 
 
 	
 
s   &/-/c                  K   d|i}|ri ||}|,| j                   j                  d| d| ||       d{   S | j                   j                  d| d||       d{   S 7 .7 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.
            params: Optional query parameters to include with the request.

        Returns:
            Subgraphs: The graph schema for the assistant.

        recurseNrT  /subgraphs/r   
/subgraphsrU  r   rW  	namespacere  rY   r   
get_paramss          rO   get_subgraphszAssistantsClient.get_subgraphsW  s     ,  )
1J1&1J |nK	{C! '    |nJ7! '   s!   6A+A')A+"A)#A+)A+contextmetadatarW  	if_existsnamerY   descriptionr   c                  K   d|i}|r||d<   |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.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            assistant_id: Assistant ID to use, will default to a random UUID if not provided.
            if_exists: How to handle duplicate creation. Defaults to 'raise' under the hood.
                Must be either 'raise' (raise error if duplicate), or 'do_nothing' (return existing assistant).
            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
            params: Optional query parameters to include with the request.

        Returns:
            Assistant: The created assistant.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            assistant = await client.assistants.create(
                graph_id="agent",
                context={"model_name": "openai"},
                metadata={"number":1},
                assistant_id="my-assistant-id",
                if_exists="do_nothing",
                name="my_name"
            )
            ```
        graph_idconfigrm  rn  rW  ro  rp  rq  /assistantsr   rY   r   Nr   r   r   rs  rt  rm  rn  rW  ro  rp  rY   rq  r   payloads               rO   createzAssistantsClient.create}  s     f #
  &GH!(GI"*GJ&2GN##,GK "GFO%0GM"YY^^ $ 
 
 	
 
s   AA!AA!rs  rt  rm  rn  rp  rY   rq  r   c                  K   i }
|r||
d<   |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.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            metadata: Metadata to merge with existing assistant metadata.
            name: The new name for the assistant.
            headers: Optional custom headers to include with the request.
            description: Optional description of the assistant.
                The description field is available for langgraph-api server version>=0.0.45
            params: Optional query parameters to include with the request.

        Returns:
            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",
                context={"model_name": "anthropic"},
                metadata={"number":2}
            )
            ```

        rs  rt  rm  rn  rp  rq  rT  rv  Nr   r   r   rW  rs  rt  rm  rn  rp  rY   rq  r   ry  s              rO   r   zAssistantsClient.update  s     ^ #%"*GJ &GH!(GI"*GJ"GFO%0GM"YY__<.)	 % 
 
 	
 
s   AAAAc               b   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.
            params: Optional query parameters 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"
            )
            ```

        rT  rR  Nr   r   rV  s       rO   r   zAssistantsClient.delete  s7     6 ii<.)76  
 	
 	
   %/-/
   r   
rn  rs  rp  limitoffsetsort_by
sort_orderselectrY   r   c                  K   y wr   r   r   rn  rs  rp  r  r  r  r  r  response_formatrY   r   s               rO   rn   zAssistantsClient.search&  s      $'   arrayrn  rs  rp  r  r  r  r  r  r  rY   r   c                  K   y wr   r   r  s               rO   rn   zAssistantsClient.search7  s      r  c               B  K   |	dvrt        d|	      ||d}|r||d<   |r||d<   |r||d<   |r||d<   |r||d<   |r||d	<   d
dfd}t        t        t           | j                  j                  d||
||	dk(  r|nd
       d
{         }|	dk(  r|dS |S 7 w)as  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.
            name: The name of the assistant to filter by.
                The filtering logic will match assistants where 'name' is a substring (case insensitive) of the assistant name.
            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.
            select: Specific assistant fields to include in the response.
            response_format: Controls the response shape. Use ``"array"`` (default)
                to return a bare list of assistants, or ``"object"`` to return
                a mapping containing assistants plus pagination metadata.
                Defaults to "array", though this default will be changed to "object" in a future release.
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        Returns:
            A list of assistants (when ``response_format="array"``) or a mapping
            with the assistants and the next pagination cursor (when
            ``response_format="object"``).

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            response = await client.assistants.search(
                metadata = {"name":"my_name"},
                graph_id="my_graph_id",
                limit=5,
                offset=5,
                response_format="object"
            )
            next_cursor = response["next"]
            assistants = response["assistants"]
            ```
        r  objectz1response_format must be 'array' or 'object', got r  r  rn  rs  rp  r  r  r  Nc                <    | j                   j                  d      y NzX-Pagination-NextrY   rl   rp   next_cursors    rO   capture_paginationz3AssistantsClient.search.<locals>.capture_pagination      "**../BCKrQ   /assistants/searchr  r   rY   r   r   r   nextrp   httpx.Responser   r   rT   r   re   r   r   r   r   rn  rs  rp  r  r  r  r  r  r  rY   r   ry  r  r   r  s                  @rO   rn   zAssistantsClient.searchH  s     n "55COCVW  #
 "*GJ"*GJ"GFO!(GI$.GL! &GH"&	D O))..$2AX2M.SW !  	

 h&",kBBs   BBB
	Brn  rs  rp  rY   r   c                  K   i }|r||d<   |r||d<   |r||d<   | j                   j                  d|||       d{   S 7 w)O  Count assistants matching filters.

        Args:
            metadata: Metadata to filter by. Exact match for each key/value.
            graph_id: Optional graph id to filter by.
            name: Optional name to filter by.
                The filtering logic will match assistants where 'name' is a substring (case insensitive) of the assistant name.
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        Returns:
            int: Number of assistants matching the criteria.
        rn  rs  rp  /assistants/countrv  Nrw  r   rn  rs  rp  rY   r   ry  s          rO   countzAssistantsClient.count  s`     , #%"*GJ"*GJ"GFOYY^^gwv $ 
 
 	
 
   :AAAc               |   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.
            params: Optional query parameters to include with the request.

        Returns:
            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"
            )
            ```
        r  rn  rT  	/versionsrv  Nrw  r   rW  rn  r  r  rY   r   ry  s           rO   get_versionszAssistantsClient.get_versions  s^     D #
 "*GJYY^^<.	2	 $ 
 
 	
 
   3<:<c               l   K   d|i}| j                   j                  d| d|||       d{   S 7 w)a  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.
            params: Optional query parameters to include with the request.

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

        versionrT  /latestrv  Nrw  r   rW  r  rY   r   ry  s         rO   
set_latestzAssistantsClient.set_latest  sK     > $-g"6YY^^<.0	 $ 
 
 	
 
s   +424r   r   r   r   rW  rG   rY   r4  r   r3  r   r   
rW  rG   rZ  z
int | boolrY   r4  r   r3  r   zdict[str, list[dict[str, Any]]]rW  rG   rY   r4  r   r3  r   r    NFrW  rG   ri  
str | Nonere  boolrY   r4  r   r3  r   r3   r   rs  r  rt  Config | Nonerm  Context | Nonern  r$   rW  r  ro  OnConflictBehavior | Nonerp  r  rY   r4  rq  r  r   r3  r   r   rW  rG   rs  r  rt  r  rm  r  rn  r$   rp  r  rY   r4  rq  r  r   r3  r   r   rW  rG   rY   r4  r   r3  r   r   rn  r$   rs  r  rp  r  r  r;  r  r;  r  AssistantSortBy | Noner  SortOrder | Noner  !list[AssistantSelectField] | Noner  zLiteral['object']rY   r4  r   r3  r   r   rn  r$   rs  r  rp  r  r  r;  r  r;  r  r  r  r  r  r  r  zLiteral['array']rY   r4  r   r3  r   zlist[Assistant]rn  r$   rs  r  rp  r  r  r;  r  r;  r  r  r  r  r  r  r  zLiteral['array', 'object']rY   r4  r   r3  r   z*AssistantsSearchResponse | list[Assistant]rn  r$   rs  r  rp  r  rY   r4  r   r3  r   r;  Nr  r   rW  rG   rn  r$   r  r;  r  r;  rY   r4  r   r3  r   zlist[AssistantVersion]
rW  rG   r  r;  rY   r4  r   r3  r   r   r   r   r   r   r   rl   r`  rc  rk  rz  r   r   r   rn   r  r  r  r   rQ   rO   r   r   f  sm    -1)-+
+
 *	+

 '+
 
+
b !,0)-8
8
 	8

 *8
 '8
 
)8
| -1)-w
w
 *	w

 'w
 
w
x !%	$ -1)-$$ $ 	$ *$ '$ 
$R !%E

 #'#'/3,0"&)-E
E
 E

  E
 E
 !E
 -E
 E
 *E
  E
 'E
 
E
V  $ $"&,0"&)-A
A
 	A

 A
  A
 A
 A
 *A
  A
 'A
 
A
N -1)-

 *	

 '
 

>  #*.'+48,0)-' ' 	'
 ' ' ' (' %' 2' +' *' '' 
"' '   #*.'+48,3,0)-  	
    ( % 2 * * ' 
 & #*.'+486=,0)-] ] 	]
 ] ] ] (] %] 2] 4] *] '] 
4]D #,0)-
 
 	

 
 *
 '
 

H ,
 -1)-,
,
 ,
 	,

 ,
 *,
 ',
 
 ,
f -1)-&
&
 &

 *&
 '&
 
&
rQ   r   c                     e Zd ZdZddZddd	 	 	 	 	 	 	 ddZddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 	 	 	 	 dd	Zddd	 	 	 	 	 	 	 d d
Zdddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d!dZ	dddddd	 	 	 	 	 	 	 	 	 	 	 d"dZ
ddd	 	 	 	 	 	 	 d dZ	 	 d#dddd	 	 	 	 	 	 	 	 	 	 	 	 	 d$dZdddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%dZddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d&dZ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   rO  rP  s     rO   r   zThreadsClient.__init__.  rQ  rQ   NrR  c               `   K   | j                   j                  d| ||       d{   S 7 w)a  Get a thread by ID.

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

        Returns:
            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/rR  NrU  r   rk   rY   r   s       rO   rl   zThreadsClient.get1  s;     P YY]]	{#WV # 
 
 	
 
rX  rn  rk   ro  
superstepsrs  ttlrY   r   c                 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
<   |$t        |t        t        f      r	|dd|	d<   n||	d<   | j                  j                  d|	||       d{   S c c}w c c}}
w 7 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.
            ttl: Optional time-to-live in minutes for the thread. You can pass an
                integer (minutes) or a mapping with keys `ttl` and optional
                `strategy` (defaults to "delete").
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        Returns:
            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"
            )
            ```
        rk   rs  rn  ro  updatesvaluescommandas_noder  r  r  r  Nr   r  strategyr  /threadsrv  rl   rF   r;  floatr   r   r   rn  rk   ro  r  rs  r  rY   r   ry  sus               rO   rz  zThreadsClient.create]  s    V #%#,GK x#>r#-5J)2#GJ #,GK  $%   "#9  	 '(k'(uuY'7'(| 	%GL! ?#U|,),(!C!$YY^^Wgf $ 
 
 	
# %&
s4   /CB?"B: B?&AC5C6C:B??Cr  rY   r   c                  K   d|i}|$t        |t        t        f      r	|dd|d<   n||d<   | j                  j	                  d| |||       d{   S 7 w)am  Update a thread.

        Args:
            thread_id: ID of thread to update.
            metadata: Metadata to merge with existing thread metadata.
            ttl: Optional time-to-live in minutes for the thread. You can pass an
                integer (minutes) or a mapping with keys `ttl` and optional
                `strategy` (defaults to "delete").
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        Returns:
            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},
                ttl=43_200,
            )
            ```
        rn  Nr   r  r  r  rv  rF   r;  r  r   r   r   rk   rn  r  rY   r   ry  s          rO   r   zThreadsClient.update  st     D $.x"8?#U|,),(!C!$YY__	{#	 % 
 
 	
 
s   AAAAc               b   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.
            params: Optional query parameters 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"
            )
            ```

        r  rR  Nr  r  s       rO   r   zThreadsClient.delete  s/     6 ii9+6PVWWWr  r  r   rn  r  idsstatusr  r  r  r  r  rY   r   c                  K   ||d}|r||d<   |r||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.
            ids: List of thread IDs to filter by.
            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.
            params: Optional query parameters to include with the request.

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

        r  rn  r  r  r  r  r  r  /threads/searchrv  Nrw  r   rn  r  r  r  r  r  r  r  r  rY   r   ry  s                rO   rn   zThreadsClient.search  s     ^ #
 "*GJ &GH GEN &GH!(GI$.GL! &GHYY^^	 $ 
 
 	
 
s   AA"A A"rn  r  r  rY   r   c                  K   i }|r||d<   |r||d<   |r||d<   | j                   j                  d|||       d{   S 7 w)  Count threads matching filters.

        Args:
            metadata: Thread metadata to filter on.
            values: State values to filter on.
            status: Thread status to filter on.
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        Returns:
            int: Number of threads matching the criteria.
        rn  r  r  /threads/countrv  Nrw  r   rn  r  r  rY   r   ry  s          rO   r  zThreadsClient.count=  sa     * #%"*GJ &GH &GHYY^^7GF $ 
 
 	
 
r  c               d   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.
            params: Optional query parameters 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"
            )
            ```

        r  /copyNrv  rw  r  s       rO   copyzThreadsClient.copy]  s>     6 YY^^	{%(tWV $ 
 
 	
 
s   '0.0F	subgraphsrY   r   c               V  K   |r.| j                   j                  d| d||d||       d{   S |r8d|i}|ri ||}| j                   j                  d| d| ||       d{   S d|i}|ri ||}| j                   j                  d| d	||       d{   S 7 t7 <7 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.
            params: Optional query parameters to include with the request.

        Returns:
            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'
                    }
            }
            ```
        r  /state/checkpoint
checkpointr  rv  Nr  /state/r   /stater   r   rl   r   rk   r  checkpoint_idr  rY   r   rj  s           rO   	get_statezThreadsClient.get_state|  s     \ I;&78$.YG	 (    %y1J5
5f5
I;gm_=! '    &y1J5
5f5
I;f-! '   's3   ,B)B#9B)(B%)5B)B'B)%B)'B)r  r  r   rY   r   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.
            params: Optional query parameters to include with the request.

        Returns:
            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   r  r  r  r  rv  Nrw  	r   rk   r  r  r  r   rY   r   ry  s	            rO   update_statezThreadsClient.update_state  su     f f#
 '4GO$$.GL!!(GIYY^^	{&)QW $ 
 
 	
 
   A A	AA	r  beforern  r  rY   r   c                  K   d|i}|r||d<   |r||d<   |r||d<   | j                   j                  d| d|||       d{   S 7 w)	az  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.
            params: Optional query parameters to include with the request.

        Returns:
            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  rn  r  r  /historyrv  Nrw  	r   rk   r  r  rn  r  rY   r   ry  s	            rO   get_historyzThreadsClient.get_historyC  sw     J U#
  &GH"*GJ$.GL!YY^^	{(+	 $ 
 
 	
 
r  	run_modes)r  stream_moderY   r   c                  K   d|i}|r|j                  |       | j                  j                  d| ddi |rd|ini |xs i |      S w)a  Get a stream of events for a thread.

        Args:
            thread_id: The ID of the thread to get the stream for.
            last_event_id: The ID of the last event to get.
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        Returns:
            An iterator of stream parts.

        ???+ example "Example Usage"

            ```python

            for chunk in client.threads.join_stream(
                thread_id="my_thread_id",
                last_event_id="my_event_id",
            ):
                print(chunk)
            ```

        r  r  /streamr   r  rR  r   r   r   )r   rk   r  r  rY   r   r_  s          rO   join_streamzThreadsClient.join_streamw  sz     B ;
 'yy	{'*7DO]3"=b     
 	
s   A	Ar  rk   rG   rY   r4  r   r3  r   r4   rn  r$   rk   r  ro  r  r  z4Sequence[dict[str, Sequence[dict[str, Any]]]] | Noners  r  r  int | Mapping[str, Any] | NonerY   r4  r   r3  r   r4   rk   rG   rn  Mapping[str, Any]r  r  rY   r4  r   r3  r   r4   rk   rG   rY   r4  r   r3  r   r   rn  r$   r  r$   r  Sequence[str] | Noner  ThreadStatus | Noner  r;  r  r;  r  zThreadSortBy | Noner  r  r  zlist[ThreadSelectField] | NonerY   r4  r   r3  r   zlist[Thread]rn  r$   r  r$   r  r  rY   r4  r   r3  r   r;  NNrk   rG   r  Checkpoint | Noner   r  r  r  rY   r4  r   r3  r   r7   rk   rG   r  z&dict[str, Any] | Sequence[dict] | Noner  r  r  r  r   r  rY   r4  r   r3  r   r:   rk   rG   r  r;  r  zstr | Checkpoint | Nonern  Mapping[str, Any] | Noner  r  rY   r4  r   r3  r   zlist[ThreadState])rk   rG   r  r  r  -ThreadStreamMode | Sequence[ThreadStreamMode]rY   r4  r   r3  r   r<  r   r   r   r   r   rl   rz  r   r   rn   r  r  r  r  r  r  r   rQ   rO   r   r     s    -1)-*
*
 *	*

 '*
 
*
^  $/3KO#.2,0)-K
 K
 	K

 -K
 IK
 K
 ,K
 *K
 'K
 
K
d /3,0)--
-
 $	-

 ,-
 *-
 '-
 
-
f -1)-XX *	X
 'X 
X@ $(&*'+'+15,0)-E
 E
 	E

 "E
 $E
 E
 E
 %E
 %E
 /E
 *E
 'E
 
E
T &*,0)-
 
 	

 $
 *
 '
 

H -1)-

 *	

 '
 

D )-$(	F  ,0)-FF &F "	F F *F 'F 
FZ #(,$(,0)-=
=
 7=

 =
 &=
 "=
 *=
 '=
 
#=
F *.-1(,,0)-2
2
 	2

 (2
 +2
 &2
 *2
 '2
 
2
p %)EP,0)--
-
 "	-

 C-
 *-
 '-
 
#-
rQ   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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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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	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 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	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 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d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d-dZ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d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d/d       Z	eddd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dddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d1dZ	ddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d2dZ
ddd	 	 	 	 	 	 	 	 	 d3dZdd ddd!	 	 	 	 	 	 	 	 	 	 	 	 	 d4d"Zddd	 	 	 	 	 	 	 	 	 d5d#Zdddddd$	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d6d%Zddd	 	 	 	 	 	 	 	 	 d7d&Zy)8r   a  Client for managing runs in LangGraph.

    A run is a single assistant invocation with optional input, config, context, and metadata.
    This client manages runs, which can be stateful (on threads) or stateless.

    ???+ example "Example"

        ```python
        client = get_client(url="http://localhost:2024")
        run = await client.runs.create(assistant_id="asst_123", thread_id="thread_456", input={"query": "Hello"})
        ```
    c                    || _         y r   rO  rP  s     rO   r   zRunsClient.__init__  rQ  rQ   Nr  F)inputr  r  stream_subgraphsstream_resumablern  rt  rm  r  r   checkpoint_duringinterrupt_beforeinterrupt_afterfeedback_keyson_disconnectwebhookmultitask_strategyif_not_existsafter_secondsrY   r   on_run_createdc                    y r   r   )r   rk   rW  r'  r  r  r(  r)  rn  rt  rm  r  r   r*  r+  r,  r-  r.  r/  r0  r1  r2  rY   r   r3  s                            rO   r   zRunsClient.stream  s    8 %(rQ   )r'  r  r  r(  r)  rn  rt  r*  r+  r,  r-  r.  on_completionr1  r/  r2  rY   r   r3  c                    y r   r   )r   rk   rW  r'  r  r  r(  r)  rn  rt  r*  r+  r,  r-  r.  r5  r1  r/  r2  rY   r   r3  s                         rO   r   zRunsClient.stream  s    2 %(rQ   r'  r  r  r(  r)  rn  rt  rm  r  r   r*  r+  r,  r-  r.  r5  r/  r0  r1  r2  rY   r   r3  
durabilityc          
        |t        j                  dt        d       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}dfd}| j                  j                  |d|j                         D ci c]  \  }}|	|| c}}||r|      S d      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: A command to execute. Cannot be combined with input.
            stream_mode: The stream mode(s) to use.
            stream_subgraphs: Whether to stream output from subgraphs.
            stream_resumable: Whether the stream is considered resumable.
                If true, the stream can be resumed and replayed in its entirety even after disconnection.
            metadata: Metadata to assign to the run.
            config: The configuration for the assistant.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            checkpoint: The checkpoint to resume from.
            checkpoint_during: (deprecated) Whether to checkpoint during the run (or only at the end/interruption).
            interrupt_before: Nodes to interrupt immediately before they get executed.
            interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
            feedback_keys: Feedback keys to assign to run.
            on_disconnect: The disconnect mode to use.
                Must be one of 'cancel' or 'continue'.
            on_completion: Whether to delete or keep the thread created for a stateless run.
                Must be one of 'delete' or 'keep'.
            webhook: Webhook to call after LangGraph API call is done.
            multitask_strategy: Multitask strategy to use.
                Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
            if_not_exists: How to handle missing thread. Defaults to 'reject'.
                Must be either 'reject' (raise error if missing), or 'create' (create new thread).
            after_seconds: The number of seconds to wait before starting the run.
                Use to schedule future runs.
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.
            on_run_created: Callback when a run is created.
            durability: The durability to use for the run. Values are "sync", "async", or "exit".
                "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
                "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
                "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps

        Returns:
            Asynchronous iterator of stream results.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024)
            async for chunk in client.runs.stream(
                thread_id=None,
                assistant_id="agent",
                input={"messages": [{"role": "user", "content": "how are you?"}]},
                stream_mode=["values","debug"],
                metadata={"name":"my_run"},
                context={"model_name": "anthropic"},
                interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
                interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
                feedback_keys=["my_feedback_key_1","my_feedback_key_2"],
                webhook="https://my.fake.webhook.com",
                multitask_strategy="interrupt"
            ):
                print(chunk)
            ```

            ```shell

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

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

        Nd`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.r   r   r'  r  rt  rm  rn  r  r(  r)  rW  r+  r,  r-  r/  r  r   r*  r0  r1  r.  r5  r2  r8  r  /runs/streamc                8    rt        |       x}r	 |       yyyz)Callback function to handle the response.Nrs   r-  rn  r3  s     rO   r   z&RunsClient.stream.<locals>.on_response  &    /Ns/S#S8#Sx( $T~rQ   POSTr   r-  r  r  r  DeprecationWarningr  r   r    r   rk   rW  r'  r  r  r(  r)  rn  rt  rm  r  r   r*  r+  r,  r-  r.  r5  r/  r0  r1  r2  rY   r   r3  r8  kvry  endpointr   s                             `      rO   r   zRunsClient.stream  s   R (MMv"
U
GN'--/C$!QQ]ACTX

 f
 w
 
 ;
  0
  0
 L
  0
 
 ]
 w
  *!
" ]#
$  !2%
& !"4'
( +***$1
8 $ 	{,/ 		)
 yy#*==?D41aam!Q$D'5   
 	
 <@   
 	
E DJ E   
C%
C%
 
C+C+)r'  r  r  r(  r)  rn  r*  rt  rm  r+  r,  r/  r5  r1  r2  rY   r   r3  c                  K   y wr   r   )r   rk   rW  r'  r  r  r(  r)  rn  r*  rt  rm  r+  r,  r/  r5  r1  r2  rY   r   r3  s                        rO   rz  zRunsClient.create  s     0 r  r'  r  r  r(  r)  rn  rt  rm  r  r   r*  r+  r,  r/  r0  r1  r2  rY   r   r3  c                  K   y wr   r   r   rk   rW  r'  r  r  r(  r)  rn  rt  rm  r  r   r*  r+  r,  r/  r0  r1  r2  rY   r   r3  s                          rO   rz  zRunsClient.create  s     4 r  r'  r  r  r(  r)  rn  rt  rm  r  r   r*  r+  r,  r/  r0  r1  r5  r2  rY   r   r3  r8  c                 K   |t        j                  dt        d       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}|j                         D ci c]  \  }}|	|| }}}dfd}| j                  j                  |rd| dnd|||r|nd       d{   S c c}}w c c}}w 7 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.
            stream_resumable: Whether the stream is considered resumable.
                If true, the stream can be resumed and replayed in its entirety even after disconnection.
            metadata: Metadata to assign to the run.
            config: The configuration for the assistant.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            checkpoint: The checkpoint to resume from.
            checkpoint_during: (deprecated) Whether to checkpoint during the run (or only at the end/interruption).
            interrupt_before: Nodes to interrupt immediately before they get executed.
            interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
            webhook: Webhook to call after LangGraph API call is done.
            multitask_strategy: Multitask strategy to use.
                Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
            on_completion: Whether to delete or keep the thread created for a stateless run.
                Must be one of 'delete' or 'keep'.
            if_not_exists: How to handle missing thread. Defaults to 'reject'.
                Must be either 'reject' (raise error if missing), or 'create' (create new thread).
            after_seconds: The number of seconds to wait before starting the run.
                Use to schedule future runs.
            headers: Optional custom headers to include with the request.
            on_run_created: Optional callback to call when a run is created.
            durability: The durability to use for the run. Values are "sync", "async", or "exit".
                "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
                "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
                "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps

        Returns:
            The created background run.

        ???+ example "Example Usage"

            ```python

            background_run = await client.runs.create(
                thread_id="my_thread_id",
                assistant_id="my_assistant_id",
                input={"messages": [{"role": "user", "content": "hello!"}]},
                metadata={"name":"my_run"},
                context={"model_name": "openai"},
                interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
                interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
                webhook="https://my.fake.webhook.com",
                multitask_strategy="interrupt"
            )
            print(background_run)
            ```

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

            {
                'run_id': 'my_run_id',
                'thread_id': 'my_thread_id',
                'assistant_id': 'my_assistant_id',
                'created_at': '2024-07-25T15:35:42.598503+00:00',
                'updated_at': '2024-07-25T15:35:42.598503+00:00',
                'metadata': {},
                'status': 'pending',
                'kwargs':
                    {
                        'input':
                            {
                                'messages': [
                                    {
                                        'role': 'user',
                                        'content': 'how are you?'
                                    }
                                ]
                            },
                        'config':
                            {
                                'metadata':
                                    {
                                        'created_by': 'system'
                                    },
                                'configurable':
                                    {
                                        'run_id': 'my_run_id',
                                        'user_id': None,
                                        'graph_id': 'agent',
                                        'thread_id': 'my_thread_id',
                                        'checkpoint_id': None,
                                        'assistant_id': 'my_assistant_id'
                                    },
                            },
                        'context':
                            {
                                'model_name': 'openai'
                            }
                        'webhook': "https://my.fake.webhook.com",
                        'temporary': False,
                        'stream_mode': ['values'],
                        'feedback_keys': None,
                        'interrupt_after': ["node_to_stop_after_1","node_to_stop_after_2"],
                        'interrupt_before': ["node_to_stop_before_1","node_to_stop_before_2"]
                    },
                'multitask_strategy': 'interrupt'
            }
            ```
        Nr:  r   r   r'  r  r  r(  r)  rt  rm  rn  rW  r+  r,  r/  r  r   r*  r0  r1  r5  r2  r8  c                8    rt        |       x}r	 |       yyyr>  r?  r@  s     rO   r   z&RunsClient.create.<locals>.on_responsep	  rA  rQ   r  /runsr   rC  r  r  rE  r  r   r   r   rk   rW  r'  r  r  r(  r)  rn  rt  rm  r  r   r*  r+  r,  r/  r0  r1  r5  r2  rY   r   r3  r8  rG  rH  ry  r   s                          `     rO   rz  zRunsClient.create  s    V (MMv"

U
GN'--/C$!QQ]ACTX

 ;
  0
  0
 f
 w
 
 L
  0
 
 w
 *
  ]!
"  !2#
$ !"4%
& ]'
( +*$-
0 %,MMOEDAqq}1a4EE	)
 YY^^,5i	{%(7'54 $ 
 
 	
9 D* F
s5   9C4
C&
C&
AC4
C,$C,)8C4!C2"C4rR  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  ry  rG  rH  s      rO   filter_payloadz/RunsClient.create_batch.<locals>.filter_payload	  (    %,]]_FTQAqDFFF   
((/runs/batchrv  Nry  r+   rw  r   payloadsrY   r   r[  ry  filtereds          rO   create_batchzRunsClient.create_batch}	  sZ     	G <DDN7+DDYY^^'& $ 
 
 	
 E
s   	A
A$A
A
A
Tr'  r  rn  rt  rm  r  r   r*  r+  r,  r/  r.  r0  r1  r2  raise_errorrY   r   r3  c                  K   y wr   r   r   rk   rW  r'  r  rn  rt  rm  r  r   r*  r+  r,  r/  r.  r0  r1  r2  re  rY   r   r3  s                         rO   waitzRunsClient.wait	  s     2 '*r  r'  r  rn  rt  rm  r*  r+  r,  r/  r.  r5  r1  r2  re  rY   r   r3  c                  K   y wr   r   r   rk   rW  r'  r  rn  rt  rm  r*  r+  r,  r/  r.  r5  r1  r2  re  rY   r   r3  s                       rO   rh  zRunsClient.wait	  s     . '*r  )r'  r  rn  rt  rm  r  r   r*  r+  r,  r/  r.  r5  r0  r1  r2  re  rY   r   r3  r8  c          
       K   |
t        j                  dt        d       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|i}|d| dnd}d fd}| j                  j                  |d|j                         D ci c]  \  }}|	|| c}}||r|nd       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)!a  Create a run, wait until it finishes and return the final state.

        Args:
            thread_id: the thread ID to create the run on.
                If `None` will create a stateless run.
            assistant_id: The assistant ID or graph name to run.
                If using graph name, will default to first assistant created from that graph.
            input: The input to the graph.
            command: A command to execute. Cannot be combined with input.
            metadata: Metadata to assign to the run.
            config: The configuration for the assistant.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            checkpoint: The checkpoint to resume from.
            checkpoint_during: (deprecated) Whether to checkpoint during the run (or only at the end/interruption).
            interrupt_before: Nodes to interrupt immediately before they get executed.
            interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
            webhook: Webhook to call after LangGraph API call is done.
            on_disconnect: The disconnect mode to use.
                Must be one of 'cancel' or 'continue'.
            on_completion: Whether to delete or keep the thread created for a stateless run.
                Must be one of 'delete' or 'keep'.
            multitask_strategy: Multitask strategy to use.
                Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
            if_not_exists: How to handle missing thread. Defaults to 'reject'.
                Must be either 'reject' (raise error if missing), or 'create' (create new thread).
            after_seconds: The number of seconds to wait before starting the run.
                Use to schedule future runs.
            headers: Optional custom headers to include with the request.
            on_run_created: Optional callback to call when a run is created.
            durability: The durability to use for the run. Values are "sync", "async", or "exit".
                "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
                "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
                "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps

        Returns:
            The output of the run.

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            final_state_of_run = await client.runs.wait(
                thread_id=None,
                assistant_id="agent",
                input={"messages": [{"role": "user", "content": "how are you?"}]},
                metadata={"name":"my_run"},
                context={"model_name": "anthropic"},
                interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
                interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
                webhook="https://my.fake.webhook.com",
                multitask_strategy="interrupt"
            )
            print(final_state_of_run)
            ```

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

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

        Nr:  r   r   r'  r  rt  rm  rn  rW  r+  r,  r/  r  r   r0  r*  r1  r.  r5  r2  r8  r  
/runs/waitc                8    rt        |       x}r	 |       yyyr>  r?  r@  s     rO   r   z$RunsClient.wait.<locals>.on_responseT
  rA  rQ   rB  r   	__error__r   z: messagerC  )
r  r  rE  r  r   r  rF   r^   r   rl   )r   rk   rW  r'  r  rn  rt  rm  r  r   r*  r+  r,  r/  r.  r5  r0  r1  r2  re  rY   r   r3  r8  rG  rH  ry  rI  r   rp   s                         `       rO   rh  zRunsClient.wait	  s    d (MMv"

U
GN'--/C$!QQ]ACTX

 f
 w
 
 L
  0
 
 w
 *
 ]
 !"4
  !2
  ]!
" ]#
$ ]%
& ]'
( *)
. 2;1Fi	{*-L 		)
 44#*==?D41aam!Q$D'54 5 
 
 8T*x'8K0$7K(,,W56b+9N9R9RS\9]8^_  [ D> E
s6   9E
E
E
A2E>
E	EE!E"A0Er  r   r  r  r  r  rY   r   c                  K   ||d}|||d<   |r||d<   |r|j                  |       | 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.
            params: Optional query parameters to include with the request.

        Returns:
            The runs for the thread.

        ???+ example "Example Usage"

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

        r  Nr  r  r  rS  r   r]  	r   rk   r  r  r  r  rY   r   r_  s	            rO   re   zRunsClient.listl
  sz     J (
 %+L"%+L"'YY]]	{%(w # 
 
 	
 
s   AAAAc               f   K   | j                   j                  d| d| ||       d{   S 7 w)aU  Get a run.

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

        Returns:
            `Run` object.

        ???+ example "Example Usage"

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

        r  /runs/rR  NrU  r   rk   rj   rY   r   s        rO   rl   zRunsClient.get
  s@     > YY]]	{&176 # 
 
 	
 
s   (1/1	interruptrh  actionrY   r   c                 K   |rdnd|d}|r|j                  |       |r.| j                  j                  d| d| dd||       d	{   S | j                  j                  d| d| dd	||
       d	{   S 7 27 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.
            params: Optional query parameters to include with the request.

        Returns:
            `None`

        ???+ example "Example Usage"

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

        r   r   rh  ry  r  ru  /cancelrB  r   Nr   r   r   r  r   r   rk   rj   rh  ry  rY   r   r_  s           rO   cancelzRunsClient.cancel
  s     L A1
 '44I;fVHG<#	 5    I;fVHG<#	 (   s$   AB
A=-B8A?9B?Bc               j   K   | j                   j                  d| d| dd||       d{   S 7 w)a  Block until a run is done. Returns the final state of the thread.

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

        Returns:
            `None`

        ???+ example "Example Usage"

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

        r  ru  /joinr   rR  Nr   r  rv  s        rO   joinzRunsClient.join
  sI     < YY00	{&6	 1 
 
 	
 
s   *313cancel_on_disconnectr  rY   r   r  c                   ||d}|r|j                  |       | j                  j                  d| d| dd|i |rd|ini |xs i xs 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.
            params: Optional query parameters to include with the request.
            last_event_id: The last event ID to use for the stream.

        Returns:
            The stream of parts.

        ???+ example "Example Usage"

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

        )r  r  r  ru  r  r   r  Nr   r  	r   rk   rj   r  r  rY   r   r  r_  s	            rO   r  zRunsClient.join_stream   s    V %9&
 'yy	{&87DO]3"=b     	
 		
rQ   c               h   K   | j                   j                  d| d| ||       d{    y7 w)aS  Delete a run.

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

        Returns:
            `None`

        ???+ example "Example Usage"

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

        r  ru  rR  Nr  rv  s        rO   r   zRunsClient.delete[  s=     < ii	{&176  
 	
 	
s   (202r  )2rk   rG   rW  rG   r'  Input | Noner  Command | Noner  !StreamMode | Sequence[StreamMode]r(  r  r)  r  rn  r"  rt  r  rm  r  r  r  r   r  r*  bool | Noner+  All | Sequence[str] | Noner,  r  r-  r  r.  DisconnectMode | Noner/  r  r0  MultitaskStrategy | Noner1  IfNotExists | Noner2  
int | NonerY   r4  r   r3  r3  *Callable[[RunCreateMetadata], None] | Noner   r<  ),rk   r   rW  rG   r'  r  r  r  r  r  r(  r  r)  r  rn  r"  rt  r  r*  r  r+  r  r,  r  r-  r  r.  r  r5  OnCompletionBehavior | Noner1  r  r/  r  r2  r  rY   r4  r   r3  r3  r  r   r<  )6rk   r  rW  rG   r'  r  r  r  r  r  r(  r  r)  r  rn  r"  rt  r  rm  r  r  r  r   r  r*  r  r+  r  r,  r  r-  r  r.  r  r5  r  r/  r  r0  r  r1  r  r2  r  rY   r4  r   r3  r3  r  r8  Durability | Noner   r<  )*rk   r   rW  rG   r'  r  r  r  r  r  r(  r  r)  r  rn  r"  r*  r  rt  r  rm  r  r+  r  r,  r  r/  r  r5  r  r1  r  r2  r  rY   r4  r   r3  r3  r  r   r*   .rk   rG   rW  rG   r'  r  r  r  r  r  r(  r  r)  r  rn  r"  rt  r  rm  r  r  r  r   r  r*  r  r+  r  r,  r  r/  r  r0  r  r1  r  r2  r  rY   r4  r   r3  r3  r  r   r*   2rk   r  rW  rG   r'  r  r  r  r  r  r(  r  r)  r  rn  r"  rt  r  rm  r  r  r  r   r  r*  r  r+  r  r,  r  r/  r  r0  r  r1  r  r5  r  r2  r  rY   r4  r   r3  r3  r  r8  r  r   r*   ra  zlist[RunCreate]rY   r4  r   r3  r   	list[Run],rk   rG   rW  rG   r'  r  r  r  rn  r"  rt  r  rm  r  r  r  r   r  r*  r  r+  r  r,  r  r/  r  r.  r  r0  r  r1  r  r2  r  re  r  rY   r4  r   r3  r3  r  r   list[dict] | dict[str, Any](rk   r   rW  rG   r'  r  r  r  rn  r"  rt  r  rm  r  r*  r  r+  r  r,  r  r/  r  r.  r  r5  r  r1  r  r2  r  re  r  rY   r4  r   r3  r3  r  r   r  )0rk   r  rW  rG   r'  r  r  r  rn  r"  rt  r  rm  r  r  r  r   r  r*  r  r+  r  r,  r  r/  r  r.  r  r5  r  r0  r  r1  r  r2  r  re  r  rY   r4  r   r3  r3  r  r8  r  r   r  rk   rG   r  r;  r  r;  r  zRunStatus | Noner  zlist[RunSelectField] | NonerY   r4  r   r3  r   r  
rk   rG   rj   rG   rY   r4  r   r3  r   r*   rk   rG   rj   rG   rh  r  ry  r   rY   r4  r   r3  r   r   
rk   rG   rj   rG   rY   r4  r   r3  r   r^   )rk   rG   rj   rG   r  r  r  (StreamMode | Sequence[StreamMode] | NonerY   r4  r   r3  r  r  r   r<  
rk   rG   rj   rG   rY   r4  r   r3  r   r   r   r   r   r   r   r   r   rz  rc  rh  re   rl   r  r  r  r   r   rQ   rO   r   r     sL     #"&9A!&!&-1 $"&(,$()-7;6:.2/3"7;,0$(,0)-EI5(( (
 (  ( 7( ( ( +( (  ( &( "( '(  5!(" 4#($ ,%(& -'(( )(* 5+(, *-(. "/(0 *1(2 '3(4 C5(6 
#7( (:  #"&9A!&!&-1 $)-7;6:.2/359,0"$(,0)-EI/(( (
 (  ( 7( ( ( +( ( '( 5( 4( ,(  -!(" 3#($ *%(& '(( ")(* *+(, '-(. C/(0 
#1( (> #"&9A!&!&-1 $"&(,$()-7;6:.2/359"7;,0$(,0)-EI(,9\
\
 \

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

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

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

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

 *!
 '!
 
!
P *,0)-88 8
 8 8 *8 '8 
8~ -1)-#
#
 #

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

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

 * 
 ' 
 
 
rQ   r   c                  T   e Zd ZdZddZ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Zddd	 	 	 	 	 	 	 ddZddd	d
dddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ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, config, and context.
    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   rO  r   http_clients     rO   r   zCronClient.__init__  	    	rQ   Nr'  rn  rt  rm  r*  r+  r,  r/  r0  rY   r   c                  K   ||||||||	|
|d
}|r||d<   |j                         D ci c]  \  }}|	|| }}}| j                  j                  d| d|||       d{   S c c}}w 7 
w)a3  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.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
            interrupt_before: Nodes to interrupt immediately before they get executed.

            interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.

            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.
            params: Optional query parameters to include with the request.

        Returns:
            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"},
                context={"model_name": "openai"},
                interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
                interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
                webhook="https://my.fake.webhook.com",
                multitask_strategy="interrupt"
            )
            ```
        
scheduler'  rt  rn  rm  rW  r*  r+  r,  r/  r0  Nr  /runs/cronsrv  r  r   r   r   rk   rW  r  r'  rn  rt  rm  r*  r+  r,  r/  r0  rY   r   ry  rG  rH  s                     rO   create_for_threadzCronClient.create_for_thread  s     ~ ! (!2 0.
 ,>G()$+MMOEDAqq}1a4EEYY^^	{+.	 $ 
 
 	
 F
s    (A0
A(A()A0#A.$A0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.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
            interrupt_before: Nodes to interrupt immediately before they get executed.
            interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
            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.
            params: Optional query parameters to include with the request.

        Returns:
            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"},
                context={"model_name": "openai"},
                interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
                interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
                webhook="https://my.fake.webhook.com",
                multitask_strategy="interrupt"
            )
            ```

        r  r0  Nr  rv  r  r   rW  r  r'  rn  rt  rm  r*  r+  r,  r/  r0  rY   r   ry  rG  rH  s                    rO   rz  zCronClient.create  s     v ! (!2 0.
 ,>G()$+MMOEDAqq}1a4EEYY^^ $ 
 
 	
 F
s    (A,
A$A$%A,A* A,rR  c               b   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.
            params: Optional query parameters 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/rR  Nr  r   cron_idrY   r   s       rO   r   zCronClient.delete;  s/     6 iigY7QWXXXr  r  r   	rW  rk   r  r  r  r  r  rY   r   c       	           K   ||||d}
|r||
d<   |r||
d<   |r||
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.
            params: Optional query parameters to include with the request.

        Returns:
            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'
                }
            ]
            ```

        rW  rk   r  r  r  r  r  N/runs/crons/searchrv  r  r   rW  rk   r  r  r  r  r  rY   r   ry  rG  rH  s                rO   rn   zCronClient.searchX  s     B )"	
 !(GI$.GL! &GH$+MMOEDAqq}1a4EEYY^^ w $ 
 
 	
 F
s!   0A4
A,A,%A4'A2(A4rW  rk   rY   r   c               |   K   i }|r||d<   |r||d<   | j                   j                  d|||       d{   S 7 w)|  Count cron jobs matching filters.

        Args:
            assistant_id: Assistant ID to filter by.
            thread_id: Thread ID to filter by.
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        Returns:
            int: Number of crons matching the criteria.
        rW  rk   /runs/crons/countrv  Nrw  r   rW  rk   rY   r   ry  s         rO   r  zCronClient.count  sT     & #%&2GN##,GK YY^^gwv $ 
 
 	
 
r  )r  r   r   r   rk   rG   rW  rG   r  rG   r'  r  rn  r"  rt  r  rm  r  r*  r  r+  All | list[str] | Noner,  r  r/  r  r0  r  rY   r4  r   r3  r   r*   rW  rG   r  rG   r'  r  rn  r"  rt  r  rm  r  r*  r  r+  r  r,  r  r/  r  r0  r  rY   r4  r   r3  r   r*   r  rG   rY   r4  r   r3  r   r   rW  r  rk   r  r  r;  r  r;  r  zCronSortBy | Noner  r  r  zlist[CronSelectField] | NonerY   r4  r   r3  r   z
list[Cron]
rW  r  rk   r  rY   r4  r   r3  r   r;  
r   r   r   r   r   r  rz  r   rn   r  r   rQ   rO   r   r   ~  s   0  #-1 $"&)-3726")-,0)-!R
R
 R

 R
 R
 +R
 R
  R
 'R
 1R
 0R
 R
 'R
 *R
  '!R
" 
#R
r #-1 $"&)-3726")-,0)-K
K
 	K

 K
 +K
 K
  K
 'K
 1K
 0K
 K
 'K
 *K
 'K
  
!K
b -1)-YY *	Y
 'Y 
Y@ $( $%)'+/3,0)-O
 !O
 	O

 O
 O
 #O
 %O
 -O
 *O
 'O
 
O
h $( $,0)-
 !
 	

 *
 '
 

rQ   r   c                      e Zd ZdZd
dZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZd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   rO  rP  s     rO   r   zStoreClient.__init__  rQ  rQ   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.
            params: Optional query parameters 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 ('.').ri  r"  r#  indexr  /store/itemsrv  NrT   r   r   _provided_vals
r   ri  r"  r#  r  r  rY   r   labelry  s
             rO   put_itemzStoreClient.put_item  s     H  	Ee| /w6gh 	 #
 iimm!8'RX  
 	
 	
s   
AAAAArefresh_ttlrY   r   c                 K   |D ]  }d|v st        d| d       dj                  |      |d}|||d<   |ri ||}| j                  j                  d||       d{   S 7 w)	a  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.
            params: Optional query parameters 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  ri  r"  Nr  r  r   )rT   r  r   rl   )r   ri  r"  r  rY   r   r  rj  s           rO   get_itemzStoreClient.get_item  s     Z  	Ee| /w6gh 	
 $'88I#6sC
"(3J}%1J1&1JYY]]>*g]VVVVs   
A(AA(!A&"A(c               d   K   | j                   j                  d||d||       d{    y7 w)at  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.
            params: Optional query parameters 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  r  rv  Nr  r   ri  r"  rY   r   s        rO   delete_itemzStoreClient.delete_itemD  s:     : ii(5	  
 	
 	
s   &0.0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.
            params: Optional query parameters to include with the request.

        Returns:
            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/searchrv  Nr   r   r  
r   r  r  r  r  r  r  rY   r   ry  s
             rO   search_itemszStoreClient.search_itemsh  sY     z !1&
 YY^^!(	 $ 
 
 	
 
s   5><>c                ~   K   |||||d}| j                   j                  dt        |      ||       d{   S 7 w)a3  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.
            params: Optional query parameters to include with the request.

        Returns:
            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"],
                ...
            ]
            ```
        rM   suffix	max_depthr  r  /store/namespacesrv  Nr  	r   rM   r  r  r  r  rY   r   ry  s	            rO   list_namespaceszStoreClient.list_namespaces  sV     \ "
 YY^^(	 $ 
 
 	
 
s   4=;=r  NNNNr"  rG   r#  r  r  z!Literal[False] | list[str] | Noner  r  rY   r4  r   r3  ri  Sequence[str]r   r   r"  rG   ri  r  r  r  rY   r4  r   r3  r   r#   r  
r"  rG   rY   r4  r   r3  ri  r  r   r   Nr  r   NNNNr  r"  r  r;  r  r;  r  r  r  r  rY   r4  r   r3  r  r  r   r/   )NNNd   r   NNrM   list[str] | Noner  r  r  r  r  r;  r  r;  rY   r4  r   r3  r   r%   
r   r   r   r   r   r  r  r  r  r  r   rQ   rO   r   r     s    48,0)-2
 	2

 !2
 12
 2
 *2
 '2
 2
 
2
t $(,0)-7W 	7W 7W !7W *7W '7W 
7W| -1)-"
 	"

 *"
 '"
 "
 
"
P ,0 #',0)-J
 )	J

 J
 J
 J
 !J
 *J
 'J
'J
 
J
\ $(#' $,0)-9
 9
 !9
 	9

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

    Args:
        url: The URL of the LangGraph API.
        api_key: API key for authentication. Can be:
            - A string: use this exact API key
            - `None`: explicitly skip loading from environment variables
            - Not provided (default): auto-load from environment in this order:
                1. `LANGGRAPH_API_KEY`
                2. `LANGSMITH_API_KEY`
                3. `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")
        ```

    ???+ example "Skip auto-loading API key from environment:"

        ```python
        from langgraph_sdk import get_sync_client

        # Don't load API key from environment variables
        client = get_sync_client(
            url="http://localhost:8123",
            api_key=None
        )
        ```
    zhttp://localhost:8123r~   r   r   r   r   )r   HTTPTransportClientr   r[   r  )rt   rL   rY   ru   r   r   s         rO   get_sync_clientr    sr    h {%##A.I\\ " MM'"qs#AFWg.	F v&&rQ   c                  @    e Zd ZdZddZddZ	 	 	 	 	 	 	 	 d	dZd
dZy)r  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     rO   r   zSyncLangGraphClient.__init__C  s^    "6*	.tyy9(3"499-	#DII.
$TYY/
rQ   c                    | S )zEnter the sync context manager.r   r   s    rO   	__enter__zSyncLangGraphClient.__enter__K  s    rQ   c                $    | j                          y)zExit the sync context manager.N)closer   s       rO   __exit__zSyncLangGraphClient.__exit__O  s     	

rQ   c                f    t        | d      r%| j                  j                  j                          yyr   )r`   r   r   r  r   s    rO   r  zSyncLangGraphClient.closeX  s'    4 II""$ !rQ   Nr   zhttpx.Clientr   r   )r   r  r   r   )r   r   r   r   r   r  r	  r  r   rQ   rO   r  r  5  sA    0, & %	
 
%rQ   c                  @   e Zd ZdZddZdddd	 	 	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 	 	 	 	 ddZdd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
ddddd		 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)r  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     rO   r   zSyncHttpClient.__init__i  r   rQ   Nr   c               ~    | j                   j                  |||      }|r ||       t        |       t        |      S )r   r   )r   rl   r   _decode_jsonr   s         rO   rl   zSyncHttpClient.getl  s8     KKOODOAN"ArQ   c                   |t        |      \  }}ni d}}|r|j                  |       | j                  j                  ||||      }|r ||       t	        |       t        |      S )r   rQ   r   )_encode_jsonr   r   r   r   r  r   s	            rO   r   zSyncHttpClient.post{  ss     '3D'9$OW')3WO""7+KK/76  
 N"ArQ   c                   t        |      \  }}|r|j                  |       | j                  j                  ||||      }|r ||       t	        |       t        |      S )r   r   )r  r   r   r   r   r  r   s	            rO   r   zSyncHttpClient.put  sb     $0#5 ""7+KKOO/76  
 N"ArQ   c                   t        |      \  }}|r|j                  |       | j                  j                  ||||      }|r ||       t	        |       t        |      S )r   r   )r  r   r   r   r   r  r   s	            rO   r   zSyncHttpClient.patch  sd     $0#5 ""7+KK/76  
 N"ArQ   r   c               n    | j                   j                  d||||      }|r ||       t        |       yr   )r   r   r   r   s          rO   r   zSyncHttpClient.delete  s<     KKdfg   
 N"rQ   r~   r   c          	     (   t        |      \  }}	|r|j                  |       | j                  j                  ||||	|      5 }
|r ||
       	 |
j	                          |
j                  j                  d      }|dk  s|st!        |
      cddd       S 	 t!        |
      cddd       S # t
        j                  $ re}|
j                         j                         }t        j                  dk\  r|j                  |       |t        j                  d| |       |d}~ww xY w# t
        j"                  $ rN t%        j&                  d| d	
       |
j)                          | j+                  |d||dz
        cY cddd       S w xY w# 1 sw Y   yxY w)r   r   r   r   r|   Nr   r   r   r   r   r   r   r   )r  r   r   r   r   r   r   r   r   r   r   r   r   r   rY   rl   r  r   r  r  r  r  r  s                 rO   r  z SyncHttpClient.request_reconnect  s    $0#5 ""7+[[D/76   
 	A""$ ))--
+C!#3#A!	 	"#A%	 	 (( vvx(##w.JJt$  LL#=dV!DqLQ ?? HN  	--+$3a$7 .  3	 	&'	 	sP   FB),F
D$)D!<A DD!!F$AF9FFFFc             #    K   |t        |      \  }}ni d}}d|d<   d|d<   |r|j                  |       |j                         D 	
ci c]  \  }	}
|	j                         dvr|	|
 }}	}
d}d}d}d}	 t	        ||n|      }|||d
<   ||nd}||nd}||nd}d}| j
                  j                  ||xs ||||      5 }|
|r ||       t        |       |j                  j                  dd      j                  d      d   }d|vrt        j                  d|      |j                  j                  d      }|r|}t               }	 t        |      D ]h  }|j                  t!        t"        |      j%                  d            }|4|j&                  |j&                  }|j(                  s|j*                  e| j 	 |j                  d      x}r5|j&                  |j&                  }|j(                  s|j*                  | 	 ddd       |r!|dz  }||kD  rt        j                  d      yc c}
}	w # t        j,                  $ r | d	}Y Lw xY w# 1 sw Y   QxY ww)z*Stream the results of a request using SSE.Nr
  r  r  r  r  r   r~   Tr  r   Fr   r  r  r  r  r   r  rQ   r   r  )r  r   r  r  r^   r   r   r   rY   rl   r  r   r  r;   r=   r   r   r  r  r  r  r   r   r!  s                              rO   r   zSyncHttpClient.stream  s     '3D'9$OW')4WO$7!+5(""7+ .335
Uyy{"DD J
 
 %)%)!""#1#9?PO (3@0'5'=V5N)7)?gTO'5'=V4NE##&$''% $  -& !)k$',"{{~rBLLSQRST&l:..+.0 
 &)[[__Z%@"%%7N$,& .s 3 *%nnT%->-E-Ee-LM?&44@070E0E"yyCHH,@&)	* &nnS11s1"00<,3,A,AM99(< #&I[-&\ "a'"%(>>..D  Y
n  ! &- E!A-& -&s]   AI(H8'AI(BI>H>0H>=H>AI2I(>IIIII%!I(r  r2  r6  r7  r8  r9  )r   rG   r  rG   r   r:  r   r3  rY   r4  r   r5  r   Iterator[StreamPart]r=  r   rQ   rO   r  r  ^  s;    *.,0?C '	
 * = 
( *.,0?C +	
 ' * = 
: *.,0?C 	
 ' * = 
6 *.,0?C 	
 ' * = 
2  )-,0?C## 	#
 '# *# =# 
#, '+)-,0?C .. .
 $. '. *. =. . 
.j '+)-,0?C`` `
 $` '` *` =` 
`rQ   r  c                    t        j                  | t        t         j                  t         j                  z        }t        t        |            }d}||d}||fS r?  )rC  rD  rh   rE  rF  rG   rG  rH  s        rO   r  r  b  sR    <<""V%<%<<D
 T^N%L!/NGD=rQ   c                T    | j                         }|rt        j                  |      S d S r   )r   rC  rK  rL  s     rO   r  r  n  s#    668D!%6<</4/rQ   c                     e Zd ZdZddZddd	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 	 	 ddZddd	 	 	 	 	 	 	 dd	Z	 	 d ddd	 	 	 	 	 	 	 	 	 	 	 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Z
ddd	 	 	 	 	 	 	 d%dZe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       Zdddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(dZdddddd	 	 	 	 	 	 	 	 	 	 	 d)dZ	 	 	 d*ddd	 	 	 	 	 	 	 	 	 	 	 	 	 d+dZddd	 	 	 	 	 	 	 	 	 d,dZy)-r   af  Client for managing assistants in LangGraph synchronously.

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

    ???+ example "Example"

        ```python
        client = get_sync_client(url="http://localhost:2024")
        assistant = client.assistants.get("assistant_id_123")
        ```
    c                    || _         y r   rO  rP  s     rO   r   zSyncAssistantsClient.__init__  rQ  rQ   NrR  c               D    | 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.
            params: Optional query parameters to include with the request.

        Returns:
            `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': {},
                'context': {},
                'metadata': {'created_by': 'system'}
            }
            ```

        rT  rR  rU  rV  s       rO   rl   zSyncAssistantsClient.get  s-    R yy}}<.)76  
 	
rQ   FrY  c               t    d|i}|r|j                  |       | j                  j                  d| d||      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.
            params: Optional query parameters to include with the request.

        Returns:
            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__'}
                    ]
            }
            ```

        rZ  rT  r\  r   r]  r^  s         rO   r`  zSyncAssistantsClient.get_graph  sI    \ ~'yy}}<./g  
 	
rQ   c               F    | j                   j                  d| d||      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.
            params: Optional query parameters 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'
                                    }
                            }
                    },
                'context_schema':
                    {
                        'title': 'Context',
                        'type': 'object',
                        'properties':
                            {
                                'model_name':
                                    {
                                        'title': 'Model Name',
                                        'enum': ['anthropic', 'openai'],
                                        'type': 'string'
                                    }
                            }
                    }
            }
            ```

        rT  rb  rR  rU  rV  s       rO   rc  z SyncAssistantsClient.get_schemas  s/    B yy}}<.176  
 	
rQ   c                   d|i}|ri ||}|$| j                   j                  d| d| ||      S | j                   j                  d| d||      S )ai  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.
            params: Optional query parameters to include with the request.

        Returns:
            Subgraphs: The graph schema for the assistant.

        re  rT  rf  r   rg  rU  rh  s          rO   rk  z"SyncAssistantsClient.get_subgraphsj  s    (  )
1J1&1J 99==|nK	{C! !   99==|nJ7! !  rQ   rl  c                   d|i}|r||d<   |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.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            metadata: Metadata to add to assistant.
            assistant_id: Assistant ID to use, will default to a random UUID if not provided.
            if_exists: How to handle duplicate creation. Defaults to 'raise' under the hood.
                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
            params: Optional query parameters to include with the request.

        Returns:
            The created assistant.

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            assistant = client.assistants.create(
                graph_id="agent",
                context={"model_name": "openai"},
                metadata={"number":1},
                assistant_id="my-assistant-id",
                if_exists="do_nothing",
                name="my_name"
            )
            ```
        rs  rt  rm  rn  rW  ro  rp  rq  ru  rv  rw  rx  s               rO   rz  zSyncAssistantsClient.create  s    f #
  &GH!(GI"*GJ&2GN##,GK "GFO%0GM"yy~~  
 	
rQ   r{  c                   i }
|r||
d<   |r||
d<   |r||
d<   |r||
d<   |r||
d<   |r||
d<   | j                   j                  d| |
||	      S )	az  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.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            metadata: Metadata to merge with existing assistant metadata.
            name: The new name for the assistant.
            headers: Optional custom headers to include with the request.
            description: Optional description of the assistant.
                The description field is available for langgraph-api server version>=0.0.45

        Returns:
            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",
                context={"model_name": "anthropic"},
                metadata={"number":2}
            )
            ```
        rs  rt  rm  rn  rp  rq  rT  rv  r}  r~  s              rO   r   zSyncAssistantsClient.update  s    Z #%"*GJ &GH!(GI"*GJ"GFO%0GM"yy<.)	  
 	
rQ   c               F    | 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.
            params: Optional query parameters 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"
            )
            ```

        rT  rR  Nr  rV  s       rO   r   zSyncAssistantsClient.delete  s%    6 			<~6PVWrQ   r  r   r  c                    y r   r   r  s               rO   rn   zSyncAssistantsClient.search3  s     $'rQ   r  r  c                    y r   r   r  s               rO   rn   zSyncAssistantsClient.searchD  s     rQ   c                   |	dvrt        d      ||d}|r||d<   |r||d<   |r||d<   |r||d<   |r||d<   |r||d	<   d
dfd}t        t        t           | j                  j                  d||
||	dk(  r|nd
            }|	dk(  r|dS |S )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.
            name: The name of the assistant to filter by.
                The filtering logic will match assistants where 'name' is a substring (case insensitive) of the assistant name.
            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.
            select: Specific assistant fields to include in the response.
            response_format: Controls the response shape. Use ``"array"`` (default)
                to return a bare list of assistants, or ``"object"`` to return
                a mapping containing assistants plus pagination metadata.
                Defaults to "array", though this default will be changed to "object" in a future release.
            headers: Optional custom headers to include with the request.

        Returns:
            A list of assistants (when ``response_format="array"``) or a mapping
            with the assistants and the next pagination cursor (when
            ``response_format="object"``).

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            response = client.assistants.search(
                metadata = {"name":"my_name"},
                graph_id="my_graph_id",
                limit=5,
                offset=5,
                response_format="object",
            )
            assistants = response["assistants"]
            next_cursor = response["next"]
            ```
        r  z+response_format must be 'array' or 'object'r  rn  rs  rp  r  r  r  Nc                <    | j                   j                  d      y r  r  r  s    rO   r  z7SyncAssistantsClient.search.<locals>.capture_pagination  r  rQ   r  r  r  r  r  r  r  s                  @rO   rn   zSyncAssistantsClient.searchU  s    l "55JKK#
 "*GJ"*GJ"GFO!(GI$.GL! &GH"&	D OIINN$2AX2M.SW  	

 h&",kBBrQ   r  c               n    i }|r||d<   |r||d<   |r||d<   | j                   j                  d|||      S )r  rn  rs  rp  r  rv  rw  r  s          rO   r  zSyncAssistantsClient.count  sR    , #%"*GJ"*GJ"GFOyy~~gwv  
 	
rQ   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:
            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"
            )
            ```

        r  rn  rT  r  rv  rw  r  s           rO   r  z!SyncAssistantsClient.get_versions  sP    D #
 "*GJyy~~<.	2	  
 	
rQ   c               P    d|i}| j                   j                  d| d|||      S )aF  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` 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  rT  r  rv  rw  r  s         rO   r  zSyncAssistantsClient.set_latest   s=    < $-g"6yy~~<.0	  
 	
rQ   r   r  r   r   r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r   rQ   rO   r   r   s  sg   
 -1)-+
+
 *	+

 '+
 
+
b !,0)-3
3
 	3

 *3
 '3
 
)3
r -1)-C
C
 *	C

 'C
 
C
P !%	" -1)-"" " 	" *" '" 
"N !%E

 #'#'/3,0"&)-E
E
 E

  E
 E
 !E
 -E
 E
 *E
  E
 'E
 
E
V  $ $"&,0"&)-?
?
 	?

 ?
  ?
 ?
 ?
 *?
  ?
 '?
 
?
J -1)-XX *	X
 'X 
X:  #*.'+48,0)-' ' 	'
 ' ' ' (' %' 2' +' *' '' 
"' '   #*.'+48,3,0)-  	
    ( % 2 * * ' 
 & #*.'+486=,0)-Z Z 	Z
 Z Z Z (Z %Z 2Z 4Z *Z 'Z 
4Z~ #,0)-
 
 	

 
 *
 '
 

H ,
 -1)-,
,
 ,
 	,

 ,
 *,
 ',
 
 ,
f -1)-%
%
 %

 *%
 '%
 
%
rQ   r   c                     e Zd ZdZddZddd	 	 	 	 	 	 	 ddZddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 	 	 	 	 dd	Zddd	 	 	 	 	 	 	 d d
Zdddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d!dZ	dddddd	 	 	 	 	 	 	 	 	 	 	 d"dZ
ddd	 	 	 	 	 	 	 d dZ	 	 d#dddd	 	 	 	 	 	 	 	 	 	 	 	 	 d$dZdddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%dZddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d&dZ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   rO  rP  s     rO   r   zSyncThreadsClient.__init__6  rQ  rQ   NrR  c               D    | j                   j                  d| ||      S )aI  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` 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'}
            }
            ```

        r  rR  rU  r  s       rO   rl   zSyncThreadsClient.get9  s%    L yy}}y4gf}UUrQ   r  c               v   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
<   |$t        |t        t        f      r	|dd|	d<   n||	d<   | j                  j                  d|	||      S c c}w c c}}
w )aR  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.
            ttl: Optional time-to-live in minutes for the thread. You can pass an
                integer (minutes) or a mapping with keys `ttl` and optional
                `strategy` (defaults to "delete").
            headers: Optional custom headers to include with the request.

        Returns:
            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"
            )
            ```
            )
        rk   rs  rn  ro  r  r  r  r  r  r  r   r  r  r  rv  r  r  s               rO   rz  zSyncThreadsClient.createa  s	   V #%#,GK x#>r#-5J)2#GJ #,GK  $%   "#9  	 '(k'(uuY'7'(| 	%GL! ?#U|,),(!C!$yy~~jwPV~WW# %s   B5"B0B50B5r  c                   d|i}|$t        |t        t        f      r	|dd|d<   n||d<   | j                  j	                  d| |||      S )an  Update a thread.

        Args:
            thread_id: ID of thread to update.
            metadata: Metadata to merge with existing thread metadata.
            ttl: Optional time-to-live in minutes for the thread. You can pass an
                integer (minutes) or a mapping with keys `ttl` and optional
                `strategy` (defaults to "delete").
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        Returns:
            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},
                ttl=43_200,
            )
            ```
        rn  r   r  r  r  rv  r  r  s          rO   r   zSyncThreadsClient.update  sf    D $.x"8?#U|,),(!C!$yy	{#	  
 	
rQ   c               F    | j                   j                  d| ||       y)a  Delete a thread.

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

        Returns:
            `None`

        ???+ example "Example Usage"

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

        r  rR  Nr  r  s       rO   r   zSyncThreadsClient.delete  s$    4 			9YK0'&QrQ   r  r   r  c                   ||d}|r||d<   |r||d<   |r||d<   |r||d<   |r||d<   |r||d<   |	r|	|d<   | j                   j                  d	||
|
      S )a  Search for threads.

        Args:
            metadata: Thread metadata to filter on.
            values: State values to filter on.
            ids: List of thread IDs to filter by.
            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 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
            )
            ```
        r  rn  r  r  r  r  r  r  r  rv  rw  r  s                rO   rn   zSyncThreadsClient.search  s    V #
 "*GJ &GH GEN &GH!(GI$.GL! &GHyy~~GWV  
 	
rQ   r  c               n    i }|r||d<   |r||d<   |r||d<   | j                   j                  d|||      S )r  rn  r  r  r  rv  rw  r  s          rO   r  zSyncThreadsClient.count7  sS    * #%"*GJ &GH &GHyy~~7GF  
 	
rQ   c               H    | 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.
            params: Optional query parameters 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"
            )
            ```

        r  r  Nrv  rw  r  s       rO   r  zSyncThreadsClient.copyW  s0    6 yy~~	{%(tWV  
 	
rQ   Fr  c                  |r&| j                   j                  d| d||d||      S |r0d|i}|ri ||}| j                   j                  d| d| ||      S d|i}|ri ||}| j                   j                  d| d||      S )	ab  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:
            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'
                    }
            }
            ```

        r  r  r  rv  r  r  r   r  r  r  s           rO   r  zSyncThreadsClient.get_statev  s    Z 99>>I;&78$.YG	 "   %y1J5
5f5
99==I;gm_=! !   &y1J5
5f5
99==I;f-! !  rQ   r  c               z    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:
            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   r  r  r  r  rv  rw  r  s	            rO   r  zSyncThreadsClient.update_state  sg    ` f#
 '4GO$$.GL!!(GIyy~~	{&)QW  
 	
rQ   r  c               z    d|i}|r||d<   |r||d<   |r||d<   | j                   j                  d| d|||      S )aC  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:
            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  rn  r  r  r
  rv  rw  r  s	            rO   r  zSyncThreadsClient.get_history9  si    L U#
  &GH"*GJ$.GL!yy~~	{(+	  
 	
rQ   r  )r  r  rY   r   c                   d|i}|r|j                  |       | j                  j                  d| ddi |rd|ini |xs i |      S )a  Get a stream of events for a thread.

        Args:
            thread_id: The ID of the thread to get the stream for.
            last_event_id: The ID of the last event to get.
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        Returns:
            An iterator of stream parts.

        ???+ example "Example Usage"

            ```python

            for chunk in client.threads.join_stream(
                thread_id="my_thread_id",
                last_event_id="my_event_id",
                stream_mode="run_modes",
            ):
                print(chunk)
            ```

        r  r  r  r   r  rR  r  )r   rk   r  r  rY   r   r_  s          rO   r  zSyncThreadsClient.join_streamn  sv    D ;
 'yy	{'*7DO]3"=b     
 	
rQ   r*  r  r  r  r  r  r  r  r  r   r!  )rk   rG   r  r#  r  r  rY   r4  r   r3  r   r  r$  r   rQ   rO   r  r  (  s    -1)-&V&V *	&V
 '&V 
&VV  $/3KO#.2,0)-IX IX 	IX
 -IX IIX IX ,IX *IX 'IX 
IX` /3,0)--
-
 $	-

 ,-
 *-
 '-
 
-
f -1)-RR *	R
 'R 
R> $(&*'+'+15,0)->
 >
 	>

 ">
 $>
 >
 >
 %>
 %>
 />
 *>
 '>
 
>
F &*,0)-
 
 	

 $
 *
 '
 

H -1)-

 *	

 '
 

D )-$(	E  ,0)-EE &E "	E E *E 'E 
EX #(,$(,0)-:
:
 7:

 :
 &:
 ":
 *:
 ':
 
#:
@ *.-1(,,0)-3
3
 	3

 (3
 +3
 &3
 *3
 '3
 
3
r FQ$(,0)-.
.
 C	.

 ".
 *.
 '.
 
.
rQ   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d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 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	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 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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	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 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	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 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d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d-dZ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d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d/d       Z	eddd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dddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d1dZ	ddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d2dZ
ddd	 	 	 	 	 	 	 	 	 d3dZdd ddd!	 	 	 	 	 	 	 	 	 	 	 	 	 d4d"Zddd	 	 	 	 	 	 	 	 	 d5d#Zdddddd$	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d6d%Zddd	 	 	 	 	 	 	 	 	 d7d&Zy)8r  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   rO  rP  s     rO   r   zSyncRunsClient.__init__  rQ  rQ   Nr  F)r'  r  r  r(  rn  rt  rm  r  r   r*  r+  r,  r-  r.  r/  r0  r1  r2  rY   r   r3  c                    y r   r   )r   rk   rW  r'  r  r  r(  rn  rt  rm  r  r   r*  r+  r,  r-  r.  r/  r0  r1  r2  rY   r   r3  s                           rO   r   zSyncRunsClient.stream  s    6  #rQ   )r'  r  r  r(  r)  rn  rt  rm  r*  r+  r,  r-  r.  r5  r1  r/  r2  rY   r   r3  c                    y r   r   )r   rk   rW  r'  r  r  r(  r)  rn  rt  rm  r*  r+  r,  r-  r.  r5  r1  r/  r2  rY   r   r3  s                          rO   r   zSyncRunsClient.stream  s    4  #rQ   r7  c          
        |t        j                  dt        d       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}dfd}| j                  j                  |d|j                         D ci c]  \  }}|	|| c}}||r|      S d      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.
            stream_resumable: Whether the stream is considered resumable.
                If true, the stream can be resumed and replayed in its entirety even after disconnection.
            metadata: Metadata to assign to the run.
            config: The configuration for the assistant.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            checkpoint: The checkpoint to resume from.
            checkpoint_during: (deprecated) Whether to checkpoint during the run (or only at the end/interruption).
            interrupt_before: Nodes to interrupt immediately before they get executed.
            interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
            feedback_keys: Feedback keys to assign to run.
            on_disconnect: The disconnect mode to use.
                Must be one of 'cancel' or 'continue'.
            on_completion: Whether to delete or keep the thread created for a stateless run.
                Must be one of 'delete' or 'keep'.
            webhook: Webhook to call after LangGraph API call is done.
            multitask_strategy: Multitask strategy to use.
                Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
            if_not_exists: How to handle missing thread. Defaults to 'reject'.
                Must be either 'reject' (raise error if missing), or 'create' (create new thread).
            after_seconds: The number of seconds to wait before starting the run.
                Use to schedule future runs.
            headers: Optional custom headers to include with the request.
            on_run_created: Optional callback to call when a run is created.
            durability: The durability to use for the run. Values are "sync", "async", or "exit".
                "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
                "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
                "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps


        Returns:
            Iterator 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"},
                context={"model_name": "anthropic"},
                interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
                interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
                feedback_keys=["my_feedback_key_1","my_feedback_key_2"],
                webhook="https://my.fake.webhook.com",
                multitask_strategy="interrupt"
            ):
                print(chunk)
            ```
            ```shell
            ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

            StreamPart(event='metadata', data={'run_id': '1ef4a9b8-d7da-679a-a45a-872054341df2'})
            StreamPart(event='values', data={'messages': [{'content': 'how are you?', 'additional_kwargs': {}, 'response_metadata': {}, 'type': 'human', 'name': None, 'id': 'fe0a5778-cfe9-42ee-b807-0adaa1873c10', 'example': False}]})
            StreamPart(event='values', data={'messages': [{'content': 'how are you?', 'additional_kwargs': {}, 'response_metadata': {}, 'type': 'human', 'name': None, 'id': 'fe0a5778-cfe9-42ee-b807-0adaa1873c10', 'example': False}, {'content': "I'm doing well, thanks for asking! I'm an AI assistant created by Anthropic to be helpful, honest, and harmless.", 'additional_kwargs': {}, 'response_metadata': {}, 'type': 'ai', 'name': None, 'id': 'run-159b782c-b679-4830-83c6-cef87798fe8b', 'example': False, 'tool_calls': [], 'invalid_tool_calls': [], 'usage_metadata': None}]})
            StreamPart(event='end', data=None)
            ```
        Nr:  r   r   r'  r  rt  rm  rn  r  r(  r)  rW  r+  r,  r-  r/  r  r   r*  r0  r;  r  r<  c                8    rt        |       x}r	 |       yyyr>  r?  r@  s     rO   r   z*SyncRunsClient.stream.<locals>.on_responseu  rA  rQ   rB  r   rC  rD  rF  s                             `      rO   r   zSyncRunsClient.stream  s   L (MMv"

U
GN'--/C$!QQ]ACTX

 f
 w
 
 ;
  0
  0
 L
  0
 
 ]
 w
  *!
" ]#
$  !2%
& !"4'
( +***$1
8 $ 	{,/ 		)
 yy#*==?D41aam!Q$D'5   
 	
 <@   
 	
E DJ ErJ  )r'  r  r  r(  r)  rn  rt  rm  r*  r+  r,  r/  r5  r1  r2  rY   r   r3  c                    y r   r   )r   rk   rW  r'  r  r  r(  r)  rn  rt  rm  r*  r+  r,  r/  r5  r1  r2  rY   r   r3  s                        rO   rz  zSyncRunsClient.create  s    0 rQ   rL  c                    y r   r   rN  s                          rO   rz  zSyncRunsClient.create  s    4 rQ   rO  c                  |t        j                  dt        d       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}|j                         D ci c]  \  }}|	|| }}}dfd}| j                  j                  |rd| dnd|||r|      S 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.
            stream_resumable: Whether the stream is considered resumable.
                If true, the stream can be resumed and replayed in its entirety even after disconnection.
            metadata: Metadata to assign to the run.
            config: The configuration for the assistant.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            checkpoint: The checkpoint to resume from.
            checkpoint_during: (deprecated) Whether to checkpoint during the run (or only at the end/interruption).
            interrupt_before: Nodes to interrupt immediately before they get executed.
            interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
            webhook: Webhook to call after LangGraph API call is done.
            multitask_strategy: Multitask strategy to use.
                Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
            on_completion: Whether to delete or keep the thread created for a stateless run.
                Must be one of 'delete' or 'keep'.
            if_not_exists: How to handle missing thread. Defaults to 'reject'.
                Must be either 'reject' (raise error if missing), or 'create' (create new thread).
            after_seconds: The number of seconds to wait before starting the run.
                Use to schedule future runs.
            headers: Optional custom headers to include with the request.
            on_run_created: Optional callback to call when a run is created.
            durability: The durability to use for the run. Values are "sync", "async", or "exit".
                "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
                "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
                "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps

        Returns:
            The created background `Run`.

        ???+ example "Example Usage"

            ```python
            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"},
                context={"model_name": "openai"},
                interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
                interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
                webhook="https://my.fake.webhook.com",
                multitask_strategy="interrupt"
            )
            print(background_run)
            ```

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

            {
                'run_id': 'my_run_id',
                'thread_id': 'my_thread_id',
                'assistant_id': 'my_assistant_id',
                'created_at': '2024-07-25T15:35:42.598503+00:00',
                'updated_at': '2024-07-25T15:35:42.598503+00:00',
                'metadata': {},
                'status': 'pending',
                'kwargs':
                    {
                        'input':
                            {
                                'messages': [
                                    {
                                        'role': 'user',
                                        'content': 'how are you?'
                                    }
                                ]
                            },
                        'config':
                            {
                                'metadata':
                                    {
                                        'created_by': 'system'
                                    },
                                'configurable':
                                    {
                                        'run_id': 'my_run_id',
                                        'user_id': None,
                                        'graph_id': 'agent',
                                        'thread_id': 'my_thread_id',
                                        'checkpoint_id': None,
                                        'assistant_id': 'my_assistant_id'
                                    }
                            },
                        'context':
                            {
                                'model_name': 'openai'
                            },
                        'webhook': "https://my.fake.webhook.com",
                        'temporary': False,
                        'stream_mode': ['values'],
                        'feedback_keys': None,
                        'interrupt_after': ["node_to_stop_after_1","node_to_stop_after_2"],
                        'interrupt_before': ["node_to_stop_before_1","node_to_stop_before_2"]
                    },
                'multitask_strategy': 'interrupt'
            }
            ```
        Nr:  r   r   r'  r  r  r(  r)  rt  rm  rn  rW  r+  r,  r/  r  r   r*  r0  r1  rQ  c                8    rt        |       x}r	 |       yyyr>  r?  r@  s     rO   r   z*SyncRunsClient.create.<locals>.on_responsed  rA  rQ   r  rS  r   rC  rT  rU  s                          `     rO   rz  zSyncRunsClient.create  s   V (MMv"

U
GN'--/C$!QQ]ACTX

 ;
  0
  0
 f
 w
 
 L
  0
 
 w
 *
  ]!
"  !2#
$ !"4%
& ]'
( +*$-
0 %,MMOEDAqq}1a4EE	)
 yy~~,5i	{%(7'5  
 	

 <@  
 	
9 D* Fs   
C!
C!

C'"C'rR  c               |    dd}|D cg c]
  } ||       }}| j                   j                  d|||      S c c}w )rW  c                \    | j                         D ci c]  \  }}|	|| c}}S c c}}w r   rY  rZ  s      rO   r[  z3SyncRunsClient.create_batch.<locals>.filter_payloadz  r\  r]  r^  rv  r_  rw  r`  s          rO   rc  zSyncRunsClient.create_batchq  sL    	G <DDN7+DDyy~~'&  
 	
 Es   9Trd  c                    y r   r   rg  s                         rO   rh  zSyncRunsClient.wait  s    2 '*rQ   ri  c                    y r   r   rk  s                       rO   rh  zSyncRunsClient.wait  s    . '*rQ   )r'  r  rn  rt  rm  r*  r  r   r+  r,  r/  r.  r5  r0  r1  r2  re  rY   r   r3  r8  c          
        |t        j                  dt        d       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fd}|d| dnd}| j                  j                  |d|j                         D ci c]  \  }}|	|| c}}||r|      S d      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.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            checkpoint: The checkpoint to resume from.
            checkpoint_during: (deprecated) Whether to checkpoint during the run (or only at the end/interruption).
            interrupt_before: Nodes to interrupt immediately before they get executed.
            interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
            webhook: Webhook to call after LangGraph API call is done.
            on_disconnect: The disconnect mode to use.
                Must be one of 'cancel' or 'continue'.
            on_completion: Whether to delete or keep the thread created for a stateless run.
                Must be one of 'delete' or 'keep'.
            multitask_strategy: Multitask strategy to use.
                Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
            if_not_exists: How to handle missing thread. Defaults to 'reject'.
                Must be either 'reject' (raise error if missing), or 'create' (create new thread).
            after_seconds: The number of seconds to wait before starting the run.
                Use to schedule future runs.
            raise_error: Whether to raise an error if the run fails.
            headers: Optional custom headers to include with the request.
            on_run_created: Optional callback to call when a run is created.
            durability: The durability to use for the run. Values are "sync", "async", or "exit".
                "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
                "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
                "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps

        Returns:
            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"},
                context={"model_name": "anthropic"},
                interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
                interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
                webhook="https://my.fake.webhook.com",
                multitask_strategy="interrupt"
            )
            print(final_state_of_run)
            ```

            ```shell

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

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

        Nr:  r   r   r'  r  rt  rm  rn  rW  r+  r,  r/  r  r   r0  r1  r.  r*  r5  r2  )re  r8  c                8    rt        |       x}r	 |       yyyr>  r?  r@  s     rO   r   z(SyncRunsClient.wait.<locals>.on_responseH  rA  rQ   r  rm  rB  r   rC  )r  r  rE  r  r   r  )r   rk   rW  r'  r  rn  rt  rm  r*  r  r   r+  r,  r/  r.  r5  r0  r1  r2  re  rY   r   r3  r8  rG  rH  ry  r   rI  s                         `      rO   rh  zSyncRunsClient.wait  s   h (MMv"

U
GN'--/C$!QQ]ACTX

 f
 w
 
 L
  0
 
 w
 *
 ]
 !"4
 ]
  ]!
"  !2#
$ ]%
& ]'
( '$+
0	) 2;1Fi	{*-L 	 yy**#*==?D41aam!Q$D'5 + 
 	
 <@ + 
 	
; D@ Es   
C"
C"
=
C(C(r  r   rq  c                   ||d}|||d<   |r||d<   |r|j                  |       | j                  j                  d| d||      S )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.
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        Returns:
            The runs for the thread.

        ???+ example "Example Usage"

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

        r  r  r  r  rS  r   r]  rs  s	            rO   re   zSyncRunsClient.listY  sg    F 27&'I%+L"%+L"'yy}}	{%(w  
 	
rQ   c               J    | 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` object.

        ???+ example "Example Usage"

            ```python

            run = client.runs.get(
                thread_id="thread_id_to_delete",
                run_id="run_id_to_delete",
            )
            ```
        r  ru  rR  rU  rv  s        rO   rl   zSyncRunsClient.get  s2    : yy}}	{&176  
 	
rQ   rw  rx  c                   |rdnd|d}|r|j                  |       |r'| j                  j                  d| d| ddd||	      S | j                  j                  d| 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.
            params: Optional query parameters 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"
            )
            ```

        r   r   r{  r  ru  r|  rB  Nr   r}  r~  s           rO   r  zSyncRunsClient.cancel  s    L A1
 '99..I;fVHG<# /   yy~~	{&8	  
 	
rQ   c               N    | j                   j                  d| 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.
            params: Optional query parameters 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"
            )
            ```

        r  ru  r  r   rR  r  rv  s        rO   r  zSyncRunsClient.join  s;    < yy**	{&6	 + 
 	
rQ   r  c                   ||d}|r|j                  |       | j                  j                  d| d| dd|i |rd|ini |xs i xs 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.
            params: Optional query parameters to include with the request.
            last_event_id: The last event ID to use for the stream.

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

        )r  r  r  ru  r  r   r  Nr   r  r  s	            rO   r  zSyncRunsClient.join_stream  s    T '$8
 'yy	{&87DO]3"=b     	
 		
rQ   c               L    | j                   j                  d| d| ||       y)aR  Delete a run.

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

        Returns:
            `None`

        ???+ example "Example Usage"

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

        r  ru  rR  Nr  rv  s        rO   r   zSyncRunsClient.deleteA  s/    < 				{&176 	 	
rQ   r*  )0rk   rG   rW  rG   r'  r  r  r  r  r  r(  r  rn  r"  rt  r  rm  r  r  r  r   r  r*  r  r+  r  r,  r  r-  r  r.  r  r/  r  r0  r  r1  r  r2  r  rY   r4  r   r3  r3  r  r   r  ).rk   r   rW  rG   r'  r  r  r  r  r  r(  r  r)  r  rn  r"  rt  r  rm  r  r*  r  r+  r  r,  r  r-  r  r.  r  r5  r  r1  r  r/  r  r2  r  rY   r4  r   r3  r3  r  r   r  )6rk   r  rW  rG   r'  r  r  r  r  r  r(  r  r)  r  rn  r"  rt  r  rm  r  r  r  r   r  r*  r  r+  r  r,  r  r-  r  r.  r  r5  r  r/  r  r0  r  r1  r  r2  r  rY   r4  r   r3  r3  r  r8  r  r   r  )*rk   r   rW  rG   r'  r  r  r  r  r  r(  r  r)  r  rn  r"  rt  r  rm  r  r*  r  r+  r  r,  r  r/  r  r5  r  r1  r  r2  r  rY   r4  r   r3  r3  r  r   r*   r  r  r  r  r  )0rk   r  rW  rG   r'  r  r  r  rn  r"  rt  r  rm  r  r*  r  r  r  r   r  r+  r  r,  r  r/  r  r.  r  r5  r  r0  r  r1  r  r2  r  re  r  rY   r4  r   r3  r3  r  r8  r  r   r  r  r  r  r  )rk   rG   rj   rG   r  r  r  r  rY   r4  r   r3  r  r  r   r  r  r  r   rQ   rO   r  r    sM     #"&9A!&-1 $"&(,$()-7;6:.2/3"7;,0$(,0)-EI3## #
 #  # 7# # +# #  # &# "# '# 5#  4!#" ,##$ -%#& '#( 5)#* *+#, "-#. */#0 '1#2 C3#4 
5# #8  #"&9A!&!&-1 $"&)-7;6:.2/359,0"$(,0)-EI1## #
 #  # 7# # # +# #  # '# 5# 4#  ,!#" -##$ 3%#& *'#( )#* "+#, *-#. '/#0 C1#2 
3# #@ #"&9A!&!&-1 $"&(,$()-7;6:.2/359"7;,0$(,0)-EI(,9X
X
 X

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

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

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

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

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

 *
 '
 

L *,0)-8
8
 8

 8
 8
 *8
 '8
 
8
~ -1)-#
#
 #

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

 #8
 >8
 *8
 '8
 "8
 
8
~ -1)- 
 
  

 * 
 ' 
 
 
rQ   r  c                  T   e Zd ZdZddZ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Zddd	 	 	 	 	 	 	 ddZddd	d
dddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ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   rO  r  s     rO   r   zSyncCronClient.__init__w  r  rQ   Nr  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.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
            interrupt_before: Nodes to interrupt immediately before they get executed.
            interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
            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:
            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"},
                context={"model_name": "openai"},
                interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
                interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
                webhook="https://my.fake.webhook.com",
                multitask_strategy="interrupt"
            )
            ```
        )r  r'  rt  rn  rm  rW  r+  r,  r*  r/  r0  r  r  rv  r  r  s                     rO   r  z SyncCronClient.create_for_threadz  s    x ! ( 0.!2"4
 %,MMOEDAqq}1a4EEyy~~	{+.	  
 	
 Fs
   
AA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.
            context: Static context to add to the assistant.
                !!! version-added "Added in version 0.6.0"
            checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
            interrupt_before: Nodes to interrupt immediately before they get executed.
            interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
            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:
            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"},
                context={"model_name": "openai"},
                checkpoint_during=True,
                interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
                interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
                webhook="https://my.fake.webhook.com",
                multitask_strategy="interrupt"
            )
            ```

        )r  r'  rt  rn  rm  rW  r+  r,  r/  r*  r0  r  rv  r  r  s                    rO   rz  zSyncCronClient.create  s}    v ! ( 0.!2"4
 %,MMOEDAqq}1a4EEyy~~  
 	
 Fs
   
AArR  c               F    | 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.
            params: Optional query parameters 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  rR  Nr  r  s       rO   r   zSyncCronClient.delete  s$    6 			<y176RrQ   r  r   r  c       	            ||||d}
|r||
d<   |r||
d<   |r||
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:
            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  rv  r  r  s                rO   rn   zSyncCronClient.search3  s    ~ )"	
 !(GI$.GL! &GH$+MMOEDAqq}1a4EEyy~~ w  
 	
 Fs
   
A"A"r  c               `    i }|r||d<   |r||d<   | j                   j                  d|||      S )r  rW  rk   r  rv  rw  r  s         rO   r  zSyncCronClient.count  sF    & #%&2GN##,GK yy~~gwv  
 	
rQ   )r  r  r   r   r  r  r  r  r  r  r   rQ   rO   r  r  d  s   $  #-1 $"&)-3726")-,0)-!N
N
 N

 N
 N
 +N
 N
  N
 'N
 1N
 0N
 N
 'N
 *N
  '!N
" 
#N
j #-1 $"&)-3726")-,0)-J
J
 	J

 J
 +J
 J
  J
 'J
 1J
 0J
 J
 'J
 *J
 'J
  
!J
` -1)-SS *	S
 'S 
S@ $( $%)'+/3,0)-M
 !M
 	M

 M
 M
 #M
 %M
 -M
 *M
 'M
 
M
d $( $,0)-
 !
 	

 *
 '
 

rQ   r  c                     e Zd ZdZddZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 d	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 ddd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   rO  rP  s     rO   r   zSyncStoreClient.__init__  rQ  rQ   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.
            params: Optional query parameters 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  rv  Nr  r  s
             rO   r  zSyncStoreClient.put_item  ss    H  	Ee| /w6gh 	 #
 			!8'RX 	 	
rQ   r  c                  |D ]  }d|v st        d| d       |dj                  |      d}|||d<   |r|j                  |       | j                  j	                  d||      S )at  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:
            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"  ri  r  r  r   )rT   r  r   r   rl   )r   ri  r"  r  rY   r   r  r_  s           rO   r  zSyncStoreClient.get_item  s    X  	Ee| /w6gh 	  #)1DE"*5L''yy}}^L'}RRrQ   c               H    | j                   j                  d||d||       y)as  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.
            params: Optional query parameters 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  rY  rv  Nr  r  s        rO   r  zSyncStoreClient.delete_item  s,    : 			95	 	 	
rQ   c	               d    ||||||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.
            params: Optional query parameters to include with the request.

        Returns:
            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 ...
                ]
            }
            ```
        r  r  rv  r  r  s
             rO   r  zSyncStoreClient.search_itemsA  sK    x !1&
 yy~~!(	  
 	
rQ   rR  c               b    |||||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:
            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"],
                ...
            ]
            ```
        r  r  rv  r  r  s	            rO   r  zSyncStoreClient.list_namespaces  sH    ` "
 yy~~(	  
 	
rQ   r*  r  r  r  r  r  r  r  )NNNr  r   r  r  r   rQ   rO   r  r    s    48,0)-2
 	2

 !2
 12
 2
 *2
 '2
 2
 
2
t $(,0)-7S 	7S 7S !7S *7S '7S 
7S| -1)-"
 	"

 *"
 '"
 "
 
"
P ,0 #',0)-H
 )	H

 H
 H
 H
 !H
 *H
 'H
'H
 
H
X $(#' $;
 -1)-;
 ;
 !;
 	;

 ;
 ;
 *;
 ';
 
;
rQ   r  c                \    | j                         D ci c]  \  }}|	|| c}}S c c}}w r   rY  )drG  rH  s      rO   r  r    s(    WWY8TQ!-AqD888r]  zlist[httpx.ASGITransport]r   c                (    t         D ]	  }| |_         y r   )r   rz   )rz   r   s     rO   configure_loopback_transportsr`    s    + 		rQ   r   )maxsizec                 f    	 ddl m}  | j                  S # t        $ r t        j                  cY S w xY w)Nr   asgi_transport)langgraph_apird  ASGITransportImportErrorr   rc  s    rO   r   r     s1    #0+++ #"""#s    00)rL   r  r   r  )rL   r  rW   r4  r   zdict[str, str])rf   r
   r   r
   )rp   r  r   zRunCreateMetadata | None)
rt   r  rL   r  rY   r4  ru   TimeoutTypes | Noner   rv   )r   r
   r   z#tuple[dict[str, str], bytes | None])r   r  r   r
   )
rt   r  rL   r  rY   r4  ru   rh  r   r  )r   r
   r   ztuple[dict[str, str], bytes])r^  r  r   zdict[str, Any])rz   r
   r   r   )r   ztype[httpx.ASGITransport])wr   
__future__r   r@  	functoolsloggingrI   rer   r  collections.abcr   r   r   r   r   typesr	   typingr
   r   r   r   r   rC  rU   langgraph_sdk.errorsr   r   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.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   langgraph_sdk.sser;   r<   r=   	getLoggerr   r   rS   r  rH   rP   r[   rh   compilerm   rs   r   rv   r   r   r   r   r   r   r   r   r  r  r  r  r  r   r  r  r  r  r  r   __annotations__r`  	lru_cacher   r  tupler   TimeoutTypesr   rQ   rO   <module>ry     s   #    	 	 
  P P      R, , , , , , , , , , , ,Z J I			8	$ " D&(# (4 2, *P. #

< 
" &(,#'o#	o# o# &	o#
 !o# o#d#, #,LA AH v

 v

rE

 E

PT
 T
nE
 E
P
g
 g
X	 &(,#'B'	B' B' &	B'
 !B' B'J&% &%RA AH	0
r

 r

jt	
 t	
nB
 B
Jx
 x
v	g
 g
T	9 57 1 6
 Q#  # 	EDL%$,&'( EDL%$,edlBCD mm	 rQ   