
    3fi}x                       d dl mZ d dlZd dl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 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 d dlmZ d dlmZmZmZ d dl m!Z!m"Z" erd dl#Z#d dl$m%Z% d dl&m'Z'  G d de      Z( G d de      Z)ddZ*ddZ+	 	 	 	 ddZ,	 	 	 	 d dZ-e.e)   e(z  e.d   z  e.d   z  Z/ G d dee0e/f         Z1y)!    )annotationsN)CallableSequence)JSONDecodeError)sleep)TYPE_CHECKINGAny)AgentActionAgentFinish)CallbackManager)dumpd)RunnableConfigRunnableSerializableensure_config)BaseTool)convert_to_openai_tool)	BaseModelFieldmodel_validator)Selfoverride)ThreadMessage)RequiredActionFunctionToolCallc                  8    e Zd ZU dZded<   ded<   edd       Zy)OpenAIAssistantFinishzoAgentFinish with run and thread metadata.

    Args:
        run_id: Run id.
        thread_id: Thread id.
    strrun_id	thread_idc                     yz]Check if the class is serializable by LangChain.

        Returns:
            False
        F clss    l/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_classic/agents/openai_assistant/base.pyis_lc_serializablez(OpenAIAssistantFinish.is_lc_serializable)            Nreturnbool__name__
__module____qualname____doc____annotations__classmethodr%   r!   r'   r$   r   r      s%     KN r'   r   c                  B    e Zd ZU dZded<   ded<   ded<   edd       Zy)	OpenAIAssistantActionzAgentAction with info needed to submit custom tool output to existing run.

    Args:
        tool_call_id: Tool call id.
        run_id: Run id.
        thread_id: Thread id
    r   tool_call_idr   r   c                     yr    r!   r"   s    r$   r%   z(OpenAIAssistantAction.is_lc_serializable@   r&   r'   Nr(   r+   r!   r'   r$   r3   r3   3   s+     KN r'   r3   c                     	 dd l }  | j                         S # t        $ r}d}t        |      |d }~wt        $ r}d}t        |      |d }~ww xY wNr   zBUnable to import openai, please install with `pip install openai`.zuPlease make sure you are using a v1.1-compatible version of openai. You can install with `pip install "openai>=1.1"`.)openaiOpenAIImportErrorAttributeErrorr8   emsgs      r$   _get_openai_clientr?   J   s\    )v}} &R#A% )< 	 S!q()    	A.AAAc                     	 dd l }  | j                         S # t        $ r}d}t        |      |d }~wt        $ r}d}t        |      |d }~ww xY wr7   )r8   AsyncOpenAIr:   r;   r<   s      r$   _get_openai_async_clientrC   Z   s_    )!v!!## &R#A% )< 	 S!q()r@   c                D    d}t        | t              xr d| v xr | d   |v S )z<Determine if tool corresponds to OpenAI Assistants built-in.)code_interpreterfile_searchtype)
isinstancedict)toolassistants_builtin_toolss     r$   _is_assistants_builtin_toolrL   j   s8      C4 	7t^	7&\55r'   c                2    t        |       r| S t        |       S )zConvert a raw function/class to an OpenAI tool.

    Note that OpenAI assistants supports several built-in tools,
    such as "code_interpreter" and "file_search".
    )rL   r   )rJ   s    r$   _get_assistants_toolrN   v   s     #4(!$''r'   r   r   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dd	 	 	 	 	 	 	 	 	 	 	 	 	 d#d       Ze	 d$	 	 	 	 	 	 	 d%d       Zedd	 	 	 	 	 	 	 	 	 	 	 	 	 d&d       Ze	 d$	 	 	 	 	 	 	 d%d       Z	 	 	 	 d'dZd(dZd)dZd*dZd+dZ	 	 	 	 d'dZd(dZd)dZd*d Zd+d!Zy),OpenAIAssistantRunnablea	  Run an OpenAI Assistant.

    Example using OpenAI tools:
        ```python
        from langchain_experimental.openai_assistant import OpenAIAssistantRunnable

        interpreter_assistant = OpenAIAssistantRunnable.create_assistant(
            name="langchain 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 = interpreter_assistant.invoke(
            {"content": "What's 10 - 4 raised to the 2.7"}
        )
        ```

    Example using custom tools and AgentExecutor:
        ```python
        from langchain_experimental.openai_assistant import OpenAIAssistantRunnable
        from langchain_classic.agents import AgentExecutor
        from langchain_classic.tools import E2BDataAnalysisTool


        tools = [E2BDataAnalysisTool(api_key="...")]
        agent = OpenAIAssistantRunnable.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": "What's 10 - 4 raised to the 2.7"})
        ```

    Example using custom tools and custom execution:
        ```python
        from langchain_experimental.openai_assistant import OpenAIAssistantRunnable
        from langchain_classic.agents import AgentExecutor
        from langchain_core.agents import AgentFinish
        from langchain_classic.tools import E2BDataAnalysisTool


        tools = [E2BDataAnalysisTool(api_key="...")]
        agent = OpenAIAssistantRunnable.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_clientr   assistant_idg     @@floatcheck_every_msFr*   as_agentafter)modec                    | j                   2dd l}| j                  j                  } |j                  |      | _         | S )Nr   )api_key)rS   r8   rR   r[   rB   )selfr8   r[   s      r$   _validate_async_clientz.OpenAIAssistantRunnable._validate_async_client   s:    $kk))G 2 2 27 CDr'   )rR   c          
         |xs
 t               }|j                  j                  j                  |||D cg c]  }t	        |       c}|      } | d|j
                  |d|S c c}w )a*  Create an OpenAI Assistant and instantiate the Runnable.

        Args:
            name: Assistant name.
            instructions: Assistant instructions.
            tools: Assistant tools. Can be passed in OpenAI format or as BaseTools.
            model: Assistant model to use.
            client: OpenAI or AzureOpenAI client.
                Will create a default OpenAI client if not specified.
            kwargs: Additional arguments.

        Returns:
            OpenAIAssistantRunnable configured to run using the created assistant.
        nameinstructionstoolsmodel)rT   rR   r!   )r?   beta
assistantscreaterN   id)	r#   r`   ra   rb   rc   rR   kwargsrJ   	assistants	            r$   create_assistantz(OpenAIAssistantRunnable.create_assistant   so    2 /-/KK**11%:?@$'-@	 2 
	 F	VFvFF As   A$c                "   t        |      }t        j                  |j                  d      |j                  d      |j                  d            }|j	                  t        |       ||j                  d      xs | j                               }	 | j                  r`|j                  d      rO| j                  |d         } | j                  j                  j                  j                  j                  di |}nd|vrNd	|d
   |j                  d      |j                  d      dg|j                  d      d}| j                  ||      }nd|vrd| j                  j                  j                  j                  j!                  |d   |d
   d	|j                  d            }	| j#                  |      }n: | j                  j                  j                  j                  j                  di |}| j%                  |j&                  |j(                        }	 | j/                  |      }|j1                  |       |S # t*        $ r}
|j-                  |
        d}
~
ww xY w# t*        $ r'}
|j-                  |
|j3                                 d}
~
ww xY w)a  Invoke assistant.

        Args:
            input: 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.
                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.
                parallel_tool_calls: Allow Assistant to set parallel_tool_calls
                    for this run.
                top_p: Override Assistant top_p for this run.
                temperature: Override Assistant temperature for this run.
                max_completion_tokens: Allow setting max_completion_tokens for this run.
                max_prompt_tokens: Allow setting max_prompt_tokens for this run.
                run_metadata: Metadata to associate with new run.
                attachments: A list of files attached to the message, and the
                    tools they should be added to.
            config: Runnable config.
            **kwargs: Additional arguments.

        Returns:
            If self.as_agent, will return
                Union[List[OpenAIAssistantAction], OpenAIAssistantFinish].
                Otherwise, will return OpenAI types
                Union[List[ThreadMessage], List[RequiredActionFunctionToolCall]].
        	callbackstagsmetadatainheritable_callbacksinheritable_tagsinheritable_metadatarun_namer`   intermediate_stepsr   usercontentmessage_metadataattachments)rolerw   rn   ry   thread_metadatamessagesrn   r   rw   rz   rn   Nrn   r!   )r   r   	configuregeton_chain_startr   get_namerW   _parse_intermediate_stepsrR   rd   threadsrunssubmit_tool_outputs_create_thread_and_runr}   rf   _create_run_wait_for_runrg   r   BaseExceptionon_chain_error_get_responseon_chain_endrI   r\   inputconfigrh   callback_managerrun_managertool_outputsrunthread_r=   responses               r$   invokezOpenAIAssistantRunnable.invoke  sd   N v&*44"(**["9#ZZ/!'J!7

 '55$KJ':4==? 6 

%	}}+?!@#==./  Hdkk&&..33GGW,WE) %+',Y'7(-		2D(E+099]+C	! !&		*; <
 11%@&KK$$,,55<<+&!),"YY'9:	 =  &&u- Hdkk&&..33GGP%P$$SVVS]];C	))#.H
 $$X.O  	&&q)	  	&&q388:&>	s1   FH; I ;	III	J'"J		J)rS   c                  K   |xs
 t               }|D cg c]  }t        |       }}|j                  j                  j	                  ||||       d{   }	 | d|	j
                  |d|S c c}w 7 w)a5  Async create an AsyncOpenAI Assistant and instantiate the Runnable.

        Args:
            name: Assistant name.
            instructions: Assistant instructions.
            tools: Assistant tools. Can be passed in OpenAI format or as BaseTools.
            model: Assistant model to use.
            async_client: AsyncOpenAI client.
                Will create default async_client if not specified.
            **kwargs: Additional arguments.

        Returns:
            AsyncOpenAIAssistantRunnable configured to run using the created assistant.
        r_   N)rT   rS   r!   )rC   rN   rd   re   rf   rg   )
r#   r`   ra   rb   rc   rS   rh   rJ   openai_toolsri   s
             r$   acreate_assistantz)OpenAIAssistantRunnable.acreate_assistant  s     2 $A'?'A?DEt,T2EE&++66==%	 > 
 
	 R	<R6RR F
s   A6A/.A6A4A6c                  K   |xs i }t        j                  |j                  d      |j                  d      |j                  d            }|j                  t	        |       ||j                  d      xs | j                               }	 | j                  rq|j                  d      r`| j                  |d          d{   } | j                  j                  j                  j                  j                  di | d{   }nd	|vrFd
|d   |j                  d      dg|j                  d      d}| j                  ||       d{   }nd|vrt| 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-                  |       d{   }|j/                  |       |S 7 7 i7 !7 7 7 l7 @# t(        $ r}
|j+                  |
        d}
~
ww xY w7 K# t(        $ r'}
|j+                  |
|j1                                 d}
~
ww xY ww)a  Async invoke assistant.

        Args:
            input: 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.
                message_metadata: Metadata to associate with a new message.
                thread_metadata: Metadata to associate with new thread. Only relevant
                    when a new thread is created.
                instructions: Overrides the instructions of the assistant.
                additional_instructions: Appends additional instructions.
                model: Override Assistant model for this run.
                tools: Override Assistant tools for this run.
                parallel_tool_calls: Allow Assistant to set parallel_tool_calls
                    for this run.
                top_p: Override Assistant top_p for this run.
                temperature: Override Assistant temperature for this run.
                max_completion_tokens: Allow setting max_completion_tokens for this run.
                max_prompt_tokens: Allow setting max_prompt_tokens for this run.
                run_metadata: Metadata to associate with new run.
            config: Runnable config.
            kwargs: Additional arguments.

        Returns:
            If self.as_agent, will return
                Union[List[OpenAIAssistantAction], OpenAIAssistantFinish].
                Otherwise, will return OpenAI types
                Union[List[ThreadMessage], List[RequiredActionFunctionToolCall]].
        rl   rm   rn   ro   rs   rt   ru   Nr   rv   rw   rx   )rz   rw   rn   r{   r|   r   r~   r   r!   )r   r   r   r   r   r   rW   _aparse_intermediate_stepsrS   rd   r   r   r   _acreate_thread_and_runr}   rf   _acreate_run_await_for_runrg   r   r   r   _aget_responser   rI   r   s               r$   ainvokezOpenAIAssistantRunnable.ainvoke  s    L 2*44"(**["9#ZZ/!'J!7

 '55$KJ':4==? 6 

(	}}+?!@%)%D%D./&   TD--22::??SS "  E) %+',Y'7(-		2D(E! !&		*; <	 !88GG&++0088AAHH+&!),"YY'9:	 I   !--e44 TD--22::??SS   ++CFFCMMBBC	!0055H
 $$X.O]  H 5 C 	&&q)	
 6 	&&q388:&>	s   B
K4I: I)AI: I,A
I: I/AI: -I2.I: I4AI: 	I6
-I: 7I88I: =J JJ K)I: ,I: /I: 2I: 4I: 6I: 8I: :	JJJKJ 	K("K

KKc                   |d   \  }}| j                  |j                  |j                        }t               }|j                  r7|j                  j
                  j                  D ch c]  }|j                   }}|D cg c]+  \  }}|j                  |v rt        |      |j                  d- }	}}|	|j                  |j                  dS c c}w c c}}w N)outputr4   )r   r   r   
r   r   r   setrequired_actionr   
tool_callsrg   r4   r   
r\   ru   last_actionr   r   required_tool_call_idstcactionr   r   s
             r$   r   z1OpenAIAssistantRunnable._parse_intermediate_steps  s     ,B/Q  !3!3[5J5JK!$ # 3 3 G G R R&&" &
 #5
""&<< 6{F4G4GH
 
 )!(($..
 	
&
s   'C0Cc                    |j                         D ci c]  \  }}|dv r|| }}} | j                  j                  j                  j                  j
                  |d   fd| j                  i|S c c}}w N)
ra   rc   rb   additional_instructionsparallel_tool_callstop_ptemperaturemax_completion_tokensmax_prompt_tokensrun_metadatar   rT   )itemsrR   rd   r   r   rf   rT   r\   
input_dictkvparamss        r$   r   z#OpenAIAssistantRunnable._create_run  s     #((*
1 qD
 
" 4t{{'',,33{#
**
 
 	
#
s   A2c                    |j                         D ci c]  \  }}|dv r|| }}} | j                  j                  j                  j                  d| j
                  |d|S c c}}w N)	ra   rc   rb   r   r   r   r   r   r   )rT   r   r!   )r   rR   rd   r   create_and_runrT   r\   r   r   r   r   r   s         r$   r   z.OpenAIAssistantRunnable._create_thread_and_run6  s     #((*
1
 qD
 
  7t{{''66 
**
 
 	
!
s   A%c                d   |j                   dk(  rdd lt        j                  j                  j                  d      d         }t        j                  j                  j                  d      d         }|dkD  xs |dk(  xr |dk\  | j                  j                  j                  j                  j                  |j                  d      }|D cg c]  }|j                  |j                  k(  s|  }}| j                  s|S |D cg c]  }|j                  D ]  }|  }}}|D 	cg c]  }|j                   D ]  }	|	  }
}}	t#        fd|D              rd	j%                  d
 |D              }t'        ||j                  |j                  |
dd|j                  |j                        S |j                   dk(  r| j                  s |j(                  j*                  j,                  S g }|j(                  j*                  j,                  D ]  }|j.                  }	 t1        j2                  |j4                  d      }t=        |      dk(  r	d|v r|d   }|j?                  tA        |j8                  ||j                  d|j                  |j                                |S t1        jB                  |jE                         d      }d|j                    d| }t;        |      c c}w c c}}w c c}	}w # t6        $ r-}d|j4                   d|j8                   }t;        |      |d }~ww xY w)N	completedr   .      ascorderc              3     K   | ]n  }r4t        |j                  j                  j                  j                        n3t        |j                  j                  j                  j
                         p y wNrH   typesrd   r   TextContentBlockMessageContentText.0rw   r8   version_gte_1_14s     r$   	<genexpr>z8OpenAIAssistantRunnable._get_response.<locals>.<genexpr>f  f      
  ( w(9(9(A(A(R(RS#))11DD
   A4A7
c              3  H   K   | ]  }|j                   j                    y wr   textvaluer   rw   s     r$   r   z8OpenAIAssistantRunnable._get_response.<locals>.<genexpr>q       "L'7<<#5#5"L    ")r   r   r   ry    return_valueslogr   r   requires_actionFstrict*Received invalid JSON function arguments:  for function __arg1rJ   
tool_inputr4   r   r   r      indentUnexpected run status: . Full run info:

)#statusr8   intversionVERSIONsplitrR   rd   r   r}   listr   r   rg   rW   rw   ry   alljoinr   r   r   r   functionjsonloads	argumentsr   r`   
ValueErrorlenappendr3   dumpsrI   )r\   r   major_versionminor_versionr}   r>   new_messagesmsg_contentanswer
attachmentry   actions	tool_callr   argsr=   run_infor8   r   s                    @@r$   r   z%OpenAIAssistantRunnable._get_responseM  s    ::$ 6 6 < <S A! DEM 6 6 < <S A! DEM - 1  ":}':  {{''//88== > H ,4LCszzSVV7KCLLL==##'3 #s{{8CF  '3"S__7A
K   
  &
 
 "LV"LL($!$!ff#.	 vv--
 
 ::**==**>>IIIG 00DDOO 	$--1::h&8&8GD t9>h$&6>D)%]]#'%.\\"vv"%--	, N::chhj3'

|3GzRo{ MD ' 1D#--.nX]]OM  %S/q01s0   K(4K(K-/K3"!K99	L/(L**L/c                    d}|rf| j                   j                  j                  j                  j	                  ||      }|j
                  dv }|rt        | j                  dz         |rfS NT)r   )in_progressqueuedi  )rR   rd   r   r   retriever   r   rV   r\   r   r   r  r   s        r$   r   z%OpenAIAssistantRunnable._wait_for_run  sf    ++""**//8898UC**(AAKd))D01	 
 
r'   c                  K   |d   \  }}| j                  |j                  |j                        }t               }|j                  r7|j                  j
                  j                  D ch c]  }|j                   }}|D cg c]+  \  }}|j                  |v rt        |      |j                  d- }	}}|	|j                  |j                  dS c c}w c c}}w wr   r   r   s
             r$   r   z2OpenAIAssistantRunnable._aparse_intermediate_steps  s      ,B/Q  !3!3[5J5JK!$ # 3 3 G G R R&&" &
 #5
""&<< 6{F4G4GH
 
 )!(($..
 	
&
s   A'C)C<C0C3(C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r   )r   rS   rd   r   r   rf   rT   r   s        r$   r   z$OpenAIAssistantRunnable._acreate_run  s      #((*
1 qD
 
" @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                  j                  j                  j                  d| j
                  |d| d {   S c c}}w 7 
wr   )r   rS   rd   r   r   rT   r   s         r$   r   z/OpenAIAssistantRunnable._acreate_thread_and_run  s      #((*
1
 qD
 
  CT&&++33BB 
**
 
 
 	
!
 
s   A7A/AA7*A5+A7c                0  K   |j                   dk(  rdd lt        j                  j                  j                  d      d         }t        j                  j                  j                  d      d         }|dkD  xs |dk(  xr |dk\  | j                  j                  j                  j                  j                  |j                  d       d {   }|D cg c]  }|j                  |j                  k(  s|  }}| j                  s|S |D cg c]  }|j                  D ]  }|  }}}t!        fd|D              rd	j#                  d
 |D              }t%        ||j                  |j                  dd|j                  |j                        S |j                   dk(  r| j                  s |j&                  j(                  j*                  S g }	|j&                  j(                  j*                  D ]  }
|
j,                  }	 t/        j0                  |j2                  d      }t;        |      dk(  r	d|v r|d   }|	j=                  t?        |j6                  ||
j                  d|j                  |j                                |	S t/        j@                  |jC                         d      }d|j                    d| }t9        |      7 c c}w c c}}w # t4        $ r-}d|j2                   d|j6                   }t9        |      |d }~ww xY ww)Nr   r   r   r   r   r   r   c              3     K   | ]n  }r4t        |j                  j                  j                  j                        n3t        |j                  j                  j                  j
                         p y wr   r   r   s     r$   r   z9OpenAIAssistantRunnable._aget_response.<locals>.<genexpr>   r   r   r   c              3  H   K   | ]  }|j                   j                    y wr   r   r   s     r$   r   z9OpenAIAssistantRunnable._aget_response.<locals>.<genexpr>  r   r   )r   r   r   r   r   r   Fr   r   r   r   r   r   r   r   r   )"r   r8   r   r   r   r   rS   rd   r   r}   r   r   r   rg   rW   rw   r   r   r   r   r   r   r   r   r   r   r   r`   r   r   r   r3   r   rI   )r\   r   r  r  r}   r>   r  r  r  r  r  r   r	  r=   r
  r8   r   s                  @@r$   r   z&OpenAIAssistantRunnable._aget_response  s     ::$ 6 6 < <S A! DEM 6 6 < <S A! DEM - 1  ":}':  "..33;;DDII J  H ,4LCszzSVV7KCLLL==##'3 #s{{8CF   
  &
 
 "LV"LL($!$!ff
 vv--	 	 ::**==**>>IIIG 00DDOO 	$--1::h&8&8GD t9>h$&6>D)%]]#'%.\\"vv"%--	, N::chhj3'

|3GzRo{ MB ' 1D#--.nX]]OM  %S/q01s\   CLKLK>KLK1CL	!K*B&LL	L&(LLLc                  K   d}|r| j                   j                  j                  j                  j	                  ||       d {   }|j
                  dv }|r*t        j                  | j                  dz         d {    |rS 7 C7 wr  )	rS   rd   r   r   r  r   asyncior   rV   r  s        r$   r   z&OpenAIAssistantRunnable._await_for_run5  s     ))..66;;DD# E  C **(AAKmmD$7$7$$>???  
 @s*   ABB	9B?B BBB)r)   r   )r`   r   ra   r   rb   Sequence[BaseTool | dict]rc   r   rR   z)openai.OpenAI | openai.AzureOpenAI | Nonerh   r	   r)   rP   r   )r   rI   r   zRunnableConfig | Nonerh   r	   r)   
OutputType)r`   r   ra   r   rb   r  rc   r   rS   z3openai.AsyncOpenAI | openai.AsyncAzureOpenAI | Nonerh   r	   r)   rP   )ru   z'list[tuple[OpenAIAssistantAction, str]]r)   rI   )r   rI   r)   r	   )r   rI   r   rI   r)   r	   )r   r	   r)   r	   )r   r   r   r   r)   r	   )r,   r-   r.   r/   r   r?   rR   r0   rS   rV   rW   r   r]   r1   rj   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r!   r'   r$   rP   rP      s   [z (:;FC;+L#1#NE#;HdH'" #  =AGG G )	G
 G :G G 
!G GB  )-__ &_ 	_
 
_ _B  MQ S S  S )	 S
  S J S  S 
! S  SD  )-aa &a 	a
 
a aF
C
 

,
0
.M^
C
 

,
0
.IV
r'   rP   )r)   zopenai.OpenAI)r)   zopenai.AsyncOpenAI)rJ   6dict[str, Any] | type[BaseModel] | Callable | BaseToolr)   r*   )rJ   r  r)   zdict[str, Any])2
__future__r   r  r   collections.abcr   r   r   timer   typingr   r	   langchain_core.agentsr
   r   langchain_core.callbacksr   langchain_core.loadr   langchain_core.runnablesr   r   r   langchain_core.toolsr   %langchain_core.utils.function_callingr   pydanticr   r   r   typing_extensionsr   r   r8   openai.types.beta.threadsr   <openai.types.beta.threads.required_action_function_tool_callr   r   r3   r?   rC   rL   rN   r   r  rI   rP   r!   r'   r$   <module>r*     s    "   .   
 ; 4 % X X ) H 6 6 ,7
K *K .) ) 	
@			
(
@
(
( 		
? +,- t
243CD t
r'   