
    Ngh                       d dl mZ d dl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 d dlmZmZmZ d dlmZmZ d dl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'm(Z( d dl)m*Z* d dl+m,Z, g dZ-eddddd3d            Z.e	 d4ddddd5d            Z.e	 d4ddddd6d             Z.	 d4ddddd7d#Z.dd$d8d%Z/h d&Z0d9d(Z1d:d*Z2d;d-Z3d<d0Z4d1Z5 G d2 deeef                   Z6dS )=    )annotationsN)util)AnyAsyncIteratorCallableDictIteratorListLiteralOptionalSequenceTupleTypeUnioncastoverload)BaseChatModelLanguageModelInputSimpleChatModel)agenerate_from_streamgenerate_from_stream)
AnyMessageBaseMessage)RunnableRunnableConfigensure_config)StreamEvent)BaseTool)RunLogRunLogPatch)	BaseModel)	TypeAlias)init_chat_modelr   r   r   r   )model_providerconfigurable_fieldsconfig_prefixmodelstrr$   Optional[str]r%   Literal[None]r&   kwargsr   returnr   c                   d S N r'   r$   r%   r&   r+   s        V/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain/chat_models/base.pyr#   r#   1   s	     C    _ConfigurableModelc                   d S r.   r/   r0   s        r1   r#   r#   <   	     r2   .1Union[Literal['any'], List[str], Tuple[str, ...]]c                   d S r.   r/   r0   s        r1   r#   r#   G   r5   r2   ;Optional[Union[Literal['any'], List[str], Tuple[str, ...]]](Union[BaseChatModel, _ConfigurableModel]c                   | s|sd}|pd}|r|st          j        d|d           |s"t          t          t          |           fd|i|S | r| |d<   |r||d<   t          |||          S )a#  Initialize a ChatModel from the model name and provider.

    **Note:** Must have the integration package corresponding to the model provider
    installed.

    Args:
        model: The name of the model, e.g. "gpt-4o", "claude-3-opus-20240229".
        model_provider: The model provider. Supported model_provider values and the
            corresponding integration package are:

            - 'openai'              -> langchain-openai
            - 'anthropic'           -> langchain-anthropic
            - 'azure_openai'        -> langchain-openai
            - 'google_vertexai'     -> langchain-google-vertexai
            - 'google_genai'        -> langchain-google-genai
            - 'bedrock'             -> langchain-aws
            - 'bedrock_converse'    -> langchain-aws
            - 'cohere'              -> langchain-cohere
            - 'fireworks'           -> langchain-fireworks
            - 'together'            -> langchain-together
            - 'mistralai'           -> langchain-mistralai
            - 'huggingface'         -> langchain-huggingface
            - 'groq'                -> langchain-groq
            - 'ollama'              -> langchain-ollama

            Will attempt to infer model_provider from model if not specified. The
            following providers will be inferred based on these model prefixes:

            - 'gpt-3...' | 'gpt-4...' | 'o1...' -> 'openai'
            - 'claude...'                       -> 'anthropic'
            - 'amazon....'                      -> 'bedrock'
            - 'gemini...'                       -> 'google_vertexai'
            - 'command...'                      -> 'cohere'
            - 'accounts/fireworks...'           -> 'fireworks'
            - 'mistral...'                      -> 'mistralai'
        configurable_fields: Which model parameters are
            configurable:

            - None: No configurable fields.
            - "any": All fields are configurable. *See Security Note below.*
            - Union[List[str], Tuple[str, ...]]: Specified fields are configurable.

            Fields are assumed to have config_prefix stripped if there is a
            config_prefix. If model is specified, then defaults to None. If model is
            not specified, then defaults to ``("model", "model_provider")``.

            ***Security Note***: Setting ``configurable_fields="any"`` means fields like
            api_key, base_url, etc. can be altered at runtime, potentially redirecting
            model requests to a different service/user. Make sure that if you're
            accepting untrusted configurations that you enumerate the
            ``configurable_fields=(...)`` explicitly.

        config_prefix: If config_prefix is a non-empty string then model will be
            configurable at runtime via the
            ``config["configurable"]["{config_prefix}_{param}"]`` keys. If
            config_prefix is an empty string then model will be configurable via
            ``config["configurable"]["{param}"]``.
        temperature: Model temperature.
        max_tokens: Max output tokens.
        timeout: The maximum time (in seconds) to wait for a response from the model
            before canceling the request.
        max_retries: The maximum number of attempts the system will make to resend a
            request if it fails due to issues like network timeouts or rate limits.
        base_url: The URL of the API endpoint where requests are sent.
        rate_limiter: A ``BaseRateLimiter`` to space out requests to avoid exceeding
            rate limits.
        kwargs: Additional model-specific keyword args to pass to
            ``<<selected ChatModel>>.__init__(model=model_name, **kwargs)``.

    Returns:
        A BaseChatModel corresponding to the model_name and model_provider specified if
        configurability is inferred to be False. If configurable, a chat model emulator
        that initializes the underlying model at runtime once a config is passed in.

    Raises:
        ValueError: If model_provider cannot be inferred or isn't supported.
        ImportError: If the model provider integration package is not installed.

    .. dropdown:: Init non-configurable model
        :open:

        .. code-block:: python

            # pip install langchain langchain-openai langchain-anthropic langchain-google-vertexai
            from langchain.chat_models import init_chat_model

            gpt_4o = init_chat_model("gpt-4o", model_provider="openai", temperature=0)
            claude_opus = init_chat_model("claude-3-opus-20240229", model_provider="anthropic", temperature=0)
            gemini_15 = init_chat_model("gemini-1.5-pro", model_provider="google_vertexai", temperature=0)

            gpt_4o.invoke("what's your name")
            claude_opus.invoke("what's your name")
            gemini_15.invoke("what's your name")


    .. dropdown:: Partially configurable model with no default

        .. code-block:: python

            # pip install langchain langchain-openai langchain-anthropic
            from langchain.chat_models import init_chat_model

            # We don't need to specify configurable=True if a model isn't specified.
            configurable_model = init_chat_model(temperature=0)

            configurable_model.invoke(
                "what's your name",
                config={"configurable": {"model": "gpt-4o"}}
            )
            # GPT-4o response

            configurable_model.invoke(
                "what's your name",
                config={"configurable": {"model": "claude-3-5-sonnet-20240620"}}
            )
            # claude-3.5 sonnet response

    .. dropdown:: Fully configurable model with a default

        .. code-block:: python

            # pip install langchain langchain-openai langchain-anthropic
            from langchain.chat_models import init_chat_model

            configurable_model_with_default = init_chat_model(
                "gpt-4o",
                model_provider="openai",
                configurable_fields="any",  # this allows us to configure other params like temperature, max_tokens, etc at runtime.
                config_prefix="foo",
                temperature=0
            )

            configurable_model_with_default.invoke("what's your name")
            # GPT-4o response with temperature 0

            configurable_model_with_default.invoke(
                "what's your name",
                config={
                    "configurable": {
                        "foo_model": "claude-3-5-sonnet-20240620",
                        "foo_model_provider": "anthropic",
                        "foo_temperature": 0.6
                    }
                }
            )
            # Claude-3.5 sonnet response with temperature 0.6

    .. dropdown:: Bind tools to a configurable model

        You can call any ChatModel declarative methods on a configurable model in the
        same way that you would with a normal model.

        .. code-block:: python

            # pip install langchain langchain-openai langchain-anthropic
            from langchain.chat_models import init_chat_model
            from pydantic import BaseModel, Field

            class GetWeather(BaseModel):
                '''Get the current weather in a given location'''

                location: str = Field(..., description="The city and state, e.g. San Francisco, CA")

            class GetPopulation(BaseModel):
                '''Get the current population in a given location'''

                location: str = Field(..., description="The city and state, e.g. San Francisco, CA")

            configurable_model = init_chat_model(
                "gpt-4o",
                configurable_fields=("model", "model_provider"),
                temperature=0
            )

            configurable_model_with_tools = configurable_model.bind_tools([GetWeather, GetPopulation])
            configurable_model_with_tools.invoke(
                "Which city is hotter today and which is bigger: LA or NY?"
            )
            # GPT-4o response with tool calls

            configurable_model_with_tools.invoke(
                "Which city is hotter today and which is bigger: LA or NY?",
                config={"configurable": {"model": "claude-3-5-sonnet-20240620"}}
            )
            # Claude-3.5 sonnet response with tools

    .. versionadded:: 0.2.7

    .. versionchanged:: 0.2.8

        Support for ``configurable_fields`` and ``config_prefix`` added.

    .. versionchanged:: 0.2.12

        Support for ChatOllama via langchain-ollama package added
        (langchain_ollama.ChatOllama). Previously,
        the now-deprecated langchain-community version of Ollama was imported
        (langchain_community.chat_models.ChatOllama).

        Support for langchain_aws.ChatBedrockConverse added
        (model_provider="bedrock_converse").

    .. versionchanged:: 0.3.5

        Out of beta.

    r'   r$    zconfig_prefix=z has been set but no fields are configurable. Set `configurable_fields=(...)` to specify the model params that are configurable.r$   r'   )default_configr&   r%   )warningswarn_init_chat_model_helperr   r(   r3   r0   s        r1   r#   r#   U   s    r  :, :9!'RM 
0 
}   	
 	
 	
  
&e
 
-;
?E
 
 	
  	$#F7O 	6'5F#$!!' 3
 
 
 	
r2   )r$   c               "   t          | |          \  } }|dk    rt          d           ddlm}  |d0d| i|S |dk    rt          d           ddlm}  |d0d| i|S |d	k    rt          d           dd
lm}  |d0d| i|S |dk    rt          d           ddlm}  |d0d| i|S |dk    rt          d           ddl	m
}  |d0d| i|S |dk    rt          d           ddlm}  |d0d| i|S |dk    rt          d           ddlm}	  |	d0d| i|S |dk    rg	 t          d           ddlm}
 nF# t"          $ r9 	 t          d           ddlm}
 n# t"          $ r t          d           Y nw xY wY nw xY w |
d0d| i|S |dk    rt          d           ddlm}  |d0d| i|S |dk    rt          d           dd lm}  |d0d| i|S |d!k    rt          d"           dd#lm}  |d0d$| i|S |d%k    rt          d&           dd'lm}  |d0d| i|S |d(k    rt          d)           dd*lm}  |d0d$| i|S |d+k    rt          d)           dd,lm}  |d0d| i|S d-                    t>                    }tA          d.|d/|           )1Nopenailangchain_openair   )
ChatOpenAIr'   	anthropiclangchain_anthropic)ChatAnthropicazure_openai)AzureChatOpenAIcoherelangchain_cohere)
ChatCoheregoogle_vertexailangchain_google_vertexai)ChatVertexAIgoogle_genailangchain_google_genai)ChatGoogleGenerativeAI	fireworkslangchain_fireworks)ChatFireworksollamalangchain_ollama)
ChatOllamalangchain_communitytogetherlangchain_together)ChatTogether	mistralailangchain_mistralai)ChatMistralAIhuggingfacelangchain_huggingface)ChatHuggingFacemodel_idgroqlangchain_groq)ChatGroqbedrocklangchain_aws)ChatBedrockbedrock_converse)ChatBedrockConversez, zUnsupported model_provider=z".

Supported model providers are: r/   )!_parse_model
_check_pkgrC   rD   rF   rG   rI   rK   rL   rN   rO   rQ   rR   rT   rU   rW   rX   ImportErrorlangchain_community.chat_modelsr[   r\   r^   r_   ra   rb   re   rf   rh   ri   rk   join_SUPPORTED_PROVIDERS
ValueError)r'   r$   r+   rD   rG   rI   rL   rO   rR   rU   rX   r\   r_   rb   rf   ri   rk   	supporteds                     r1   r@   r@   H  s    )??E>!!%&&&//////z000000	;	&	&()))555555}3353F333	>	)	)%&&&44444455U5f555	8	#	#%&&&//////z000000	,	,	,.///::::::|22%26222	>	)	)+,,,AAAAAA%%<<E<V<<<	;	&	&()))555555}3353F333	8	#	#	/)***3333333 	/ 	/ 	//0111FFFFFFF / / / -...../	/ z000000	:	%	%'(((333333|22%26222	;	&	&()))555555}3353F333	=	(	(*+++999999888888	6	!	!#$$$++++++x..e.v...	9	$	$?###------ {44E4V444	-	-	-?###555555""999&999II233	>   
 
 	
s6   D4 4
E7?EE7E1.E70E11E76E7>   rd   rJ   rV   rB   rg   rZ   rE   rS   r]   r`   rH   rP   rM   rj   
model_namec                V    t           fddD                       rdS                      d          rdS                      d          rdS                      d          rd	S                      d
          rdS                      d          rdS                      d          rdS d S )Nc              3  B   K   | ]}                     |          V  d S r.   )
startswith).0prert   s     r1   	<genexpr>z0_attempt_infer_model_provider.<locals>.<genexpr>  s1      
J
J#:  %%
J
J
J
J
J
Jr2   )zgpt-3zgpt-4o1rB   clauderE   commandrJ   zaccounts/fireworksrS   geminirM   zamazon.rg   mistralr]   )anyrw   )rt   s   `r1   _attempt_infer_model_providerr     s    

J
J
J
J1I
J
J
JJJ x			x	(	( {			y	)	) x			3	4	4 	{			x	(	(   			y	)	) y			y	)	) {tr2   Tuple[str, str]c                   |sqd| v rm|                      d          d         t          v rK|                      d          d         }d                    |                      d          dd                    } |pt          |           }|st	          d| d          |                    dd                                          }| |fS )N:r      z)Unable to infer model provider for model=z), please specify model_provider directly.-_)splitrq   rp   r   rr   replacelowerr;   s     r1   rl   rl     s    /5LLKKQ#777S))!,S))!""-..#K'DU'K'KN 
(% ( ( (
 
 	
 $++C55;;==N.  r2   pkgNonec                    t          j        |           s,|                     dd          }t          d| d| d          d S )Nr   r   zUnable to import z&. Please install with `pip install -U `)r   	find_specr   rn   )r   	pkg_kebabs     r1   rm   rm     sf    ># 
KKS))	,	 , ,(, , ,
 
 	

 
r2   sprefixc                ^    |                      |          r| t          |          d          } | S r.   )rw   len)r   r   s     r1   _remove_prefixr     s/    ||F c&kkmmHr2   )
bind_toolswith_structured_outputc                      e Zd Zdddddd\dZd]dZd^d_dZd`dZ	 d^dadZedbd            Z		 d^dcd Z
	 d^dcd!Z	 d^ddd$Z	 d^ded&Z	 d^d'd(df fd/Z	 d^d'd(df fd0Z	 d^d'd(dg fd4Z	 d^d'd(dh fd6Z	 d^did8Z	 d^djd:Ze	 d^d;d;ddddddd<dkdH            Ze	 d^d;dddddddIdldL            Z	 d^d;d;ddddddd<dmdNZ	 d^dddddddOdndSZdodWZdpd[Z xZS )qr3   Nr   r<   r/   r=   r%   r&   queued_declarative_operationsr=   Optional[dict]r%   r6   r&   r(   r   !Sequence[Tuple[str, Tuple, Dict]]r,   r   c                   |pi | _         |dk    r|nt          |          | _        |r|                    d          s|dz   n|| _        t          |          | _        d S )Nr   r   )_default_configlist_configurable_fieldsendswith_config_prefix_queued_declarative_operations)selfr=   r%   r&   r   s        r1   __init__z_ConfigurableModel.__init__  s     &4%9r #e++  )** 	! %2%;%;C%@%@MC 	
 NR)N
 N
+++r2   namer   c                     t           v r	d
 fd}|S  j        r6                                 x}r t          |          rt	          |          S  d} j        r|dz  }|d	z  }t          |          )Nargsr   r+   r,   r3   c                    t          j                  }|                    | |f           t          t	          j                  t          j        t                     rt          j                  nj        j        |          S )Nr   )	r   r   appendr3   dictr   
isinstancer   r   )r   r+   r   r   r   s      r1   queuez-_ConfigurableModel.__getattr__.<locals>.queue  s    0471 1- .44dD&5IJJJ)#'(<#=#=!$";TBB)3T-F(G(G(G2"&"52O   r2   z! is not a BaseChatModel attributez, and is not implemented on the default model.)r   r   r+   r   r,   r3   )_DECLARATIVE_METHODSr   _modelhasattrgetattrAttributeError)r   r   r   r'   msgs   ``   r1   __getattr__z_ConfigurableModel.__getattr__  s    '''       L! 	&'=u 	&75RVCWCW 	&5$'''<<<C# FEE3JC %%%r2   configOptional[RunnableConfig]r   c                    i | j         |                     |          }t          di |}| j        D ]\  }}} t	          ||          |i |}|S )Nr/   )r   _model_paramsr@   r   r   )r   r   paramsr'   r   r   r+   s          r1   r   z_ConfigurableModel._model%  ss    GD(GD,>,>v,F,FG'11&11"&"E 	: 	:D$(GE4(($9&99EEr2   r   c                     t          |          } fd|                    di                                           D             } j        dk    r  fd|                                D             }|S )Nc                v    i | ]5\  }}|                     j                  t          |j                  |6S r/   )rw   r   r   rx   kvr   s      r1   
<dictcomp>z4_ConfigurableModel._model_params.<locals>.<dictcomp>.  sQ     
 
 
1||D/00
1d122A
 
 
r2   configurabler   c                .    i | ]\  }}|j         v ||S r/   )r   r   s      r1   r   z4_ConfigurableModel._model_params.<locals>.<dictcomp>4  s3       Ad>W9W9W19W9W9Wr2   )r   getitemsr   )r   r   model_paramss   `  r1   r   z _ConfigurableModel._model_params,  s    v&&
 
 
 


>266<<>>
 
 

 $--   !-!3!3!5!5  L r2   r+   c                *    t          di |pi t          t           |          }                     |          d |                                D             } fd|                    di                                           D             |d<   t           j                  }|r|                    ddd|if           t          i  j	        t           j        t
                    rt           j                  n j         j        |          S )z4Bind config to a Runnable, returning a new Runnable.c                &    i | ]\  }}|d k    ||S )r   r/   )rx   r   r   s      r1   r   z2_ConfigurableModel.with_config.<locals>.<dictcomp>A  s(    SSSTQqN?R?RAq?R?R?Rr2   c                J    i | ]\  }}t          |j                  v|| S r/   )r   r   )rx   r   r   r   r   s      r1   r   z2_ConfigurableModel.with_config.<locals>.<dictcomp>B  sA     ,
 ,
 ,
1a!455\II qIIIr2   r   with_configr/   r   r   )r   r   r   r   r   r   r   r   r3   r   r   r   r   )r   r   r+   remaining_configr   r   s   `    @r1   r   z_ConfigurableModel.with_config9  sH     QQ6<RQD4P4PQQ))&11SSV\\^^SSS,
 ,
 ,
 ,
 ,


>266<<>>,
 ,
 ,
(
 )-T-P(Q(Q% 	)00X/?$@A   "Cd2ClC$3T::!+T%> ? ? ?*-*G
 
 
 	
r2   r"   c                v    ddl m}m} t          t          t          ||f         t
          t                   f         S )z%Get the input type for this runnable.r   )ChatPromptValueConcreteStringPromptValue)langchain_core.prompt_valuesr   r   r   r(   r
   r   )r   r   r   s      r1   	InputTypez_ConfigurableModel.InputTypeU  sX    	
 	
 	
 	
 	
 	
 	
 	
 #%<<=
 	
r2   inputr   c                H     |                      |          j        |fd|i|S Nr   )r   invoker   r   r   r+   s       r1   r   z_ConfigurableModel.invokef  s0     *t{{6"")%III&IIIr2   c                X   K    |                      |          j        |fd|i| d {V S r   )r   ainvoker   s       r1   r   z_ConfigurableModel.ainvoken  sF       1T[[((0PPvPPPPPPPPPPr2   Optional[Any]Iterator[Any]c              +  \   K    |                      |          j        |fd|i|E d {V  d S r   )r   streamr   s       r1   r   z_ConfigurableModel.streamv  sL       .4;;v&&-eMMFMfMMMMMMMMMMMr2   AsyncIterator[Any]c               l   K    |                      |          j        |fd|i|2 3 d {V }|W V  6 d S r   )r   astreamr   r   r   r+   xs        r1   r   z_ConfigurableModel.astream~  so       3t{{6**25RRR6RR 	 	 	 	 	 	 	!GGGGG SRR   3F)return_exceptionsinputsList[LanguageModelInput]5Optional[Union[RunnableConfig, List[RunnableConfig]]]r   bool	List[Any]c                  |pd }|(t          |t                    st          |          dk    rAt          |t                    r|d         } |                     |          j        |f||d|S  t                      j        |f||d|S Nr   r   )r   r   )r   r   r   r   r   batchsuperr   r   r   r   r+   	__class__s        r1   r   z_ConfigurableModel.batch  s     4>Z55>V9I9I&$'' #,4;;v&&,%9J NT   !577=%9J NT  r2   c               8  K   |pd }|(t          |t                    st          |          dk    rGt          |t                    r|d         } |                     |          j        |f||d| d {V S  t                      j        |f||d| d {V S r   )r   r   r   r   r   abatchr   r   s        r1   r   z_ConfigurableModel.abatch  s      4>Z55>V9I9I&$'' #3V,,3%9J NT         (%9J NT        r2   Sequence[LanguageModelInput]9Optional[Union[RunnableConfig, Sequence[RunnableConfig]]]+Iterator[Tuple[int, Union[Any, Exception]]]c             +  f  K   |pd }|(t          |t                    st          |          dk    r\t          |t                    r|d         } |                     t          t          |                    j        |f||d|E d {V  d S  t                      j        |f||d|E d {V  d S r   )	r   r   r   r   r   r   r   batch_as_completedr   r   s        r1   r   z%_ConfigurableModel.batch_as_completed  s       4>Z55>V9I9I&$'' #St{{4#?#?@@S%9J NT           2uww1%9J NT          r2   AsyncIterator[Tuple[int, Any]]c                K   |pd }|(t          |t                    st          |          dk    rdt          |t                    r|d         } |                     t          t          |                    j        |f||d|2 3 d {V }|W V  6 d S  t                      j        |f||d|2 3 d {V }|W V  6 d S r   )	r   r   r   r   r   r   r   abatch_as_completedr   )r   r   r   r   r+   r   r   s         r1   r   z&_ConfigurableModel.abatch_as_completed  sY      4>Z55>V9I9I&$'' #"4;;^V,, !  &9J  OU        a
    75776%9J NT        a   s   B3C Iterator[LanguageModelInput]c              +  ^   K    |                      |          j        |fd|i|D ]}|V  d S r   )r   	transformr   s        r1   r   z_ConfigurableModel.transform  sR       /V$$.uNNVNvNN 	 	AGGGG	 	r2   !AsyncIterator[LanguageModelInput]c               l   K    |                      |          j        |fd|i|2 3 d {V }|W V  6 d S r   )r   
atransformr   s        r1   r   z_ConfigurableModel.atransform  so       6t{{6**5eUUFUfUU 	 	 	 	 	 	 	!GGGGG VUUr   T)diffwith_streamed_output_listinclude_namesinclude_typesinclude_tagsexclude_namesexclude_typesexclude_tagsr   Literal[True]r   r   Optional[Sequence[str]]r   r  r  r  r  AsyncIterator[RunLogPatch]c                   d S r.   r/   r   r   r   r   r   r   r   r  r  r  r  r+   s               r1   astream_logz_ConfigurableModel.astream_log  s	     &)Sr2   )r   r   r   r  r  r  r  Literal[False]AsyncIterator[RunLog]c                   d S r.   r/   r	  s               r1   r
  z_ConfigurableModel.astream_log
  s	     !$r2   8Union[AsyncIterator[RunLogPatch], AsyncIterator[RunLog]]c              |   K    |                      |          j        |f|||||||
|	|d	|2 3 d {V }|W V  6 d S )N)	r   r   r   r   r   r  r  r  r  )r   r
  )r   r   r   r   r   r   r   r  r  r  r  r+   r   s                r1   r
  z_ConfigurableModel.astream_log  s       7t{{6**6
&?''%%''
 
 
 
 	 	 	 	 	 	 	! GGGGG
 
 
s   ;)r   r   r  r  r  r  versionLiteral['v1', 'v2']AsyncIterator[StreamEvent]c              z   K    |                      |          j        |f||||||	||d|
2 3 d {V }|W V  6 d S )N)r   r  r   r   r  r  r  r  )r   astream_events)r   r   r   r  r   r   r  r  r  r  r+   r   s               r1   r  z!_ConfigurableModel.astream_events9  s       :t{{6**9
''%%''
 
 
 
 	 	 	 	 	 	 	! GGGGG
 
 
s   :toolsDSequence[Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool]])Runnable[LanguageModelInput, BaseMessage]c                :     |                      d          |fi |S )Nr   r   )r   r  r+   s      r1   r   z_ConfigurableModel.bind_toolsV  s*    
 .t--e>>v>>>r2   schemaUnion[Dict, Type[BaseModel]]4Runnable[LanguageModelInput, Union[Dict, BaseModel]]c                :     |                      d          |fi |S )Nr   r  )r   r  r+   s      r1   r   z)_ConfigurableModel.with_structured_output^  s+     :t 899&KKFKKKr2   )
r=   r   r%   r6   r&   r(   r   r   r,   r   )r   r(   r,   r   r.   )r   r   r,   r   )r   r   r,   r   )r   r   r+   r   r,   r3   )r,   r"   )r   r   r   r   r+   r   r,   r   )r   r   r   r   r+   r   r,   r   )r   r   r   r   r+   r   r,   r   )
r   r   r   r   r   r   r+   r   r,   r   )
r   r   r   r   r   r   r+   r   r,   r   )
r   r   r   r   r   r   r+   r   r,   r   )r   r   r   r   r+   r   r,   r   )r   r   r   r   r+   r   r,   r   )r   r   r   r   r   r  r   r   r   r  r   r  r  r  r  r  r  r  r  r  r+   r   r,   r  )r   r   r   r   r   r  r   r   r   r  r   r  r  r  r  r  r  r  r  r  r+   r   r,   r  )r   r   r   r   r   r   r   r   r   r  r   r  r  r  r  r  r  r  r  r  r+   r   r,   r  )r   r   r   r   r  r  r   r  r   r  r  r  r  r  r  r  r  r  r+   r   r,   r  )r  r  r+   r   r,   r  )r  r  r+   r   r,   r  )__name__
__module____qualname__r   r   r   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r
  r  r   r   __classcell__)r   s   @r1   r3   r3     s        *.QVKM
 
 
 
 
 
.& & & &>        ,0
 
 
 
 
8 
 
 
 X
& ,0J J J J J ,0Q Q Q Q Q ,0N N N N N ,0     IM
 #(       4 IM
 #(       4 MQ
 #(       4 MQ
 #(       < ,0     ,0      ,0)
 #*.151504151504) ) ) ) ) X)   ,0$ +/151504151504$ $ $ $ $ X$& ,0
 *.151504151504     B ,0 261504151504     :? ? ? ?L L L L L L L Lr2   )r'   r(   r$   r)   r%   r*   r&   r)   r+   r   r,   r   r.   )r'   r*   r$   r)   r%   r*   r&   r)   r+   r   r,   r3   )r'   r)   r$   r)   r%   r6   r&   r)   r+   r   r,   r3   )r'   r)   r$   r)   r%   r8   r&   r)   r+   r   r,   r9   )r'   r(   r$   r)   r+   r   r,   r   )rt   r(   r,   r)   )r'   r(   r$   r)   r,   r   )r   r(   r,   r   )r   r(   r   r(   r,   r(   )7
__future__r   r>   	importlibr   typingr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   langchain_core.language_modelsr   r   r   *langchain_core.language_models.chat_modelsr   r   langchain_core.messagesr   r   langchain_core.runnablesr   r   r   langchain_core.runnables.schemar   langchain_core.toolsr   langchain_core.tracersr   r    pydanticr!   typing_extensionsr"   __all__r#   r@   rq   r   rl   rm   r   r   r3   r/   r2   r1   <module>r0     s   " " " " " "                                      "         
        < ; ; ; ; ; ; ; L L L L L L L L L L 7 7 7 7 7 7 ) ) ) ) ) ) 6 6 6 6 6 6 6 6       ' ' ' ' ' '   
 %))-#'     
 
 %))-#'     
 
 %)MP#'     
  p
 %) 	#'p
 p
 p
 p
 p
 p
h 48Z
 Z
 Z
 Z
 Z
 Z
z   $   &! ! ! !$
 
 
 
    @ sL sL sL sL sL"4c"9: sL sL sL sL sLr2   