Ë
    òÏjÐr  ã                  ó¼   — d Z ddlmZ ddlZddlmZmZmZ ddlm	Z	m
Z
mZ ddlmZ ddlmZ ddl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   G d
„ d«      Z!y)z/Async client for managing threads in LangGraph.é    )ÚannotationsN)ÚAsyncIteratorÚMappingÚSequence)ÚAnyÚLiteralÚoverload)Ú
HttpClient)ÚAsyncThreadStream)Ú_quote_path_param)Ú
CheckpointÚJsonÚOnConflictBehaviorÚPruneStrategyÚQueryParamTypesÚ	SortOrderÚ
StreamPartÚThreadÚThreadSelectFieldÚThreadSortByÚThreadStateÚThreadStatusÚThreadStreamModeÚThreadUpdateStateResponsec                  ó   — e Zd ZdZd'd„Zddddœ	 	 	 	 	 	 	 	 	 d(d„Zdddddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)d„Zeddddd	œ	 	 	 	 	 	 	 	 	 	 	 	 	 d*d
„«       Zeddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 d+d„«       Zeddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 d,d„«       Z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dœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d.d„Z
ddddddœ	 	 	 	 	 	 	 	 	 	 	 d/d„Zdddœ	 	 	 	 	 	 	 d-d„Zddddœ	 	 	 	 	 	 	 	 	 d0d„Z	 	 d1ddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 d2d„Zddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d3d„Zdddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d4d „Z	 d5ddd!d"œ	 	 	 	 	 	 	 	 	 	 	 d6d#„Zdd$ddd%œ	 	 	 	 	 	 	 	 	 	 	 d7d&„Zy)8ÚThreadsClientaÍ  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 ©N)Úhttp)Úselfr   s     úY/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/langgraph_sdk/_async/threads.pyÚ__init__zThreadsClient.__init__-   s	   € Øˆ�	ó    N)ÚincludeÚheadersÚparamsc             ƒ  óÐ   K  — i }|rdj                  |«      |d<   |r|j                  |«       | j                  j                  dt	        |«      › �||xs d¬«      ƒ d{  –—† S 7 Œ­w)a  Get a thread by ID.

        Args:
            thread_id: The ID of the thread to get.
            include: Additional fields to include in the response.
                Supported values: `"ttl"`.
            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'}
            }
            ```

        Ú,r$   ú	/threads/N©r%   r&   )ÚjoinÚupdater   Úgetr   )r    Ú	thread_idr$   r%   r&   Úquery_paramss         r!   r-   zThreadsClient.get0   su   è ø€ ðT (*ˆÙØ&)§h¡h¨wÓ&7ˆL˜Ñ#ÙØ×Ñ Ô'Ø—Y‘Y—]‘]ØÔ)¨)Ó4Ð5Ð6ØØÒ' 4ð #ó 
÷ 
ð 	
ð 
ús   ‚AA&ÁA$Á A&)Úmetadatar.   Ú	if_existsÚ
superstepsÚgraph_idÚttlr%   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"
            )
            ```
        r.   r3   r0   r1   ÚupdatesÚvaluesÚcommandÚas_node)r7   r8   r9   r2   NÚdelete©r4   Ústrategyr4   z/threads©Újsonr%   r&   )r-   Ú
isinstanceÚintÚfloatr   Úpost)r    r0   r.   r1   r2   r3   r4   r%   r&   ÚpayloadÚsÚus               r!   ÚcreatezThreadsClient.createe   s,  è ø€ ðV #%ˆÙØ#,ˆG�KÑ Ù‘xð#Ø’>˜rð#á-5�J Ñ)¸2ð#ˆG�JÑñ Ø#,ˆG�KÑ Ùñ $ô%ñ $�Að ð "# 9¢ó ñ ".˜Að	 '(¨¡kØ'(§u¡u¨YÓ'7Ø'(¨¡|óð
 ".ñ ò	ð $ò%ˆG�LÑ!ð ˆ?Ü˜#¤¤U˜|Ô,Ø),¸(Ñ!C�˜’à!$�˜‘à—Y‘Y—^‘^Ø˜W¨g¸fð $ó 
÷ 
ð 	
ùò# ùó%ð&
ús4   ‚/C±B?¾"B:Á B?Á&ACÂ5CÂ6CÂ:B?Â?CF)r4   Úreturn_minimalr%   r&   c             ƒ  ó   K  — y ­wr   © ©r    r.   r0   r4   rG   r%   r&   s          r!   r,   zThreadsClient.update²   s   è ø€ ð ùó   ‚)r4   r%   r&   c             ƒ  ó   K  — y ­wr   rI   rJ   s          r!   r,   zThreadsClient.update¾   s   è ø€ ð ùrK   c             ƒ  ó   K  — y ­wr   rI   rJ   s          r!   r,   zThreadsClient.updateÊ   s   è ø€ ð ùrK   c             ƒ  óü   K  — d|i}|�$t        |t        t        f«      r	|ddœ|d<   n||d<   t        |xs i «      }|rd|d<   | j                  j                  dt        |«      › �||xs d|¬	«      ƒ d{  –—† S 7 Œ­w)
aß  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").
            return_minimal: If `True`, request a 204 response with no body.
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        Returns:
            The updated thread, or `None` when `return_minimal=True`.

        ???+ 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,
            )
            ```
        r0   Nr:   r;   r4   zreturn=minimalÚPreferr)   r=   )r?   r@   rA   Údictr   Úpatchr   )	r    r.   r0   r4   rG   r%   r&   rC   Úrequest_headerss	            r!   r,   zThreadsClient.updateÖ   s›   è ø€ ðH $.¨xÐ"8ˆØˆ?Ü˜#¤¤U˜|Ô,Ø),¸(Ñ!C�˜’à!$�˜‘Ü˜wš}¨"Ó-ˆÙØ(8ˆO˜HÑ%Ø—Y‘Y—_‘_ØÔ)¨)Ó4Ð5Ð6ØØ#Ò+ tØð	 %ó 
÷ 
ð 	
ð 
ús   ‚A3A<Á5A:Á6A<r*   c             ƒ  ót   K  — | j                   j                  dt        |«      › �||¬«      ƒ 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)   r*   N)r   r:   r   ©r    r.   r%   r&   s       r!   r:   zThreadsClient.delete
  s?   è ø€ ð6 �i‰i×ÑØÔ)¨)Ó4Ð5Ð6ÀÐPVð ó 
÷ 	
ò 	
ús   ‚.8°6±8é
   r   )r0   r7   ÚidsÚstatusÚlimitÚoffsetÚsort_byÚ
sort_orderÚselectÚextractr%   r&   c             ƒ  óÖ   K  — ||dœ}|r||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.
            select: List of fields to include in the response.
            extract: Dictionary mapping aliases to JSONB paths to extract
                from thread data. Paths use dot notation for nested keys and
                bracket notation for array indices (e.g.,
                `{"last_msg": "values.messages[-1]"}`). Extracted values are
                returned in an `extracted` field on each thread. Maximum 10
                paths per request.
            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
            )
            ```

        )rX   rY   r0   r7   rV   rW   rZ   r[   r\   r]   z/threads/searchr=   N©r   rB   )r    r0   r7   rV   rW   rX   rY   rZ   r[   r\   r]   r%   r&   rC   s                 r!   ÚsearchzThreadsClient.search)  s¯   è ø€ ðn Øñ#
ˆñ Ø"*ˆG�JÑÙØ &ˆG�HÑÙØ ˆG�E‰NÙØ &ˆG�HÑÙØ!(ˆG�IÑÙØ$.ˆG�LÑ!ÙØ &ˆG�HÑÙØ!(ˆG�IÑØ—Y‘Y—^‘^ØØØØð	 $ó 
÷ 
ð 	
ð 
ús   ‚A A)Á"A'Á#A))r0   r7   rW   r%   r&   c             ƒ  óŠ   K  — i }|r||d<   |r||d<   |r||d<   | j                   j                  d|||¬«      ƒ d{  –—† S 7 Œ­w)a«  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.
        r0   r7   rW   z/threads/countr=   Nr_   )r    r0   r7   rW   r%   r&   rC   s          r!   ÚcountzThreadsClient.countz  sa   è ø€ ð* #%ˆÙØ"*ˆG�JÑÙØ &ˆG�HÑÙØ &ˆG�HÑØ—Y‘Y—^‘^Ø 7°GÀFð $ó 
÷ 
ð 	
ð 
ús   ‚:A¼A½Ac             ƒ  óv   K  — | j                   j                  dt        |«      › 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)   z/copyNr=   ©r   rB   r   rT   s       r!   ÚcopyzThreadsClient.copyš  sH   è ø€ ð6 —Y‘Y—^‘^ØÔ)¨)Ó4Ð5°UÐ;ØØØð	 $ó 
÷ 
ð 	
ð 
ús   ‚09²7³9r:   )r<   r%   r&   c             ƒ  óx   K  — d|i}|dk7  r||d<   | j                   j                  d|||¬«      ƒ d{  –—† S 7 Œ­w)aY  Prune threads by ID.

        Args:
            thread_ids: List of thread IDs to prune.
            strategy: The prune strategy. `"delete"` removes threads entirely.
                `"keep_latest"` prunes old checkpoints but keeps threads and their
                latest state. Defaults to `"delete"`.
            headers: Optional custom headers to include with the request.
            params: Optional query parameters to include with the request.

        Returns:
            A dict containing `pruned_count` (number of threads pruned).

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            result = await client.threads.prune(
                thread_ids=["thread_1", "thread_2"],
            )
            print(result)  # {'pruned_count': 2}
            ```

        Ú
thread_idsr:   r<   z/threads/pruner=   Nr_   )r    rg   r<   r%   r&   rC   s         r!   ÚprunezThreadsClient.prune¼  sV   è ø€ ðB ˜*ð#
ˆð �xÒØ"*ˆG�JÑØ—Y‘Y—^‘^Ø 7°GÀFð $ó 
÷ 
ð 	
ð 
ús   ‚1:³8´:)Ú	subgraphsr%   r&   c             ƒ  óÂ  K  — |r7| j                   j                  dt        |«      › d�||dœ||¬«      ƒ d{  –—† S |rSd|i}|ri |¥t        |«      ¥}| j                   j	                  dt        |«      › dt        |«      › �||¬«      ƒ d{  –—† S d|i}|ri |¥t        |«      ¥}| j                   j	                  dt        |«      › d	�||¬«      ƒ d{  –—† S 7 Œ¡7 ŒN7 Œ­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)   z/state/checkpoint)Ú
checkpointri   r=   Nri   z/state/)r&   r%   ú/state)r   rB   r   rP   r-   )r    r.   rk   Úcheckpoint_idri   r%   r&   Ú
get_paramss           r!   Ú	get_statezThreadsClient.get_stateå  s!  è ø€ ñ\ ØŸ™Ÿ™ØÔ-¨iÓ8Ð9Ð9JÐKØ$.¸YÑGØØð	 (ó ÷ ð ñ Ø% yÐ1ˆJÙØ; 
Ð;¬d°6«lÐ;�
ØŸ™Ÿ™ØÔ-¨iÓ8Ð9¸ÔARÐS`ÓAaÐ@bÐcØ!Øð 'ó ÷ ð ð & yÐ1ˆJÙØ; 
Ð;¬d°6«lÐ;�
ØŸ™Ÿ™ØÔ-¨iÓ8Ð9¸Ð@Ø!Øð 'ó ÷ ð ð'øðøðús5   ‚5C·C¸ACÂCÂACÃCÃCÃCÃC)r9   rk   rm   r%   r&   c             ƒ  ó¨   K  — d|i}|r||d<   |r||d<   |r||d<   | j                   j                  dt        |«      › 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': {}
                }
            }
            ```
        r7   rm   rk   r9   r)   rl   r=   Nrd   )	r    r.   r7   r9   rk   rm   r%   r&   rC   s	            r!   Úupdate_statezThreadsClient.update_statem  s~   è ø€ ðf �fð#
ˆñ Ø'4ˆG�OÑ$ÙØ$.ˆG�LÑ!ÙØ!(ˆG�IÑØ—Y‘Y—^‘^ØÔ)¨)Ó4Ð5°VÐ<ØØØð	 $ó 
÷ 
ð 	
ð 
úó   ‚A	AÁAÁA)rX   Úbeforer0   rk   r%   r&   c             ƒ  ó¨   K  — d|i}|r||d<   |r||d<   |r||d<   | j                   j                  dt        |«      › 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,
            )
            ```

        rX   rs   r0   rk   r)   z/historyr=   Nrd   )	r    r.   rX   rs   r0   rk   r%   r&   rC   s	            r!   Úget_historyzThreadsClient.get_history¯  s~   è ø€ ðJ �Uð#
ˆñ Ø &ˆG�HÑÙØ"*ˆG�JÑÙØ$.ˆG�LÑ!Ø—Y‘Y—^‘^ØÔ)¨)Ó4Ð5°XÐ>ØØØð	 $ó 
÷ 
ð 	
ð 
úrr   Ússe)r%   Úrun_start_timeoutÚ	transportc          	     óš   — |dvrt        d«      ‚t        | j                  |�|nt        t	        j
                  «       «      ||||du|¬«      S )uÁ  Open a v3 thread-centric streaming session.

        When `thread_id` is None, a fresh UUIDv4 is minted client-side and
        included in the URL of subsequent `POST /threads/{thread_id}/...`
        calls. The server creates the thread row lazily on the first
        `run.start` (internal server detail â€” the SDK does not send any
        `if_not_exists` flag). The v3 protocol response carries only
        `run_id`, never `thread_id` â€” that's why the SDK mints the id
        client-side.

        Args:
            thread_id: optional explicit thread identifier. Defaults to a
                fresh UUIDv4.
            assistant_id: assistant the run will use. Required.
            headers: optional headers forwarded on every command and event
                request for this stream session.
            run_start_timeout: optional seconds to wait for an in-flight
                `run.start` before subscribing operations raise
                `asyncio.TimeoutError`. Defaults to `None` (wait forever).
            transport: event transport to use â€” `"sse"` (default) or
                `"websocket"`.

        Returns:
            An `AsyncThreadStream` to use as an async context manager.
        )rv   Ú	websocketz'transport must be 'sse' or 'websocket'.N)r   r.   Úassistant_idr%   rw   Úexplicit_thread_idÚtransport_kind)Ú
ValueErrorr   r   ÚstrÚuuidÚuuid4)r    r.   r{   r%   rw   rx   s         r!   ÚstreamzThreadsClient.streamã  sW   € ðD Ð0Ñ0ÜÐFÓGÐGÜ Ø—‘Ø#,Ð#8‘i¼cÄ$Ç*Á*Ã,Ó>OØ%ØØ/Ø(°Ð4Ø$ô
ð 	
r#   Ú	run_modes)Úlast_event_idÚstream_moder%   r&   c             ƒ  ó¬   K  — d|i}|r|j                  |«       | j                  j                  dt        |«      › 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)   z/streamÚGETzLast-Event-IDr*   )r,   r   r‚   r   )r    r.   r„   r…   r%   r&   r/   s          r!   Újoin_streamzThreadsClient.join_stream  s�   è ø€ ðB ˜;ð
ˆñ Ø×Ñ Ô'Ø�y‰y×ÑØÔ)¨)Ó4Ð5°WÐ=ØðÙ7D�O ]Ñ3È"ðà’=˜bðð  ð  ó 
ð 	
ùs   ‚AA)r   r
   ÚreturnÚNone)
r.   r   r$   úSequence[str] | Noner%   úMapping[str, str] | Noner&   úQueryParamTypes | Noner‰   r   )r0   r   r.   ú
str | Noner1   zOnConflictBehavior | Noner2   z4Sequence[dict[str, Sequence[dict[str, Any]]]] | Noner3   rŽ   r4   úint | Mapping[str, Any] | Noner%   rŒ   r&   r�   r‰   r   )r.   r   r0   úMapping[str, Any]r4   r�   rG   zLiteral[False]r%   rŒ   r&   r�   r‰   r   )r.   r   r0   r�   r4   r�   rG   zLiteral[True]r%   rŒ   r&   r�   r‰   rŠ   )r.   r   r0   r�   r4   r�   rG   Úboolr%   rŒ   r&   r�   r‰   zThread | None)r.   r   r%   rŒ   r&   r�   r‰   rŠ   )r0   r   r7   r   rV   r‹   rW   úThreadStatus | NonerX   r@   rY   r@   rZ   zThreadSortBy | Noner[   zSortOrder | Noner\   zlist[ThreadSelectField] | Noner]   zdict[str, str] | Noner%   rŒ   r&   r�   r‰   zlist[Thread])r0   r   r7   r   rW   r’   r%   rŒ   r&   r�   r‰   r@   )
rg   zSequence[str]r<   r   r%   rŒ   r&   r�   r‰   zdict[str, Any])NN)r.   r   rk   úCheckpoint | Nonerm   rŽ   ri   r‘   r%   rŒ   r&   r�   r‰   r   )r.   r   r7   z&dict[str, Any] | Sequence[dict] | Noner9   rŽ   rk   r“   rm   rŽ   r%   rŒ   r&   r�   r‰   r   )r.   r   rX   r@   rs   zstr | Checkpoint | Noner0   zMapping[str, Any] | Nonerk   r“   r%   rŒ   r&   r�   r‰   zlist[ThreadState]r   )r.   rŽ   r{   r   r%   rŒ   rw   zfloat | Nonerx   zLiteral['sse', 'websocket']r‰   r   )r.   r   r„   rŽ   r…   z-ThreadStreamMode | Sequence[ThreadStreamMode]r%   rŒ   r&   r�   r‰   zAsyncIterator[StreamPart])Ú__name__Ú
__module__Ú__qualname__Ú__doc__r"   r-   rF   r	   r,   r:   r`   rb   re   rh   ro   rq   ru   r‚   rˆ   rI   r#   r!   r   r      sò  „ ñóð )-Ø,0Ø)-ñ3
àð3
ð &ð	3
ð
 *ð3
ð 'ð3
ð 
ó3
ðp Ø $Ø/3ØKOØ#Ø.2Ø,0Ø)-ñK
ð ðK
ð ð	K
ð
 -ðK
ð IðK
ð ðK
ð ,ðK
ð *ðK
ð 'ðK
ð 
óK
ðZ ð /3Ø).Ø,0Ø)-ñ	àð	ð $ð		ð
 ,ð	ð 'ð	ð *ð	ð 'ð	ð 
ò	ó ð	ð ð /3à,0Ø)-ñ	àð	ð $ð		ð
 ,ð	ð &ð	ð *ð	ð 'ð	ð 
ò	ó ð	ð ð /3à,0Ø)-ñ	àð	ð $ð		ð
 ,ð	ð ð	ð *ð	ð 'ð	ð 
ò	ó ð	ð  /3Ø$Ø,0Ø)-ñ2
àð2
ð $ð	2
ð
 ,ð2
ð ð2
ð *ð2
ð 'ð2
ð 
ó2
ðp -1Ø)-ñ
àð
ð *ð	
ð
 'ð
ð 
ó
ðD ØØ$(Ø&*ØØØ'+Ø'+Ø15Ø)-Ø,0Ø)-ñO
ð ðO
ð ð	O
ð
 "ðO
ð $ðO
ð ðO
ð ðO
ð %ðO
ð %ðO
ð /ðO
ð 'ðO
ð *ðO
ð 'ðO
ð 
óO
ðh ØØ&*Ø,0Ø)-ñ
ð ð
ð ð	
ð
 $ð
ð *ð
ð 'ð
ð 
ó
ðH -1Ø)-ñ 
àð 
ð *ð	 
ð
 'ð 
ð 
ó 
ðL #+Ø,0Ø)-ñ'
à!ð'
ð  ð	'
ð
 *ð'
ð 'ð'
ð 
ó'
ðX )-Ø$(ð	Fð  Ø,0Ø)-ñFàðFð &ðFð "ð	Fð ðFð *ðFð 'ðFð 
óFðZ #Ø(,Ø$(Ø,0Ø)-ñ@
àð@
ð 7ð@
ð
 ð@
ð &ð@
ð "ð@
ð *ð@
ð 'ð@
ð 
#ó@
ðL Ø*.Ø-1Ø(,Ø,0Ø)-ñ2
àð2
ð ð	2
ð
 (ð2
ð +ð2
ð &ð2
ð *ð2
ð 'ð2
ð 
ó2
ðl !%ð,
ð
 -1Ø*.Ø16ñ,
àð,
ð ð	,
ð
 *ð,
ð (ð,
ð /ð,
ð 
ó,
ðd %)ØEPØ,0Ø)-ñ-
àð-
ð "ð	-
ð
 Cð-
ð *ð-
ð 'ð-
ð 
#ô-
r#   r   )"r—   Ú
__future__r   r€   Úcollections.abcr   r   r   Útypingr   r   r	   Úlanggraph_sdk._async.httpr
   Úlanggraph_sdk._async.streamr   Úlanggraph_sdk._shared.utilitiesr   Úlanggraph_sdk.schemar   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rI   r#   r!   Ú<module>rŸ      sC   ðÙ 5å "ã ß <Ñ <ß )Ñ )å 0Ý 9Ý =÷÷ ÷ ÷ ÷$`
ò `
r#   