Ë
    µŒj6_  ã                  ó:  — d dl mZ d dlmZmZmZmZmZmZm	Z	m
Z
 d dl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 d dlmZ d d	lmZ d d
lmZmZmZ d dlm Z  erd dl!Z!d dl"m#Z# d dl$m%Z& dd„Z'dd„Z(dd„Z)	 	 	 	 dd„Z*	 	 	 	 dd„Z+ e«        G d„ de«      «       Z,y)é    )Úannotations)ÚTYPE_CHECKINGÚAnyÚCallableÚDictÚOptionalÚSequenceÚTypeÚUnion)ÚOpenAIAssistantRunnableÚ
OutputType)Úbeta)ÚCallbackManager)Údumpd)ÚRunnableConfigÚensure_config)ÚBaseTool)Úconvert_to_openai_tool)Ú	BaseModelÚFieldÚmodel_validator)ÚSelfN)ÚNotGiven)ÚToolResourcesc                 ó    — 	 ddl }  | j                  ddi¬«      S # t        $ r}t        d«      |‚d}~wt        $ r}t        d«      |‚d}~ww xY w)zÛGet the OpenAI client.

    Returns:
        openai.OpenAI: OpenAI client

    Raises:
        ImportError: If `openai` is not installed.
        AttributeError: If the installed `openai` version is not compatible.
    r   NúOpenAI-Betaúassistants=v2©Údefault_headersúBUnable to import openai, please install with `pip install openai`.úwPlease make sure you are using a v1.23-compatible version of openai. You can install with `pip install "openai>=1.23"`.)ÚopenaiÚOpenAIÚImportErrorÚAttributeError©r"   Úes     úz/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/agents/openai_assistant/base.pyÚ_get_openai_clientr)      se   € ðÛàˆv�}‰}¨m¸_Ð-MÔNÐNøÜò ÜØPó
àð	ûô ò Üð=ó
ð ð	ûðúó   ‚ ›	A¤0°A¼AÁAc                 ó    — 	 ddl }  | j                  ddi¬«      S # t        $ r}t        d«      |‚d}~wt        $ r}t        d«      |‚d}~ww xY w)zìGet the async OpenAI client.

    Returns:
        openai.AsyncOpenAI: Async OpenAI client

    Raises:
        ImportError: If `openai` is not installed.
        AttributeError: If the installed `openai` version is not compatible.
    r   Nr   r   r   r    r!   )r"   ÚAsyncOpenAIr$   r%   r&   s     r(   Ú_get_openai_async_clientr-   7   sg   € ðÛà!ˆv×!Ñ!°=À/Ð2RÔSÐSøÜò ÜØPó
àð	ûô ò Üð=ó
ð ð	ûðúr*   c                óL   — g }| D ]  }|j                  |ddiddigdœ«       Œ |S )a  Convert file_ids into attachments
    File search and Code interpreter will be turned on by default.

    Args:
        file_ids (list): List of file_ids that need to be converted into attachments.

    Returns:
        list: List of attachments converted from file_ids.
    ÚtypeÚfile_searchÚcode_interpreter)Úfile_idÚtools)Úappend)Úfile_idsÚattachmentsÚids      r(   Ú"_convert_file_ids_into_attachmentsr8   P   sD   € ð €KÛˆØ×ÑàØ! =Ð1°FÐ<NÐ3OÐPñõ	
ð ð Ðó    c                óD   — d}t        | t        «      xr d| v xr | d   |v S )aM  Determine if tool corresponds to OpenAI Assistants built-in.

    Args:
        tool (Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool]):
            Tool that needs to be determined.

    Returns:
        A boolean response of true or false indicating if the tool corresponds to
            OpenAI Assistants built-in.
    )r1   Ú	retrievalr0   r/   )Ú
isinstanceÚdict)ÚtoolÚassistants_builtin_toolss     r(   Ú_is_assistants_builtin_toolr@   e   s8   € ð  PÐä�4œÓò 	7Ø�tˆ^ò	7à�&‰\Ð5Ð5ðr9   c                ó2   — t        | «      r| S t        | «      S )a¨  Convert a raw function/class to an OpenAI tool.

    Note that OpenAI assistants supports several built-in tools,
    such as "code_interpreter" and "retrieval."

    Args:
        tool (Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool]):
            Tools or functions that need to be converted to OpenAI tools.

    Returns:
        Dict[str, Any]: A dictionary of tools that are converted into OpenAI tools.
    )r@   r   )r>   s    r(   Ú_get_assistants_toolrB   z   s   € ô # 4Ô(Øˆä% dÓ+Ð+r9   c                  ó\  — e Zd ZU dZ ee¬«      Zded<   	 dZded<   	 ded<   	 d	Z	d
ed<   	 dZ
ded<   	  ed¬«      dd„«       Zei ddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Z	 d	 	 	 	 	 	 	 dd„Zedddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d d„«       Z	 d	 	 	 	 	 	 	 dd„Zd!d„Zd"d„Zd!d„Zd"d„Zy)#ÚOpenAIAssistantV2RunnableaÍ  Run an OpenAI Assistant.

    Attributes:
        client (Any): OpenAI or AzureOpenAI client.
        async_client (Any): Async OpenAI or AzureOpenAI client.
        assistant_id (str): OpenAI assistant ID.
        check_every_ms (float): Frequency to check progress in milliseconds.
        as_agent (bool): Whether to use the assistant as a LangChain agent.

    Example using OpenAI tools:
        .. code-block:: python

            from langchain.agents.openai_assistant import OpenAIAssistantV2Runnable

            assistant = OpenAIAssistantV2Runnable.create_assistant(
                name="math assistant",
                instructions="You are a personal math tutor. Write and run code to answer math questions.",
                tools=[{"type": "code_interpreter"}],
                model="gpt-4-1106-preview"
            )
            output = assistant.invoke({"content": "What's 10 - 4 raised to the 2.7"})

    Example using custom tools and AgentExecutor:
        .. code-block:: python

            from langchain.agents.openai_assistant import OpenAIAssistantV2Runnable
            from langchain.agents import AgentExecutor
            from langchain.tools import E2BDataAnalysisTool


            tools = [E2BDataAnalysisTool(api_key="...")]
            agent = OpenAIAssistantV2Runnable.create_assistant(
                name="langchain assistant e2b tool",
                instructions="You are a personal math tutor. Write and run code to answer math questions.",
                tools=tools,
                model="gpt-4-1106-preview",
                as_agent=True
            )

            agent_executor = AgentExecutor(agent=agent, tools=tools)
            agent_executor.invoke({"content": "Analyze the data..."})

    Example using custom tools and custom execution:
        .. code-block:: python

            from langchain.agents.openai_assistant import OpenAIAssistantV2Runnable
            from langchain.agents import AgentExecutor
            from langchain_core.agents import AgentFinish
            from langchain.tools import E2BDataAnalysisTool


            tools = [E2BDataAnalysisTool(api_key="...")]
            agent = OpenAIAssistantV2Runnable.create_assistant(
                name="langchain assistant e2b tool",
                instructions="You are a personal math tutor. Write and run code to answer math questions.",
                tools=tools,
                model="gpt-4-1106-preview",
                as_agent=True
            )

            def execute_agent(agent, tools, input):
                tool_map = {tool.name: tool for tool in tools}
                response = agent.invoke(input)
                while not isinstance(response, AgentFinish):
                    tool_outputs = []
                    for action in response:
                        tool_output = tool_map[action.tool].invoke(action.tool_input)
                        tool_outputs.append({"output": tool_output, "tool_call_id": action.tool_call_id})
                    response = agent.invoke(
                        {
                            "tool_outputs": tool_outputs,
                            "run_id": action.run_id,
                            "thread_id": action.thread_id
                        }
                    )

                return response

            response = execute_agent(agent, tools, {"content": "What's 10 - 4 raised to the 2.7"})
            next_response = execute_agent(agent, tools, {"content": "now add 17.241", "thread_id": response.thread_id})

    )Údefault_factoryr   ÚclientNÚasync_clientÚstrÚassistant_idg     @�@ÚfloatÚcheck_every_msFÚboolÚas_agentÚafter)Úmodec                ó‚   — | j                   €2ddl}| j                  j                  } |j                  |¬«      | _         | S )z?Validate that the async client is set, otherwise initialize it.Nr   )Úapi_key)rG   r"   rF   rQ   r,   )Úselfr"   rQ   s      r(   Úvalidate_async_clientz/OpenAIAssistantV2Runnable.validate_async_clientï   s<   € ð ×ÑÐ$Ûà—k‘k×)Ñ)ˆGØ 2 × 2Ñ 2¸7Ô CˆDÔØˆr9   )Úmodel_kwargsrF   Útool_resourcesÚ
extra_bodyc               óî   — |xs
 t        «       }|€ddlm}
 |
} |j                  j                  j
                  d|||D �cg c]  }t        |«      ‘Œ c}|||dœ|¤Ž} | d|j                  |dœ|	¤ŽS c c}w )aø  Create an OpenAI Assistant and instantiate the Runnable.

        Args:
            name (str): Assistant name.
            instructions (str): Assistant instructions.
            tools (Sequence[Union[BaseTool, dict]]): Assistant tools. Can be passed
                in OpenAI format or as BaseTools.
            tool_resources (Optional[Union[AssistantToolResources, dict, NotGiven]]):
                Assistant tool resources. Can be passed in OpenAI format.
            model (str): Assistant model to use.
            client (Optional[Union[openai.OpenAI, openai.AzureOpenAI]]): OpenAI or
                AzureOpenAI client. Will create default OpenAI client (Assistant v2)
                if not specified.
            model_kwargs: Additional model arguments. Only available for temperature
                and top_p parameters.
            extra_body: Additional body parameters to be passed to the assistant.

        Returns:
            OpenAIAssistantRunnable: The configured assistant runnable.
        r   ©Ú	NOT_GIVEN)ÚnameÚinstructionsr3   rU   ÚmodelrV   )rI   rF   © )r)   Úopenai._typesrY   r   Ú
assistantsÚcreaterB   r7   )ÚclsrZ   r[   r3   r\   rT   rF   rU   rV   ÚkwargsrY   r>   Ú	assistants                r(   Úcreate_assistantz*OpenAIAssistantV2Runnable.create_assistantù   s”   € ðD Ò/Ô-Ó/ˆØÐ!Ý/à&ˆNØ1�F—K‘K×*Ñ*×1Ñ1ð 
ØØ%Ù:?Ó@¹%°$Ô'¨Õ-¸%Ñ@Ø)ØØ!ñ
ð ñ
ˆ	ñ ÐF 	§¡°VÑF¸vÑFÐFùò As   Á A2c           	     ój  — t        |«      }t        j                  |j                  d«      |j                  d«      |j                  d«      ¬«      }|j	                  t        | «      ||j                  d«      xs | j                  «       ¬«      }t        |j                  dg «      «      }|j                  dg «      |z   }	 | j                  r`|j                  d	«      rO| j                  |d	   «      } | j                  j                  j                  j                  j                  di |¤Ž}	næd
|vr?d|d   ||j                  d«      dœg|j                  d«      dœ}
| j                  ||
«      }	n£d|vre| j                  j                  j                  j                   j#                  |d
   |d   d||j                  d«      ¬«      }| j%                  |«      }	n: | j                  j                  j                  j                  j                  di |¤Ž}	| j'                  |	j(                  |	j*                  «      }		 | j1                  |	«      }|j3                  |«       |S # t,        $ r}|j/                  |«       |‚d}~ww xY w# t,        $ r(}|j/                  ||	j5                  «       ¬«       |‚d}~ww xY w)a(  Invoke the assistant.

        Args:
            input (dict): Runnable input dict that can have:
                content: User message when starting a new run.
                thread_id: Existing thread to use.
                run_id: Existing run to use. Should only be supplied when providing
                    the tool output for a required action after an initial invocation.
                file_ids: (deprecated) File ids to include in new run. Use
                    'attachments' instead
                attachments: Assistant files to include in new run. (v2 API).
                message_metadata: Metadata to associate with new message.
                thread_metadata: Metadata to associate with new thread. Only relevant
                    when new thread being created.
                instructions: Additional run instructions.
                model: Override Assistant model for this run.
                tools: Override Assistant tools for this run.
                tool_resources: Override Assistant tool resources for this run (v2 API).
                run_metadata: Metadata to associate with new run.
            config (Optional[RunnableConfig]): Configuration for the run.

        Returns:
            OutputType: If self.as_agent, will return
                Union[List[OpenAIAssistantAction], OpenAIAssistantFinish]. Otherwise,
                will return OpenAI types
                Union[List[ThreadMessage], List[RequiredActionFunctionToolCall]].

        Raises:
            BaseException: If an error occurs during the invocation.
        Ú	callbacksÚtagsÚmetadata©Úinheritable_callbacksÚinheritable_tagsÚinheritable_metadataÚrun_name©rZ   r5   r6   Úintermediate_stepsÚ	thread_idÚuserÚcontentÚmessage_metadata©Úrolerr   r6   rh   Úthread_metadata©Úmessagesrh   Úrun_id©rr   ru   r6   rh   N©rh   r]   )r   r   Ú	configureÚgetÚon_chain_startr   Úget_namer8   rM   Ú_parse_intermediate_stepsrF   r   ÚthreadsÚrunsÚsubmit_tool_outputsÚ_create_thread_and_runrx   r`   Ú_create_runÚ_wait_for_runr7   rp   ÚBaseExceptionÚon_chain_errorÚ_get_responseÚon_chain_endr=   ©rR   ÚinputÚconfigrb   Úcallback_managerÚrun_managerÚfilesr6   Útool_outputsÚrunÚthreadÚ_r'   Úresponses                 r(   Úinvokez OpenAIAssistantV2Runnable.invoke+  sŒ  € ôB ˜vÓ&ˆÜ*×4Ñ4Ø"(§*¡*¨[Ó"9Ø#ŸZ™Z¨Ó/Ø!'§¡¨JÓ!7ô
Ðð
 '×5Ñ5Ü�$‹K˜ V§Z¡Z°
Ó%;Ò%N¸t¿}¹}»ð 6ó 
ˆô 3°6·:±:¸jÈ"Ó3MÓNˆØ—j‘j °Ó3°eÑ;ˆð&	à�}Š} §¡Ð+?Ô!@Ø#×=Ñ=ØÐ.Ñ/ó �ð H�d—k‘k×&Ñ&×.Ñ.×3Ñ3×GÑGÑWÈ,ÑW‘à EÑ)ð %+Ø',¨YÑ'7Ø+6Ø(-¯	©	Ð2DÓ(Eñ	ð!ð !&§	¡	Ð*;Ó <ñ
�ð ×1Ñ1°%¸Ó@‘à Ñ&Ø—K‘K×$Ñ$×,Ñ,×5Ñ5×<Ñ<Ø˜+Ñ&Ø! )Ñ,ØØ +Ø"ŸY™YÐ'9Ó:ð =ó �ð ×&Ñ& uÓ-‘ð H�d—k‘k×&Ñ&×.Ñ.×3Ñ3×GÑGÑPÈ%ÑP�Ø×$Ñ$ S§V¡V¨S¯]©]Ó;ˆCð	Ø×)Ñ)¨#Ó.ˆHð
 ×$Ñ$ XÔ.ØˆOøô ò 	Ø×&Ñ& qÔ)ØˆGûð	ûô
 ò 	Ø×&Ñ& q°3·8±8³:Ð&Ô>ØˆGûð	ús1   Ã E8I È9J É	I>É&I9É9I>Ê	J2Ê
#J-Ê-J2)rG   rU   c             ‹  ó  K  — |xs
 t        «       }|€ddlm} |}|D �	cg c]  }	t        |	«      ‘Œ }
}	|j                  j
                  j                  |||
||¬«      ƒ d{  –—† } | d|j                  |dœ|¤ŽS c c}	w 7 Œ­w)a  Create an AsyncOpenAI Assistant and instantiate the Runnable.

        Args:
            name (str): Assistant name.
            instructions (str): Assistant instructions.
            tools (Sequence[Union[BaseTool, dict]]): Assistant tools. Can be passed
                in OpenAI format or as BaseTools.
            tool_resources (Optional[Union[AssistantToolResources, dict, NotGiven]]):
                Assistant tool resources. Can be passed in OpenAI format.
            model (str): Assistant model to use.
            async_client (Optional[Union[openai.OpenAI, openai.AzureOpenAI]]): OpenAI or
            AzureOpenAI async client. Will create default async_client if not specified.

        Returns:
            AsyncOpenAIAssistantRunnable: The configured assistant runnable.
        Nr   rX   )rZ   r[   r3   rU   r\   )rI   rG   r]   )r-   r^   rY   rB   r   r_   r`   r7   )ra   rZ   r[   r3   r\   rG   rU   rb   rY   r>   Úopenai_toolsrc   s               r(   Úacreate_assistantz+OpenAIAssistantV2Runnable.acreate_assistant‰  s™   è ø€ ð< $ÒAÔ'?Ó'AˆØÐ!Ý/à&ˆNÙ?DÓE¹u°tÔ,¨TÕ2¸uˆÐEà&×+Ñ+×6Ñ6×=Ñ=ØØ%ØØ)Øð >ó 
÷ 
ˆ	ñ ÐR 	§¡¸<ÑRÈ6ÑRÐRùò Fð
ús   ‚BŸA:±/BÁ A?Á!Bc           	   ‹  óæ  K  — |xs i }t        j                  |j                  d«      |j                  d«      |j                  d«      ¬«      }|j                  t	        | «      ||j                  d«      xs | j                  «       ¬«      }t        |j                  dg «      «      }|j                  dg «      |z   }	 | j                  ri|j                  d	«      rX| j                  |d	   «      } | j                  j                  j                  j                  j                  di |¤Žƒ d
{  –—† }	�nd|vrGd|d   ||j                  d«      dœg|j                  d«      dœ}
| j                  ||
«      ƒ d
{  –—† }	n»d|vru| j                  j                  j                  j                  j!                  |d   |d   d||j                  d«      ¬«      ƒ d
{  –—† }| j#                  |«      ƒ d
{  –—† }	nB | j                  j                  j                  j                  j                  di |¤Žƒ d
{  –—† }	| j%                  |	j&                  |	j(                  «      ƒ d
{  –—† }		 | j/                  |	«      }|j1                  |«       |S 7 �Œ`7 �Œ7 Œ¹7 Œ¢7 Œa7 Œ5# t*        $ r}|j-                  |«       |‚d
}~ww xY w# t*        $ r(}|j-                  ||	j3                  «       ¬«       |‚d
}~ww xY w­w)a*  Async invoke assistant.

        Args:
            input (dict): Runnable input dict that can have:
                content: User message when starting a new run.
                thread_id: Existing thread to use.
                run_id: Existing run to use. Should only be supplied when providing
                    the tool output for a required action after an initial invocation.
                file_ids: (deprecated) File ids to include in new run. Use
                    'attachments' instead
                attachments: Assistant files to include in new run. (v2 API).
                message_metadata: Metadata to associate with new message.
                thread_metadata: Metadata to associate with new thread. Only relevant
                    when new thread being created.
                instructions: Additional run instructions.
                model: Override Assistant model for this run.
                tools: Override Assistant tools for this run.
                tool_resources: Override Assistant tool resources for this run (v2 API).
                run_metadata: Metadata to associate with new run.
            config (Optional[RunnableConfig]): Configuration for the run.

        Returns:
            OutputType: If self.as_agent, will return
                Union[List[OpenAIAssistantAction], OpenAIAssistantFinish]. Otherwise,
                will return OpenAI types
                Union[List[ThreadMessage], List[RequiredActionFunctionToolCall]].

        Raises:
            BaseException: If an error occurs during the invocation.
        rf   rg   rh   ri   rm   rn   r5   r6   ro   Nrp   rq   rr   rs   rt   rv   rw   ry   rz   r{   r]   )r   r|   r}   r~   r   r   r8   rM   r€   rG   r   r�   r‚   rƒ   Ú_acreate_thread_and_runrx   r`   Ú_acreate_runÚ_await_for_runr7   rp   r‡   rˆ   r‰   rŠ   r=   r‹   s                 r(   Úainvokez!OpenAIAssistantV2Runnable.ainvoke·  sß  è ø€ ðB ’˜2ˆÜ*×4Ñ4Ø"(§*¡*¨[Ó"9Ø#ŸZ™Z¨Ó/Ø!'§¡¨JÓ!7ô
Ðð
 '×5Ñ5Ü�$‹K˜ V§Z¡Z°
Ó%;Ò%N¸t¿}¹}»ð 6ó 
ˆô 3°6·:±:¸jÈ"Ó3MÓNˆØ—j‘j °Ó3°eÑ;ˆð*	à�}Š} §¡Ð+?Ô!@Ø#×=Ñ=ØÐ.Ñ/ó �ð T˜D×-Ñ-×2Ñ2×:Ñ:×?Ñ?×SÑSñ Ø"ñ÷ ’ð  EÑ)ð %+Ø',¨YÑ'7Ø+6Ø(-¯	©	Ð2DÓ(Eñ	ð!ð !&§	¡	Ð*;Ó <ñ
�ð !×8Ñ8¸ÀÓG×G‘à Ñ&Ø×+Ñ+×0Ñ0×8Ñ8×AÑA×HÑHØ˜+Ñ&Ø! )Ñ,ØØ +Ø"ŸY™YÐ'9Ó:ð Ió ÷ �ð !×-Ñ-¨eÓ4×4‘ð T˜D×-Ñ-×2Ñ2×:Ñ:×?Ñ?×SÑSñ Øñ÷ �ð ×+Ñ+¨C¯F©F°C·M±MÓB×BˆCð	Ø×)Ñ)¨#Ó.ˆHð
 ×$Ñ$ XÔ.ØˆOðYùð  Hùðøð 5øðøð CùÜò 	Ø×&Ñ& qÔ)ØˆGûð	ûô
 ò 	Ø×&Ñ& q°3·8±8³:Ð&Ô>ØˆGûð	üs¸   ‚B:K1Â=A.J Ä+JÄ,AJ Å7JÅ8AJ ÇJÇJ Ç0JÇ1AJ È3JÈ4-J É!JÉ"J É'J= É8K1ÊJ ÊJ ÊJ ÊJ ÊJ ÊJ Ê	J:Ê"J5Ê5J:Ê:K1Ê=	K.Ë#K)Ë)K.Ë.K1c                óö   — d}|j                  «       D ��ci c]  \  }}||v sŒ||“Œ }}} | j                  j                  j                  j                  j
                  |d   fd| j                  i|¤ŽS c c}}w )z¸Create a new run within an existing thread.

        Args:
            input (dict): The input data for the new run.

        Returns:
            Any: The created run object.
        )r[   r\   r3   rU   Úrun_metadataÚtruncation_strategyÚmax_prompt_tokensrp   rI   )ÚitemsrF   r   r�   r‚   r`   rI   )rR   rŒ   Úallowed_assistant_paramsÚkÚvÚparamss         r(   r…   z%OpenAIAssistantV2Runnable._create_run  s‡   € ð$
Ð ð $)§;¡;¤=ÔR¡=™4˜1˜a°AÐ9QÒ4Q�!�Q‘$ =ˆÑRØ3ˆt�{‰{×Ñ×'Ñ'×,Ñ,×3Ñ3Ø�+Ññ
à×*Ñ*ð
ð ñ
ð 	
ùó Ss
   –A5£A5c                ó
  — |j                  «       D ��ci c]  \  }}|dv r||“Œ }}}|j                  d«      x}r||d<    | j                  j                  j                  j
                  d| j                  |dœ|¤Ž}|S c c}}w )zßCreate a new thread and run.

        Args:
            input (dict): The input data for the run.
            thread (dict): The thread data to create.

        Returns:
            Any: The created thread and run.
        ©r[   r\   r3   r    rU   ©rI   r“   r]   )r£   r}   rF   r   r�   Úcreate_and_runrI   ©rR   rŒ   r“   r¥   r¦   r§   rU   r’   s           r(   r„   z0OpenAIAssistantV2Runnable._create_thread_and_run2  s¦   € ð Ÿ™œô
á%‘��1ØÐFÑFð ˆq‰DØ%ð 	ñ 
ð
 #ŸY™YÐ'7Ó8Ð8ˆ>Ð8Ø'5ˆFÐ#Ñ$Ø5ˆd�k‰k×Ñ×&Ñ&×5Ñ5ð 
Ø×*Ñ*Øñ
ð ñ
ˆð
 ˆ
ùó
s   ”A?c              ƒ  ó  K  — |j                  «       D ��ci c]  \  }}|dv r||“Œ }}} | j                  j                  j                  j                  j
                  |d   fd| j                  i|¤Žƒ d{  –—† S c c}}w 7 Œ
­w)zÇAsynchronously create a new run within an existing thread.

        Args:
            input (dict): The input data for the new run.

        Returns:
            Any: The created run object.
        )r[   r\   r3   rU   r    rp   rI   N)r£   rG   r   r�   r‚   r`   rI   )rR   rŒ   r¥   r¦   r§   s        r(   rœ   z&OpenAIAssistantV2Runnable._acreate_runJ  sž   è ø€ ð Ÿ™œô
á%‘��1ØÐXÑXð ˆq‰DØ%ð 	ñ 
ð
 @�T×&Ñ&×+Ñ+×3Ñ3×8Ñ8×?Ñ?Ø�+Ññ
à×*Ñ*ð
ð ñ
÷ 
ð 	
ùó
ð

ús   ‚B–A<§ABÁ7BÁ8Bc              ƒ  ó&  K  — |j                  «       D ��ci c]  \  }}|dv r||“Œ }}}|j                  d«      x}r||d<    | j                  j                  j                  j
                  d| j                  |dœ|¤Žƒ d{  –—† }|S c c}}w 7 Œ­w)zýAsynchronously create a new thread and run simultaneously.

        Args:
            input (dict): The input data for the run.
            thread (dict): The thread data to create.

        Returns:
            Any: The created thread and run.
        r©   rU   rª   Nr]   )r£   r}   rG   r   r�   r«   rI   r¬   s           r(   r›   z1OpenAIAssistantV2Runnable._acreate_thread_and_run^  s¶   è ø€ ð Ÿ™œô
á%‘��1ØÐFÑFð ˆq‰DØ%ð 	ñ 
ð
 #ŸY™YÐ'7Ó8Ð8ˆ>Ð8Ø'5ˆFÐ#Ñ$ØA�D×%Ñ%×*Ñ*×2Ñ2×AÑAð 
Ø×*Ñ*Øñ
ð ñ
÷ 
ˆð
 ˆ
ùó
ð
ús   ‚B–B	§ABÂBÂB)Úreturnr   )rZ   rH   r[   rH   r3   úSequence[Union[BaseTool, dict]]r\   rH   rT   zdict[str, float]rF   z2Optional[Union[openai.OpenAI, openai.AzureOpenAI]]rU   ú7Optional[Union[AssistantToolResources, dict, NotGiven]]rV   zOptional[object]rb   r   r¯   r   )N)rŒ   r=   r�   zOptional[RunnableConfig]rb   r   r¯   r   )rZ   rH   r[   rH   r3   r°   r\   rH   rG   z<Optional[Union[openai.AsyncOpenAI, openai.AsyncAzureOpenAI]]rU   r±   rb   r   r¯   r   )rŒ   r=   r¯   r   )rŒ   r=   r“   r=   r¯   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r)   rF   Ú__annotations__rG   rK   rM   r   rS   Úclassmethodrd   r–   r™   rž   r…   r„   rœ   r›   r]   r9   r(   rD   rD   �   sä  … ñQñf Ð(:Ô;€FˆCÓ;Ø'Ø€L�#ÓØ-ØÓØØ#€N�EÓ#ØEØ€HˆdÓØFá˜'Ô"òó #ðð ð *,ØEIØRVØ'+ñ/Gàð/Gð ð/Gð /ð	/Gð
 ð/Gð 'ð/Gð Cð/Gð Pð/Gð %ð/Gð ð/Gð 
!ò/Gó ð/Gðd ?Cð\Øð\Ø#;ð\ØNQð\à	ó\ð| ð ØRVñ+Sàð+Sð ð+Sð /ð	+Sð
 ð+Sð
ð+Sð Pð+Sð ð+Sð 
!ò+Só ð+Sð\ ?Cð`Øð`Ø#;ð`ØNQð`à	ó`óD
ó2ó0
ô(r9   rD   )r¯   zopenai.OpenAI)r¯   zopenai.AsyncOpenAI)r5   Úlistr¯   r¸   )r>   ú:Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool]r¯   rL   )r>   r¹   r¯   zDict[str, Any])-Ú
__future__r   Útypingr   r   r   r   r   r	   r
   r   Ú&langchain.agents.openai_assistant.baser   r   Úlangchain_core._apir   Úlangchain_core.callbacksr   Úlangchain_core.loadr   Úlangchain_core.runnablesr   r   Úlangchain_core.toolsr   Ú%langchain_core.utils.function_callingr   Úpydanticr   r   r   Útyping_extensionsr   r"   r^   r   Úopenai.types.beta.assistantr   ÚAssistantToolResourcesr)   r-   r8   r@   rB   rD   r]   r9   r(   Ú<module>rÇ      sž   ðÝ "÷	÷ 	ó 	÷ WÝ $Ý 4Ý %ß BÝ )Ý Hß 6Ñ 6Ý "áÛÝ&ÝSóó2ó2ð*Ø
Dðà	óð*,Ø
Dð,àó,ñ* ƒôdÐ 7ó dó ñdr9   