
    =Ki0h                        S r SSKJr  SSKJr  SSKJrJrJrJ	r	  SSK
r
SSKJr  SSKJrJrJrJrJrJrJrJrJrJrJrJrJr   " S S	5      rg)
z8Synchronous client for managing assistants in LangGraph.    )annotations)Mapping)AnyLiteralcastoverloadN)SyncHttpClient)	AssistantAssistantSelectFieldAssistantSortByAssistantsSearchResponseAssistantVersionConfigContextGraphSchemaJsonOnConflictBehaviorQueryParamTypes	SortOrder	Subgraphsc                     \ rS rSrSrSS jrSSS.       S S jjrSSSS.         S!S	 jjrSSS.       S"S
 jjr  S#SSS.           S$S jjjr	 S%SSSSSSSSS.                     S&S jjjr
SSSSSSSSS.                   S'S jjrSSSS.         S(S jjr\SSSSSSSSSSS.
                       S)S jj5       r\SSSSSSSSSSSS.                       S*S jj5       rSSSSSSSSSSSS.                       S+S jjrSSSSSS.           S,S jjr   S-SSS.             S.S jjjrSSS.         S/S jjrSrg)0SyncAssistantsClient   aJ  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                    Xl         g Nhttp)selfr   s     `/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/langgraph_sdk/_sync/assistants.py__init__SyncAssistantsClient.__init__)   s    	    Nheadersparamsc               <    U R                   R                  SU 3X#S9$ )aA  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'}
    }
    ```

/assistants/r#   r   getr   assistant_idr$   r%   s       r   r)   SyncAssistantsClient.get,   s+    R yy}}<.)7  
 	
r"   F)xrayr$   r%   c               v    SU0nU(       a  UR                  U5        U R                  R                  SU S3XSS9$ )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__'}
            ]
    }
    ```

r-   r'   z/graphr%   r$   )updater   r)   )r   r+   r-   r$   r%   query_paramss         r   	get_graphSyncAssistantsClient.get_graphY   sG    \ ~'yy}}<./  
 	
r"   c               >    U R                   R                  SU S3X#S9$ )aU  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'
                            }
                    }
            }
    }
    ```

r'   z/schemasr#   r(   r*   s       r   get_schemas SyncAssistantsClient.get_schemas   s-    B yy}}<.17  
 	
r"   c                   SU0nU(       a  0 UE[        U5      EnUb!  U R                  R                  SU SU 3UUS9$ U R                  R                  SU S3UUS9$ )a1  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.

recurser'   z/subgraphs/r/   z
/subgraphs)dictr   r)   )r   r+   	namespacer8   r$   r%   
get_paramss          r   get_subgraphs"SyncAssistantsClient.get_subgraphs  s    (  )
7J7$v,7J 99==|nK	{C! !   99==|nJ7! !  r"   )contextmetadatar+   	if_existsnamer$   descriptionr%   c                   SU0nU(       a  X+S'   U(       a  X;S'   U(       a  XKS'   U(       a  X[S'   U(       a  XkS'   U(       a  X{S'   U	(       a  XS'   U R                   R                  S	XU
S
9$ )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"
    )
    ```
graph_idconfigr>   r?   r+   r@   rA   rB   z/assistantsjsonr$   r%   r   post)r   rD   rE   r>   r?   r+   r@   rA   r$   rB   r%   payloads               r   createSyncAssistantsClient.create7  s    f #
  &H!(I"*J&2N##,K "FO%0M"yy~~  
 	
r"   )rD   rE   r>   r?   rA   r$   rB   r%   c                   0 n
U(       a  X*S'   Ub  X:S'   Ub  XJS'   U(       a  XZS'   U(       a  XjS'   U(       a  XS'   U R                   R                  SU 3U
UU	S9$ )	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

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}
    )
    ```
rD   rE   r>   r?   rA   rB   r'   rF   )r   patch)r   r+   rD   rE   r>   r?   rA   r$   rB   r%   rJ   s              r   r0   SyncAssistantsClient.update~  s~    Z #%"*J &H!(I"*J"FO%0M"yy<.)	  
 	
r"   )delete_threadsr$   r%   c                   0 nU(       a  SUS'   U(       a  UR                  U5        U R                  R                  SU 3UU=(       d    SS9  g)aQ  Delete an assistant.

Args:
    assistant_id: The assistant ID to delete.
    delete_threads: If true, delete all threads with `metadata.assistant_id`
        matching this assistant, along with runs and checkpoints belonging to
        those threads.
    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"
    )
    ```

TrP   r'   Nr#   )r0   r   delete)r   r+   rP   r$   r%   r1   s         r   rR   SyncAssistantsClient.delete  sT    > (*-1L)*'		<.)'4 	 	
r"   
   r   )
r?   rD   rA   limitoffsetsort_by
sort_orderselectr$   r%   c                   g r    r   r?   rD   rA   rU   rV   rW   rX   rY   response_formatr$   r%   s               r   searchSyncAssistantsClient.search  s     $'r"   array)r?   rD   rA   rU   rV   rW   rX   rY   r]   r$   r%   c                   g r   r[   r\   s               r   r^   r_     s     r"   c               V  ^ U	S;  a  [        S5      eUUS.nU(       a  XS'   U(       a  X,S'   U(       a  X<S'   U(       a  XlS'   U(       a  X|S'   U(       a  XS	'   S
mSU4S jjn[        [        [           U R                  R                  SUU
UU	S:X  a  UOS
S95      nU	S:X  a  UTS.$ U$ )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`   objectz+response_format must be 'array' or 'object'rU   rV   r?   rD   rA   rW   rX   rY   Nc                <   > U R                   R                  S5      mg )NzX-Pagination-Next)r$   r)   )responsenext_cursors    r   capture_pagination7SyncAssistantsClient.search.<locals>.capture_paginationU  s    "**../BCKr"   z/assistants/searchrc   )rG   r$   r%   on_response)
assistantsnext)rf   zhttpx.ResponsereturnNone)
ValueErrorr   listr
   r   rI   )r   r?   rD   rA   rU   rV   rW   rX   rY   r]   r$   r%   rJ   rh   rk   rg   s                  @r   r^   r_     s    l "55JKK#
 "*J"*J"FO!(I$.L! &H"&	D OIINN$2AX2M.SW  	

 h&",kBBr"   )r?   rD   rA   r$   r%   c               ~    0 nU(       a  XS'   U(       a  X&S'   U(       a  X6S'   U R                   R                  SXdUS9$ )a  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.
r?   rD   rA   z/assistants/countrF   rH   )r   r?   rD   rA   r$   r%   rJ   s          r   countSyncAssistantsClient.countg  sJ    , #%"*J"*J"FOyy~~gv  
 	
r"   c               b    UUS.nU(       a  X'S'   U R                   R                  SU S3UUUS9$ )aR  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"
    )
    ```

rd   r?   r'   z	/versionsrF   rH   )r   r+   r?   rU   rV   r$   r%   rJ   s           r   get_versions!SyncAssistantsClient.get_versions  sN    D #
 "*Jyy~~<.	2	  
 	
r"   c               J    SU0nU R                   R                  SU S3UUUS9$ )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.

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

versionr'   z/latestrF   rH   )r   r+   rx   r$   r%   rJ   s         r   
set_latestSyncAssistantsClient.set_latest  s=    < $-g"6yy~~<.0	  
 	
r"   r   )r   r	   rm   rn   )r+   strr$   Mapping[str, str] | Noner%   QueryParamTypes | Nonerm   r
   )
r+   r{   r-   z
int | boolr$   r|   r%   r}   rm   zdict[str, list[dict[str, Any]]])r+   r{   r$   r|   r%   r}   rm   r   )NF)r+   r{   r:   
str | Noner8   boolr$   r|   r%   r}   rm   r   r   )rD   r~   rE   Config | Noner>   Context | Noner?   r   r+   r~   r@   zOnConflictBehavior | NonerA   r~   r$   r|   rB   r~   r%   r}   rm   r
   )r+   r{   rD   r~   rE   r   r>   r   r?   r   rA   r~   r$   r|   rB   r~   r%   r}   rm   r
   )
r+   r{   rP   r   r$   r|   r%   r}   rm   rn   )r?   r   rD   r~   rA   r~   rU   intrV   r   rW   AssistantSortBy | NonerX   SortOrder | NonerY   !list[AssistantSelectField] | Noner]   zLiteral['object']r$   r|   r%   r}   rm   r   )r?   r   rD   r~   rA   r~   rU   r   rV   r   rW   r   rX   r   rY   r   r]   zLiteral['array']r$   r|   r%   r}   rm   zlist[Assistant])r?   r   rD   r~   rA   r~   rU   r   rV   r   rW   r   rX   r   rY   r   r]   zLiteral['array', 'object']r$   r|   r%   r}   rm   z*AssistantsSearchResponse | list[Assistant])r?   r   rD   r~   rA   r~   r$   r|   r%   r}   rm   r   )NrT   r   )r+   r{   r?   r   rU   r   rV   r   r$   r|   r%   r}   rm   zlist[AssistantVersion])
r+   r{   rx   r   r$   r|   r%   r}   rm   r
   )__name__
__module____qualname____firstlineno____doc__r    r)   r2   r5   r<   rK   r0   rR   r   r^   rr   ru   ry   __static_attributes__r[   r"   r   r   r      su   
 -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  %,0)-(
(
 	(

 *(
 '(
 
(
T  #*.'+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)-%
%
 %

 *%
 '%
 
%
 %
r"   r   )r   
__future__r   collections.abcr   typingr   r   r   r   httpxlanggraph_sdk._sync.httpr	   langgraph_sdk.schemar
   r   r   r   r   r   r   r   r   r   r   r   r   r   r[   r"   r   <module>r      s:    > " # / /  3   "

 

r"   