
    =Kih                        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)
z2Async client for managing assistants in LangGraph.    )annotations)Mapping)AnyLiteralcastoverloadN)
HttpClient)	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AssistantsClient   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                    Xl         g Nhttp)selfr   s     a/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/langgraph_sdk/_async/assistants.py__init__AssistantsClient.__init__*   s    	    Nheadersparamsc               X   #    U R                   R                  SU 3X#S9I Sh  vN $  N7f)a6  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/r#   Nr   getr   assistant_idr$   r%   s       r   r)   AssistantsClient.get-   s8     R YY]]<.)7 # 
 
 	
 
s   !*(*F)xrayr$   r%   c                  #    SU0nU(       a  UR                  U5        U R                  R                  SU S3XSS9I Sh  vN $  N7f)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__'}
            ]
    }
    ```


r-   r'   z/graphr%   r$   N)updater   r)   )r   r+   r-   r$   r%   query_paramss         r   	get_graphAssistantsClient.get_graphZ   sT     d ~'YY]]<./ # 
 
 	
 
s   >A AAc               Z   #    U R                   R                  SU S3X#S9I Sh  vN $  N7f)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'
                            }
                    }
            }
    }
    ```

r'   z/schemasr#   Nr(   r*   s       r   get_schemasAssistantsClient.get_schemas   s:     j YY]]<.17 # 
 
 	
 
s   "+)+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I Sh  vN $ U R                  R                  SU S3UUS9I Sh  vN $  N+ N7f)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.

recurseNr'   z/subgraphs/r/   z
/subgraphs)dictr   r)   )r   r+   	namespacer8   r$   r%   
get_paramss          r   get_subgraphsAssistantsClient.get_subgraphs  s     ,  )
7J7$v,7J |nK	{C! '    |nJ7! '   s$   AA4A0&A4+A2,A42A4)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I Sh  vN $  N7f)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configr>   r?   r+   r@   rA   rB   z/assistantsjsonr$   r%   Nr   post)r   rD   rE   r>   r?   r+   r@   rA   r$   rB   r%   payloads               r   createAssistantsClient.create3  s     f #
  &H!(I"*J&2N##,K "FO%0M"YY^^ $ 
 
 	
 
s   A0A92A73A9)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I Sh  vN $  N7f)
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}
    )
    ```

rD   NrE   r>   r?   rA   rB   r'   rF   )r   patch)r   r+   rD   rE   r>   r?   rA   r$   rB   r%   rJ   s              r   r0   AssistantsClient.updatez  s     ^ #%"*J &H!(I"*J"FO%0M"YY__<.)	 % 
 
 	
 
s   AA(!A&"A()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I Sh  vN   g N7f)aR  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_client(url="http://localhost:2024")
    await client.assistants.delete(
        assistant_id="my_assistant_id"
    )
    ```

TrP   r'   Nr#   )r0   r   delete)r   r+   rP   r$   r%   r1   s         r   rR   AssistantsClient.delete  sa     > (*-1L)*'ii<.)'4  
 	
 	
s   AAAA
   r   )
r?   rD   rA   limitoffsetsort_by
sort_orderselectr$   r%   c                  #    g 7fr    r   r?   rD   rA   rU   rV   rW   rX   rY   response_formatr$   r%   s               r   searchAssistantsClient.search  s
      $'   array)r?   rD   rA   rU   rV   rW   rX   rY   r]   r$   r%   c                  #    g 7fr   r[   r\   s               r   r^   r_     s
      r`   c               z  ^#    U	S;  a  [        SU	< 3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I S
h  vN 5      nU	S:X  a  UTS.$ U$  N7f)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"]
    ```
)ra   objectz1response_format must be 'array' or 'object', got 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_pagination3AssistantsClient.search.<locals>.capture_paginationV  s    "**../BCKr"   z/assistants/searchrd   )rG   r$   r%   on_response)
assistantsnext)rg   zhttpx.ResponsereturnNone)
ValueErrorr   listr
   r   rI   )r   r?   rD   rA   rU   rV   rW   rX   rY   r]   r$   r%   rJ   ri   rl   rh   s                  @r   r^   r_   	  s     n "55COCVW  #
 "*J"*J"FO!(I$.L! &H"&	D O))..$2AX2M.SW !  	

 h&",kBBs   B B;#B9
$B;)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I Sh  vN $  N7f)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   NrH   )r   r?   rD   rA   r$   r%   rJ   s          r   countAssistantsClient.counth  sW     , #%"*J"*J"FOYY^^gv $ 
 
 	
 
s   AAA	Ac               ~   #    UUS.nU(       a  X'S'   U R                   R                  SU S3UUUS9I Sh  vN $  N7f)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"
    )
    ```
re   r?   r'   z	/versionsrF   NrH   )r   r+   r?   rU   rV   r$   r%   rJ   s           r   get_versionsAssistantsClient.get_versions  s[     D #
 "*JYY^^<.	2	 $ 
 
 	
 
s   4=;=c               f   #    SU0nU R                   R                  SU S3UUUS9I Sh  vN $  N7f)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
    )
    ```

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

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

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

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

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