ó
    ýÞ j�›  ã            $       ó  • S SK r S SKrS SKJrJrJr  S SKJrJrJ	r	J
r
JrJr  S SKJrJrJr  S SKJrJrJrJrJr  S SKJrJrJrJr  S SKJr  S SKJrJ r   S S	K!J"r"  S S
K#J$r$J%r%  S SK&J'r'J(r(  S SK)J*r*  S SK+J,r,  S SK-J.r.  S SK/J0r0  S SK1J2r2  S SK3J4r4J5r5  S SK6J7r7  S SK8J9r9  S SK:J;r;  S SK<J=r=J>r>J?r?  S SK@JArAJBrB  \C\;-  rD\C\E\;   -  rF\?" S\9S9 " S S\>5      5       rG\?" S\9S9 " S S\;5      5       rH\R’                  " 5          \R”                  " S\9SS 9  \?" S!\9S9 " S" S#\G5      5       rKSSS5        \R’                  " 5          \R”                  " S\9SS 9  \?" S$\9S9 " S% S&\H5      5       rLSSS5        \R’                  " 5          \R”                  " S\9S9  \
" S'\G\H-  S(9rM\E\M   rNSSS5        S)rO\\P-  \\M/\4   -  \\M\4   -  rQSLS*\MS+\PS,\S-\4S. jjrRS/\QS-  S-\4S0 jrS SMS1\S2\\   S3\TS-\U4S4 jjrVS1\S-\4S5 jrWS6\\   S-S4S7 jrX\?" S8\9S9SSSSSSSSSSS9S:SS;.S1\P\-  \\M\0\7   /\4   -  \\M\0\7   /\\   4   -  \\M\0\7   /\\\4   4   -  \\M\0\7   /\\\\4      4   -  S2\\\-  \C\P\4   -     \B-  S/\QS-  S<\F\Y\P\F4   -  S-  S=\ S-  S>\ S-  S?\NS-  S@\E\   S-  SA\4S-  SB\2S-  SC\Z\P   S-  SD\Z\P   S-  SE\USF\	SG   SH\PS-  SI\S-\,4"SJ jj5       r[\[r\/ SKQr]g! , (       d  f       GNº= f! , (       d  f       GN‹= f! , (       d  f       GNc= f)Né    N)Ú	AwaitableÚCallableÚSequence)Ú	AnnotatedÚAnyÚLiteralÚTypeVarÚcastÚget_type_hints)ÚBaseChatModelÚLanguageModelInputÚLanguageModelLike)Ú	AIMessageÚ
AnyMessageÚBaseMessageÚSystemMessageÚToolMessage)ÚRunnableÚRunnableBindingÚRunnableConfigÚRunnableSequence)ÚBaseTool)ÚRunnableCallableÚRunnableLike)ÚMISSING)Ú	ErrorCodeÚcreate_error_message)ÚENDÚ
StateGraph)Úadd_messages)ÚCompiledStateGraph)ÚRemainingSteps)ÚRuntime)Ú	BaseStore)ÚCheckpointerÚSend)ÚContextT)ÚLangGraphDeprecatedSinceV10)Ú	BaseModel)ÚNotRequiredÚ	TypedDictÚ
deprecated)ÚToolCallWithContextÚToolNodezxAgentState has been moved to `langchain.agents`. Please update your import to `from langchain.agents import AgentState`.©Úcategoryc                   óD   • \ rS rSr% Sr\\\   \4   \	S'   \
\   \	S'   Srg)Ú
AgentStateé5   úThe state of the agent.ÚmessagesÚremaining_steps© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r    Ú__annotations__r*   r"   Ú__static_attributes__r7   ó    Ú`/var/www/html/gaurav/venv/lib/python3.13/site-packages/langgraph/prebuilt/chat_agent_executor.pyr2   r2   5   s'   ‡ ñ
 "à˜ Ñ-¨|Ð;Ñ<Ó<à  Ñ0Ö0r?   r2   zTAgentStatePydantic has been deprecated in favor of AgentState in `langchain.agents`.c                   óB   • \ rS rSr% Sr\\\   \4   \	S'   Sr
\\	S'   Srg)ÚAgentStatePydanticéA   r4   r5   é   r6   r7   N)r8   r9   r:   r;   r<   r   r   r   r    r=   r6   r"   r>   r7   r?   r@   rB   rB   A   s&   ‡ ñ
 "à˜ Ñ-¨|Ð;Ñ<Ó<à&(€O�^Ö(r?   rB   Úignorez1AgentState has been moved to `langchain.agents`.*)r0   ÚmessagezbAgentStateWithStructuredResponse has been deprecated in favor of AgentState in `langchain.agents`.c                   ó$   • \ rS rSr% Sr\\S'   Srg)Ú AgentStateWithStructuredResponseéT   ú2The state of the agent with a structured response.Ústructured_responser7   N©r8   r9   r:   r;   r<   ÚStructuredResponser=   r>   r7   r?   r@   rH   rH   T   ó   ‡ ñ
 	Aà/Ö/r?   rH   zjAgentStateWithStructuredResponsePydantic has been deprecated in favor of AgentState in `langchain.agents`.c                   ó$   • \ rS rSr% Sr\\S'   Srg)Ú(AgentStateWithStructuredResponsePydanticée   rJ   rK   r7   NrL   r7   r?   r@   rP   rP   e   rN   r?   rP   ÚStateSchema)ÚboundÚPromptÚstateÚkeyÚdefaultÚreturnc                 óf   • [        U [        5      (       a  U R                  X5      $ [        XU5      $ ©N)Ú
isinstanceÚdictÚgetÚgetattr)rU   rV   rW   s      r@   Ú_get_state_valuer_   �   s5   € ô �eœT×"Ñ"ð 	�	‰	�#Óðô �U Ó)ðr?   Úpromptc                 óÜ  ^ ^• T c  [        S [        S9nU$ [        T [        5      (       a  [	        T S9m[        U4S j[        S9nU$ [        T [        5      (       a  [        U 4S j[        S9nU$ [
        R                  " T 5      (       a  [        S T [        S9nU$ [        T 5      (       a  [        T [        S9nU$ [        T [        5      (       a  T nU$ [        S[        T 5       35      e)Nc                 ó   • [        U S5      $ ©Nr5   ©r_   )rU   s    r@   Ú<lambda>Ú&_get_prompt_runnable.<locals>.<lambda>�   s   € Ô*¨5°*Ô=r?   ©Úname©Úcontentc                 ó$   >• T/[        U S5      -   $ rc   rd   )rU   Ú_system_messages    €r@   re   rf   ’   s   ø€ ˜?Ð+Ô.>¸uÀjÓ.QÒQr?   c                 ó$   >• T/[        U S5      -   $ rc   rd   )rU   r`   s    €r@   re   rf   —   s   ø€ ˜6˜(Ô%5°e¸ZÓ%HÒHr?   z"Got unexpected type for `prompt`: )r   ÚPROMPT_RUNNABLE_NAMEr[   Ústrr   ÚinspectÚiscoroutinefunctionÚcallabler   Ú
ValueErrorÚtype)r`   Úprompt_runnablerl   s   ` @r@   Ú_get_prompt_runnablerv   ‰   s   ù€ à�~Ü*Ù=ÔDXñ
ˆð< Ðô7 
�FœC×	 Ñ	 Ü'4¸VÑ'DˆÜ*ÜQÜ%ñ
ˆð2 Ðô+ 
�FœM×	*Ñ	*Ü*ÜHÜ%ñ
ˆð( Ðô! 
×	$Ò	$ V×	,Ñ	,Ü*ØØÜ%ñ
ˆð Ðô 
�&×	Ñ	Ü*ØÜ%ñ
ˆð Ðô 
�FœH×	%Ñ	%Ø ˆð Ðô Ð=¼dÀ6»l¸^ÐLÓMÐMr?   ÚmodelÚtoolsÚnum_builtinc                 ón  • [        U [        5      (       a  [        S U R                   5       U 5      n [        U [        5      (       d  gSU R
                  ;  a  gU R
                  S   n[        U5      [        U5      U-
  :w  a&  [        S[        U5       S[        U5      U-
   35      e[        S U 5       5      n[        5       nU HP  nUR                  S5      S:X  a	  US   S	   nOUR                  S	5      (       a  US	   nOM?  UR                  U5        MR     XE-
  =n(       a  [        S
U S35      eg)Nc              3   ó^   #   • U H$  n[        U[        [        45      (       d  M   Uv •  M&     g 7frZ   ©r[   r   r   ©Ú.0Ústeps     r@   Ú	<genexpr>Ú%_should_bind_tools.<locals>.<genexpr>²   ó(   é € ð á'�DÜ˜d¤_´mÐ$D×E÷ ‘Ú'ùó   ‚-¤	-Trx   z`Number of tools in the model.bind_tools() and tools passed to create_react_agent must match Got z tools, expected c              3   ó6   #   • U H  oR                   v •  M     g 7frZ   rg   )r~   Útools     r@   r€   r�   Ç   s   é € Ð1©5 4—Y–Yª5ùs   ‚rt   Úfunctionrh   zMissing tools 'z' in the model.bind_tools()F)r[   r   ÚnextÚstepsr   ÚkwargsÚlenrs   Úsetr]   Úadd)	rw   rx   ry   Úbound_toolsÚ
tool_namesÚbound_tool_namesÚ
bound_toolÚbound_tool_nameÚmissing_toolss	            r@   Ú_should_bind_toolsr“   ­   sB  € ô �%Ô)×*Ñ*Üñà!ŸKšKóð
 ó
ˆô �eœ_×-Ñ-Øà�e—l‘lÓ"Øà—,‘,˜wÑ'€KÜ
ˆ5ƒz”S˜Ó%¨Ñ3Ó3ÜðÜ˜“J�<Ð0´°[Ó1AÀKÑ1OÐ0PðRó
ð 	
ô
 Ñ1©5Ó1Ó1€JÜ“uÐÛ!ˆ
à�>‰>˜&Ó! ZÓ/Ø(¨Ñ4°VÑ<‰Oà�^‰^˜F×#Ñ#Ø(¨Ñ0‰Oñ à×Ñ˜_Ö-ñ "ð #Ñ5Ð5€}Õ5Ü˜?¨=¨/Ð9TÐUÓVÐVàr?   c                 ó  • [        U [        5      (       a  [        S U R                   5       U 5      n [        U [        5      (       a  U R
                  n [        U [        5      (       d  [        S[        U 5       35      eU $ )zKGet the underlying model from a RunnableBinding or return the model itself.c              3   ó^   #   • U H$  n[        U[        [        45      (       d  M   Uv •  M&     g 7frZ   r|   r}   s     r@   r€   Ú_get_model.<locals>.<genexpr>à   r‚   rƒ   zXExpected `model` to be a ChatModel or RunnableBinding (e.g. model.bind_tools(...)), got )	r[   r   r‡   rˆ   r   rS   r   Ú	TypeErrorrt   )rw   s    r@   Ú
_get_modelr˜   Ü   s{   € ä�%Ô)×*Ñ*Üñà!ŸKšKóð
 ó
ˆô �%œ×)Ñ)Ø—‘ˆä�eœ]×+Ñ+ÜØfÔgkÐlqÓgrÐfsÐtó
ð 	
ð €Lr?   r5   c                 óœ  • U  VVs/ sH/  n[        U[        5      (       d  M  UR                   H  nUPM     M1     nnnU  Vs1 sH&  n[        U[        5      (       d  M  UR                  iM(     nnU Vs/ sH  nUS   U;  d  M  UPM     nnU(       d  g[        SUSS  S3[        R                  S9n[        U5      es  snnf s  snf s  snf )zLValidate that all tool calls in AIMessages have a corresponding ToolMessage.ÚidNz{Found AIMessages with tool_calls that do not have a corresponding ToolMessage. Here are the first few of those tool calls: é   zÌ.

Every tool call (LLM requesting to call a tool) in the message history MUST have a corresponding ToolMessage (result of a tool invocation to return to the LLM) - this is required by most LLM providers.)rF   Ú
error_code)	r[   r   Ú
tool_callsr   Útool_call_idr   r   ÚINVALID_CHAT_HISTORYrs   )r5   rF   Ú	tool_callÚall_tool_callsÚtool_call_ids_with_resultsÚtool_calls_without_resultsÚerror_messages          r@   Ú_validate_chat_historyr¥   ó   s  € ñ  ôáˆGÜ�gœy×)ó 	ð !×+Ô+ˆIó 	ñ ,ñ 	Ùð ñ ñ -5ó"Ù,4 ¼
À7ÌK×8XÓˆ×Ô©Hð ð "ñ
 (ó"á'ˆIØ�T‰?Ð"<Ñ<÷ 	Ù'ð ð "ö
 &Øä(ð7Ø7QÐRTÐSTÐ7UÐ6Vð Wgðgô ×1Ñ1ñ€Mô �]Ó
#Ð#ùó1ùò"ùò"s"   †B>¢B>ÁCÁCÁ4C	ÂC	z‚create_react_agent has been moved to `langchain.agents`. Please update your import to `from langchain.agents import create_agent`.FÚv2)r`   Úresponse_formatÚpre_model_hookÚpost_model_hookÚstate_schemaÚcontext_schemaÚcheckpointerÚstoreÚinterrupt_beforeÚinterrupt_afterÚdebugÚversionrh   r§   r¨   r©   rª   r«   r¬   r­   r®   r¯   r°   r±   ©Úv1r¦   rh   Údeprecated_kwargsc          	      ó²  ^ ^^^^^^^^'^(^)^*^+^,^-^.^/• UR                  S[        5      =n[        La  [        R                  " S[        S9  Uc  Un[        U5      S:”  a  [        SU 35      eTS;  a  [        ST S	35      eTbP  S
S1nTb  UR                  S5        [        [        T5      5      nU[        U5      -
  =n(       a  [        SU S35      eTc  Tb  [        O[        m/ n[        U[        5      (       a&  [        UR                   R#                  5       5      nUnO}U Vs/ sH  n[        U[$        5      (       d  M  UPM     nn[        U Vs/ sH  n[        U[$        5      (       a  M  UPM     sn5      n[        UR                   R#                  5       5      n[        T [&        [(        45      (       + =(       a    [+        T 5      m-T-=(       a    [,        R.                  " T 5      m,[        U5      S:„  nT-(       dŽ  [        T [&        5      (       a   SSKJn  [7        [8        U" T 5      5      m [;        T U[        U5      S9(       a4  [        UU-   5      S:”  a"  [7        [8        T 5      R=                  UU-   5      m [?        T5      T -  m/OSm/U Vs1 sH"  nUR@                  (       d  M  URB                  iM$     snm.S[D        S[F        [H           S[J        4U-U UU/4S jjm*S[D        S[F        [H           S[J        4U,U-U UU/4S jjm(S[D        S[L        S[N        4U.4S jjm'S[D        S[D        4UU4S jjm)S[D        S[F        [H           S[P        S[D        4U'U)U*U,U-UU/4S jjnS[D        S[F        [H           S[P        S[D        4U'U(U)U-UU/4S jjnTbT  [        T[R        5      (       a1  [U        T[V        5      (       a  SSK,J-n  U" S[        [\           S4TS 9nO " S! ST5      nUnOTnS[D        S[F        [H           S[P        S[D        4U*U,U4S" jjnS[D        S[F        [H           S[P        S[D        4U(U4S# jjn U(       dä  [_        TUS$9n!U!Ra                  S%[c        UU5      US&9  Tb'  U!Ra                  S'T5        U!Re                  S'S%5        S'm+OS%m+U!Rg                  T+5        Tb$  U!Ra                  S(T5        U!Re                  S%S(5        TbD  U!Ra                  S)[c        UU 5      5        Tb  U!Re                  S(S)5        OU!Re                  S%S)5        U!Ri                  UU	U
UUTS*9$ S[D        S[&        [        [j           -  4UUU4S+ jjn"[_        T=(       d    [        US$9n!U!Ra                  S%[c        UU5      US&9  U!Ra                  S,U5        Tb'  U!Ra                  S'T5        U!Re                  S'S%5        S'm+OS%m+U!Rg                  T+5        / n#T+S,/n$Tb6  U!Ra                  S(T5        U#Rm                  S(5        U!Re                  S%S(5        OU#Rm                  S,5        TbC  U!Ra                  S)[c        UU 5      5        Tb  U$Rm                  S)5        O@U#Rm                  S)5        O.Tb  U$Rm                  [n        5        OU#Rm                  [n        5        Tb4  S[D        S[&        [        [j           -  4U+U4S- jjn%U!Rq                  S(U%U$S.9  U!Rq                  S%U"U#S.9  S[D        S[&        4U+U.4S/ jjn&T.(       a  U!Rq                  S,U&T+[n        /S.9  OU!Re                  S,T+5        U!Ri                  UU	U
UUTS*9$ s  snf s  snf ! [4         a    [5        S5      ef = fs  snf )0as'  Creates an agent graph that calls tools in a loop until a stopping condition is met.

!!! warning

    This function is deprecated in favor of
    [`create_agent`][langchain.agents.create_agent] from the `langchain`
    package, which provides an equivalent agent factory with a flexible
    middleware system. For migration guidance, see
    [Migrating from LangGraph v0](https://docs.langchain.com/oss/python/migrate/langgraph-v1).

Args:
    model: The language model for the agent. Supports static and dynamic
        model selection.

        - **Static model**: A chat model instance (e.g.,
            [`ChatOpenAI`][langchain_openai.ChatOpenAI]) or string identifier (e.g.,
            `"openai:gpt-4"`)
        - **Dynamic model**: A callable with signature
            `(state, runtime) -> BaseChatModel` that returns different models
            based on runtime context

            If the model has tools bound via `bind_tools` or other configurations,
            the return type should be a `Runnable[LanguageModelInput, BaseMessage]`
            Coroutines are also supported, allowing for asynchronous model selection.

        Dynamic functions receive graph state and runtime, enabling
        context-dependent model selection. Must return a `BaseChatModel`
        instance. For tool calling, bind tools using `.bind_tools()`.
        Bound tools must be a subset of the `tools` parameter.

        !!! example "Dynamic model"

            ```python
            from dataclasses import dataclass

            @dataclass
            class ModelContext:
                model_name: str = "gpt-3.5-turbo"

            # Instantiate models globally
            gpt4_model = ChatOpenAI(model="gpt-4")
            gpt35_model = ChatOpenAI(model="gpt-3.5-turbo")

            def select_model(state: AgentState, runtime: Runtime[ModelContext]) -> ChatOpenAI:
                model_name = runtime.context.model_name
                model = gpt4_model if model_name == "gpt-4" else gpt35_model
                return model.bind_tools(tools)
            ```

        !!! note "Dynamic Model Requirements"

            Ensure returned models have appropriate tools bound via
            `.bind_tools()` and support required functionality. Bound tools
            must be a subset of those specified in the `tools` parameter.

    tools: A list of tools or a `ToolNode` instance.
        If an empty list is provided, the agent will consist of a single LLM node without tool calling.
    prompt: An optional prompt for the LLM. Can take a few different forms:

        - `str`: This is converted to a `SystemMessage` and added to the beginning of the list of messages in `state["messages"]`.
        - `SystemMessage`: this is added to the beginning of the list of messages in `state["messages"]`.
        - `Callable`: This function should take in full graph state and the output is then passed to the language model.
        - `Runnable`: This runnable should take in full graph state and the output is then passed to the language model.

    response_format: An optional schema for the final agent output.

        If provided, output will be formatted to match the given schema and returned in the 'structured_response' state key.

        If not provided, `structured_response` will not be present in the output state.

        Can be passed in as:

        - An OpenAI function/tool schema,
        - A JSON Schema,
        - A TypedDict class,
        - A Pydantic class.
        - A tuple `(prompt, schema)`, where schema is one of the above.
            The prompt will be used together with the model that is being used to
            generate the structured response.

        !!! Important
            `response_format` requires the model to support `.with_structured_output`

        !!! Note
            The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.
            This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).

    pre_model_hook: An optional node to add before the `agent` node (i.e., the node that calls the LLM).
        Useful for managing long message histories (e.g., message trimming, summarization, etc.).
        Pre-model hook must be a callable or a runnable that takes in current graph state and returns a state update in the form of
            ```python
            # At least one of `messages` or `llm_input_messages` MUST be provided
            {
                # If provided, will UPDATE the `messages` in the state
                "messages": [RemoveMessage(id=REMOVE_ALL_MESSAGES), ...],
                # If provided, will be used as the input to the LLM,
                # and will NOT UPDATE `messages` in the state
                "llm_input_messages": [...],
                # Any other state keys that need to be propagated
                ...
            }
            ```

        !!! Important
            At least one of `messages` or `llm_input_messages` MUST be provided and will be used as an input to the `agent` node.
            The rest of the keys will be added to the graph state.

        !!! Warning
            If you are returning `messages` in the pre-model hook, you should OVERWRITE the `messages` key by doing the following:

            ```python
            {
                "messages": [RemoveMessage(id=REMOVE_ALL_MESSAGES), *new_messages]
                ...
            }
            ```
    post_model_hook: An optional node to add after the `agent` node (i.e., the node that calls the LLM).
        Useful for implementing human-in-the-loop, guardrails, validation, or other post-processing.
        Post-model hook must be a callable or a runnable that takes in current graph state and returns a state update.

        !!! Note
            Only available with `version="v2"`.
    state_schema: An optional state schema that defines graph state.
        Must have `messages` and `remaining_steps` keys.
        Defaults to `AgentState` that defines those two keys.
        !!! Note
            `remaining_steps` is used to limit the number of steps the react agent can take.
            Calculated roughly as `recursion_limit` - `total_steps_taken`.
            If `remaining_steps` is less than 2 and tool calls are present in the response,
            the react agent will return a final AI Message with
            the content "Sorry, need more steps to process this request.".
            No `GraphRecusionError` will be raised in this case.

    context_schema: An optional schema for runtime context.
    checkpointer: An optional checkpoint saver object. This is used for persisting
        the state of the graph (e.g., as chat memory) for a single thread (e.g., a single conversation).
    store: An optional store object. This is used for persisting data
        across multiple threads (e.g., multiple conversations / users).
    interrupt_before: An optional list of node names to interrupt before.
        Should be one of the following: `"agent"`, `"tools"`.

        This is useful if you want to add a user confirmation or other interrupt before taking an action.
    interrupt_after: An optional list of node names to interrupt after.
        Should be one of the following: `"agent"`, `"tools"`.

        This is useful if you want to return directly or run additional processing on an output.
    debug: A flag indicating whether to enable debug mode.
    version: Determines the version of the graph to create.

        Can be one of:

        - `"v1"`: The tool node processes a single message. All tool
            calls in the message are executed in parallel within the tool node.
        - `"v2"`: The tool node processes a tool call.
            Tool calls are distributed across multiple instances of the tool
            node using the [Send](https://langchain-ai.github.io/langgraph/concepts/low_level/#send)
            API.
    name: An optional name for the `CompiledStateGraph`.
        This name will be automatically used when adding ReAct agent graph to another graph as a subgraph node -
        particularly useful for building multi-agent systems.

!!! warning "`config_schema` Deprecated"
    The `config_schema` parameter is deprecated in v0.6.0 and support will be removed in v2.0.0.
    Please use `context_schema` instead to specify the schema for run-scoped context.


Returns:
    A compiled LangChain `Runnable` that can be used for chat interactions.

The "agent" node calls the language model with the messages list (after applying the prompt).
If the resulting AIMessage contains `tool_calls`, the graph will then call the ["tools"][langgraph.prebuilt.tool_node.ToolNode].
The "tools" node executes the tools (1 tool per `tool_call`) and adds the responses to the messages list
as `ToolMessage` objects. The agent node then calls the language model again.
The process repeats until no more `tool_calls` are present in the response.
The agent then returns the full list of messages as a dictionary containing the key `'messages'`.

``` mermaid
    sequenceDiagram
        participant U as User
        participant A as LLM
        participant T as Tools
        U->>A: Initial input
        Note over A: Prompt + LLM
        loop while tool_calls present
            A->>T: Execute tools
            T-->>A: ToolMessage for each tool_calls
        end
        A->>U: Return final state
```

Example:
    ```python
    from langgraph.prebuilt import create_react_agent

    def check_weather(location: str) -> str:
        '''Return the weather forecast for the specified location.'''
        return f"It's always sunny in {location}"

    graph = create_react_agent(
        "anthropic:claude-3-7-sonnet-latest",
        tools=[check_weather],
        prompt="You are a helpful assistant",
    )
    inputs = {"messages": [{"role": "user", "content": "what is the weather in sf"}]}
    for chunk in graph.stream(inputs, stream_mode="updates"):
        print(chunk)
    ```
Úconfig_schemazW`config_schema` is deprecated and will be removed. Please use `context_schema` instead.r/   Nr   z7create_react_agent() got unexpected keyword arguments: r²   zInvalid version z'. Supported versions are 'v1' and 'v2'.r5   r6   rK   zMissing required key(s) z in state_schema)Úinit_chat_modelzsPlease install langchain (`pip install langchain`) to use '<provider>:<model>' string syntax for `model` parameter.)ry   rU   ÚruntimerX   c                 ó>   >• T(       a  [        T5      T" X5      -  $ T$ )zBResolve the model to use, handling both static and dynamic models.©rv   )rU   r¸   Úis_dynamic_modelrw   r`   Ústatic_models     €€€€r@   Ú_resolve_modelÚ*create_react_agent.<locals>._resolve_modelW  s#   ø€ ö Ü'¨Ó/±%¸Ó2GÑGÐGàÐr?   c              “   ó”   >#   • T(       a  T" X5      I Sh  v•N n[        T5      U-  $ T(       a  [        T5      T" X5      -  $ T$  N/7f)zHAsync resolve the model to use, handling both static and dynamic models.Nrº   )rU   r¸   Úresolved_modelÚis_async_dynamic_modelr»   rw   r`   r¼   s      €€€€€r@   Ú_aresolve_modelÚ+create_react_agent.<locals>._aresolve_model`  sK   øé € ö "Ù#(¨Ó#8×8ˆNÜ'¨Ó/°.Ñ@Ð@ÞÜ'¨Ó/±%¸Ó2GÑGÐGàÐñ 9ùs   ƒA–A—0AÚresponsec                 ó  >• [        U[        5      =(       a    UR                  n[        U[        5      (       a  [        U4S jUR                   5       5      OSn[	        U SS 5      nUb  US:  a  U(       a  gUS:  a  U(       a  gg)Nc              3   ó0   >#   • U H  oS    T;   v •  M     g7f©rh   Nr7   ©r~   ÚcallÚshould_return_directs     €r@   r€   ÚEcreate_react_agent.<locals>._are_more_steps_needed.<locals>.<genexpr>o  s   øé € ÐUÑAT¸�V‘Ð 4Ö4ÒATùó   ƒFr6   é   Té   )r[   r   r�   Úallr_   )rU   rÄ   Úhas_tool_callsÚall_tools_return_directr6   rÊ   s        €r@   Ú_are_more_steps_neededÚ2create_react_agent.<locals>._are_more_steps_neededl  s|   ø€ Ü# H¬iÓ8×P¸X×=PÑ=Pˆô ˜(¤I×.Ñ.ô ÔUÀ×ATÒATÓUÔUàð 	 ô
 +¨5Ð2CÀTÓJˆØÑ&Ø Ó"Ö'>ØØ  1Ó$®Øàr?   c                 ó  >• Tb%  [        U S5      =(       d    [        U S5      nSU  3nO[        U S5      nSU  3nUc  [        U5      e[        U5        [        T[        5      (       a  [        T[        5      (       a  Xl        U $ XS'   U $ )NÚllm_input_messagesr5   zUExpected input to call_model to have 'llm_input_messages' or 'messages' key, but got z=Expected input to call_model to have 'messages' key, but got )r_   rs   r¥   r[   rt   Ú
issubclassr)   r5   )rU   r5   Ú	error_msgr¨   rª   s      €€r@   Ú_get_model_input_stateÚ2create_react_agent.<locals>._get_model_input_state|  s¤   ø€ ØÑ%ä  Ð(<Ó=÷5ä! %¨Ó4ð ð pÐpuÐovÐw‰Iä'¨¨zÓ:ˆHàOÐPUÈwÐWð ð ÑÜ˜YÓ'Ð'ä˜xÔ(ä�l¤D×)Ñ)¬j¸Äy×.QÑ.QØ%ŒNð ˆð !)�*Ñàˆr?   Úconfigc                 ó8  >• T
(       a  Sn[        U5      eT" U 5      nT(       a(  T	" X5      n[        [        UR                  XB5      5      nO[        [        TR                  XB5      5      nTUl        T" X5      (       a  S[        UR
                  SS9/0$ SU/0$ )NúˆAsync model callable provided but agent invoked synchronously. Use agent.ainvoke() or agent.astream(), or provide a sync model callable.r5   ú/Sorry, need more steps to process this request.©rš   rj   )ÚRuntimeErrorr
   r   Úinvokerh   rš   )rU   r¸   rÚ   ÚmsgÚmodel_inputÚdynamic_modelrÄ   rÒ   rØ   r½   rÁ   r»   rh   r¼   s          €€€€€€€r@   Ú
call_modelÚ&create_react_agent.<locals>.call_model•  s«   ø€ ö "ð1ð ô
 ˜sÓ#Ð#á,¨UÓ3ˆæá*¨5Ó:ˆMÜœI }×';Ñ';¸KÓ'PÓQ‰HäœI |×':Ñ':¸;Ó'OÓPˆHð ˆŒá! %×2Ñ2àÜØ#Ÿ;™;Ø Qñððð ð ˜X˜JÐ'Ð'r?   c              “   óT  >#   • T" U 5      nT	(       a8  T" X5      I S h  v•N n[        [        UR                  X25      I S h  v•N 5      nO'[        [        TR                  X25      I S h  v•N 5      nT
Ul        T" X5      (       a  S[        UR                  SS9/0$ SU/0$  Nƒ Nb N<7f)Nr5   rÝ   rÞ   )r
   r   Úainvokerh   rš   )rU   r¸   rÚ   râ   rã   rÄ   rÒ   rÂ   rØ   r»   rh   r¼   s         €€€€€€r@   Úacall_modelÚ'create_react_agent.<locals>.acall_model¸  s«   øé € ñ -¨UÓ3ˆæñ #2°%Ó"A×AˆMÜœI¨]×-BÑ-BÀ;Ó-W×'WÓX‰HäœI¨\×-AÑ-AÀ+Ó-V×'VÓWˆHð ˆŒÙ! %×2Ñ2àÜØ#Ÿ;™;Ø Qñððð ð ˜X˜JÐ'Ð'ñ# BÙ'Wá'Vùs3   ƒB(žB"Ÿ"B(ÁB$
Á'B(Á)B&
Á*9B(Â$B(Â&B()Úcreate_modelÚCallModelInputSchema.)rÕ   Ú__base__c                   ó&   • \ rS rSr% \\   \S'   Srg)Ú0create_react_agent.<locals>.CallModelInputSchemaiá  rÕ   r7   N)r8   r9   r:   r;   Úlistr   r=   r>   r7   r?   r@   rë   rî   á  s   ‡ Ø$(¨Ñ$4Ö4r?   c                 ó0  >• T(       a  Sn[        U5      e[        U S5      nTn[        T[        5      (       a  Tu  pe[	        US9/[        U5      -   nT
" X5      n[        U5      R                  [        [        U5      5      nUR                  XB5      n	SU	0$ )NrÜ   r5   ri   rK   )rß   r_   r[   Útupler   rï   r˜   Úwith_structured_outputr
   ÚStructuredResponseSchemarà   )rU   r¸   rÚ   rá   r5   Ústructured_response_schemaÚsystem_promptrÀ   Úmodel_with_structured_outputrÄ   r½   rÁ   r§   s             €€€r@   Úgenerate_structured_responseÚ8create_react_agent.<locals>.generate_structured_responseè  s«   ø€ ö "ð\ð ô ˜sÓ#Ð#ä# E¨:Ó6ˆØ%4Ð"Ü�o¤u×-Ñ-Ø8GÑ5ˆMÜ%¨mÑ<Ð=ÄÀXÃÑNˆHá'¨Ó7ˆÜ'1Øó(
ç
 Ñ
 ÜÔ)Ð+EÓFó
ð 	%ð
 0×6Ñ6°xÓHˆØ% xÐ0Ð0r?   c              “   ó8  >#   • [        U S5      nT
n[        T
[        5      (       a  T
u  pT[        US9/[	        U5      -   nT	" X5      I S h  v•N n[        U5      R                  [        [        U5      5      nUR                  X25      I S h  v•N nSU0$  NI N
7f)Nr5   ri   rK   )
r_   r[   rñ   r   rï   r˜   rò   r
   ró   rç   )rU   r¸   rÚ   r5   rô   rõ   rÀ   rö   rÄ   rÂ   r§   s            €€r@   Úagenerate_structured_responseÚ9create_react_agent.<locals>.agenerate_structured_response  s¤   øé € ô $ E¨:Ó6ˆØ%4Ð"Ü�o¤u×-Ñ-Ø8GÑ5ˆMÜ%¨mÑ<Ð=ÄÀXÃÑNˆHá.¨uÓ>×>ˆÜ'1Øó(
ç
 Ñ
 ÜÔ)Ð+EÓFó
ð 	%ð
 6×=Ñ=¸hÓO×OˆØ% xÐ0Ð0ñ ?ñ Pùs%   ƒA	BÁBÁA BÂBÂ	BÂB)rª   r«   Úagent)Úinput_schemar¨   r©   r÷   )r¬   r­   r®   r¯   r°   rh   c                 ó  >• [        U S5      nUS   n[        U[        5      (       a  UR                  (       d  Tb  gTb  g[        $ TS:X  a  gTS:X  a3  Tb  gUR                   Vs/ sH  n[        S[        SUU S	95      PM     sn$ g s  snf )
Nr5   éÿÿÿÿr©   r÷   r³   rx   r¦   Útool_call_with_context©Ú__typer    rU   )r_   r[   r   r�   r   r&   r-   )rU   r5   Úlast_messagerÉ   r©   r§   r±   s       €€€r@   Úshould_continueÚ+create_react_agent.<locals>.should_continue?  s¯   ø€ Ü# E¨:Ó6ˆØ ‘|ˆä˜,¬	×2Ñ2¸,×:Q×:QØÑ*Ø(Ø Ñ,Ø5ä�
ð ˜$‹ØØ˜D“Ø"Ñ.Ø,ð !-× 7Ò 7ó
ñ !8˜ô ØÜ+Ø#;Ø&*Ø"'ñöñ !8ñ
ð 
ð !ùò
s   Á&Brx   c                 ó¾  >• [        U S5      nU Vs/ sH&  n[        U[        5      (       d  M  UR                  PM(     nn[	        S [        U5       5       5      nUR                   Vs/ sH  oUS   U;  d  M  UPM     nnU(       a%  U Vs/ sH  n[        S[        SUU S95      PM     sn$ [        US   [        5      (       a  T$ T	b  g[        $ s  snf s  snf s  snf )	a;  Route to the next node after post_model_hook.

Routes to one of:
* "tools": if there are pending tool calls without a corresponding message.
* "generate_structured_response": if no pending tool calls exist and response_format is specified.
* END: if no pending tool calls exist and no response_format is specified.
r5   c              3   óR   #   • U H  n[        U[        5      (       d  M  Uv •  M      g 7frZ   )r[   r   )r~   Úms     r@   r€   ÚEcreate_react_agent.<locals>.post_model_hook_router.<locals>.<genexpr>¤  s   é € ð #Ù-�a´¸A¼y×1I—‘Ò-ùs   ‚'ž	'rš   rx   r   r  rÿ   r÷   )
r_   r[   r   rž   r‡   Úreversedr�   r&   r-   r   )
rU   r5   r  Útool_messagesÚlast_ai_messageÚcÚpending_tool_callsrÉ   Ú
entrypointr§   s
           €€r@   Úpost_model_hook_routerÚ2create_react_agent.<locals>.post_model_hook_router—  s  ø€ ô (¨¨zÓ:ˆHá(0óÙ(0 1´J¸qÄ+×4N“�—”©ð ð ô #ñ #Ü# HÔ-ó#ó ˆOð +×5Ò5ó"Ù5�a¸4¹ÈÑ9U—Ñ5ð ð "ö "ñ !3ó
ñ !3˜ô ØÜ+Ø#;Ø&*Ø"'ñöñ !3ñ
ð 
ô ˜H R™L¬+×6Ñ6Ø!Ð!Ø Ñ,Ø5ä�
ùò7ùò"ùò

s   ’C®CÁ)CÁ8CÂC)Úpath_mapc                 ó>  >• [        [        U S5      5       H2  n[        U[        5      (       d    OUR                  T;   d  M,  [
        s  $    [        W[        5      (       a;  UR                  (       a*  [        U4S jUR                   5       5      (       a  [
        $ T$ )Nr5   c              3   ó0   >#   • U H  oS    T;   v •  M     g7frÇ   r7   rÈ   s     €r@   r€   ÚCcreate_react_agent.<locals>.route_tool_responses.<locals>.<genexpr>Ô  s   øé € ÐQÁL¸D˜‘<Ð#7Ö7ÂLùrÌ   )	r
  r_   r[   r   rh   r   r   r�   Úany)rU   r  r  rÊ   s     €€r@   Úroute_tool_responsesÚ0create_react_agent.<locals>.route_tool_responsesÊ  sq   ø€ ÜÔ*¨5°*Ó=Ö>ˆAÜ˜a¤×-Ñ-ÙØ�v‰vÐ-Õ-Ü’
ñ	 ?ô �aœ×#Ñ#¨¯¯ÜÔQÀAÇLÂLÓQ×QÑQÜ�
àÐr?   )9Úpopr   ÚwarningsÚwarnr(   rŠ   r—   rs   rŒ   r‹   r   rH   r2   r[   r.   rï   Útools_by_nameÚvaluesr\   ro   r   rr   rp   rq   Úlangchain.chat_modelsr·   ÚImportErrorr
   r   r“   Ú
bind_toolsrv   Úreturn_directrh   rR   r#   r'   r   r   Úboolr   rt   rÖ   r)   Úpydanticrê   r   r   Úadd_noder   Úadd_edgeÚset_entry_pointÚcompiler&   Úappendr   Úadd_conditional_edges)0rw   rx   r`   r§   r¨   r©   rª   r«   r¬   r­   r®   r¯   r°   r±   rh   r´   r¶   Úrequired_keysÚschema_keysÚmissing_keysÚllm_builtin_toolsÚtool_classesÚ	tool_nodeÚtÚtool_calling_enabledr·   rä   rè   rê   rý   rë   r÷   rú   Úworkflowr  Úagent_pathsÚpost_model_hook_pathsr  r  rÒ   rÂ   rØ   r½   r  rÁ   r»   rÊ   r¼   s0   ` `````      ``                        @@@@@@@@@r@   Úcreate_react_agentr5    sÄ  ÿÿø€ ðh +×.Ñ.¨ÄÓHÐHˆÜòô 	�ŠØeÜ0ò	
ð
 Ñ!Ø*ˆNä
ÐÓ Ó!ÜØEÐFWÐEXÐYó
ð 	
ð �lÓ"ÜØ˜w˜iÐ'NÐOó
ð 	
ð ÑØ#Ð%6Ð7ˆØÑ&Ø×ÑÐ3Ô4äœ.¨Ó6Ó7ˆØ(¬3¨{Ó+;Ñ;Ð;ˆ<Õ;ÜÐ7¸°~ÐEUÐVÓWÐWàÑð Ñ*õ -äð 	ð %'ÐÜ�%œ×"Ñ"Ü˜E×/Ñ/×6Ñ6Ó8Ó9ˆØ‰	á(-ÓE© 1´¸A¼t×1DŸQ©ÐÐEÜ©ÓJ© A´jÀÄD×6IŸa©ÑJÓKˆ	Ü˜I×3Ñ3×:Ñ:Ó<Ó=ˆä% e¬c´8¨_Ó=Ô=×QÄ(È5Ã/ÐØ-×T´'×2MÒ2MÈeÓ2TÐä˜|Ó,¨qÑ0ÐæÜ�eœS×!Ñ!ðõô œ©¸Ó(>Ó?ˆEô ˜u lÄÐDUÓ@V×WÜ�LÐ#4Ñ4Ó5¸Ó9äœ¨Ó.×9Ñ9ØÐ0Ñ0óˆEô )=¸VÓ(DÀuÑ(L‰ð ˆñ -9ÓL©L q¸A¿O½O›F˜AŸFœF©LÑLÐð Üð Ü%,¬XÑ%6ð ä	÷ ò  ð
 Üð
 Ü%,¬XÑ%6ð
 ä	÷
 ó 
 ð¤kð ¼[ð ÌT÷ ð ¤kð ´k÷ ð ð2!(Üð!(Ü%,¬XÑ%6ð!(Ü@Nð!(ä	÷!(õ !(ðF(Üð(Ü%,¬XÑ%6ð(Ü@Nð(ä	÷(ô (ð8 Ñ!ä�l¤D×)Ñ)¬j¸Äy×.QÑ.Qå-á'Ø&Ü$(¬Ñ$4°cÐ#:Ø%ñ‰Lô5 |ô 5ð 0‰Là#ˆð1Üð1Ü%,¬XÑ%6ð1Ü@Nð1ä	÷1ñ 1ð21Üð1Ü%,¬XÑ%6ð1Ü@Nð1ä	÷1ð 1ö$  ä¨<ÈÑWˆØ×ÑØÜ˜Z¨Ó5Ø%ð 	ñ 	
ð
 Ñ%Ø×ÑÐ.°Ô?Ø×ÑÐ.°Ô8Ø)‰Jà ˆJà× Ñ  Ô,àÑ&Ø×ÑÐ/°ÔAØ×Ñ˜gÐ'8Ô9àÑ&Ø×ÑØ.Ü Ø0Ø1óôð Ñ*Ø×!Ñ!Ð"3Ð5SÕTà×!Ñ! 'Ð+IÔJà×ÑØ%ØØ-Ø+ØØð  ð 
ð 	
ðœ{ð ¬s´T¼$±ZÑ/?÷ ñ ô> Ø!×/¤ZÀñ€Hð
 ×ÑØÜ˜ [Ó1Ø!ð ñ ð
 ×Ñ�g˜yÔ)ð Ñ!Ø×ÑÐ*¨NÔ;Ø×ÑÐ*¨GÔ4Ø%‰
àˆ
ð ×Ñ˜ZÔ(à€KØ'¨Ð1Ðð Ñ"Ø×ÑÐ+¨_Ô=Ø×ÑÐ,Ô-Ø×Ñ˜'Ð#4Õ5à×Ñ˜7Ô#ð Ñ"Ø×ÑØ*ÜØ,Ø-óô	
ð Ñ&Ø!×(Ñ(Ð)GÕHà×ÑÐ=Õ>àÑ&Ø!×(Ñ(¬Õ-à×ÑœsÔ#àÑ"ð%	¬+ð %	¼#ÄÄTÁ
Ñ:J÷ %	ð %	ðN 	×&Ñ&ØØ"Ø*ð 	'ñ 	
ð ×"Ñ"ØØØð #ñ ð¤Kð ´C÷ ð ö Ø×&Ñ&ØÐ)°ZÄÐ4Eð 	'ò 	
ð 	×Ñ˜' :Ô.ð
 ×ÑØ!ØØ)Ø'ØØð ð ð ùòi FùÚJøô ó Ü!ðTóð ðüò. Ms0   Ä'\1Å\1Å\6Å0\6È\; Ê]Ê-]Ü;])r5  Úcreate_tool_calling_executorr2   rB   rH   rP   rZ   )r   )^rp   r  Úcollections.abcr   r   r   Útypingr   r   r   r	   r
   r   Úlangchain_core.language_modelsr   r   r   Úlangchain_core.messagesr   r   r   r   r   Úlangchain_core.runnablesr   r   r   r   Úlangchain_core.toolsr   Úlanggraph._internal._runnabler   r   Úlanggraph._internal._typingr   Úlanggraph.errorsr   r   Úlanggraph.graphr   r   Úlanggraph.graph.messager    Úlanggraph.graph.stater!   Úlanggraph.managedr"   Úlanggraph.runtimer#   Úlanggraph.store.baser$   Úlanggraph.typesr%   r&   Úlanggraph.typingr'   Úlanggraph.warningsr(   r#  r)   Útyping_extensionsr*   r+   r,   Úlanggraph.prebuilt.tool_noder-   r.   r\   rM   rt   ró   r2   rB   Úcatch_warningsÚfilterwarningsrH   rP   rR   ÚStateSchemaTypern   ro   rT   r_   rv   Úintr"  r“   r˜   r¥   rñ   rï   r5  r6  Ú__all__r7   r?   r@   Ú<module>rP     sì  ðÛ Û ß 9Ñ 9÷÷ ÷ñ ÷
õ ÷ó õ *ß HÝ /ß <ß +Ý 0Ý 4Ý ,Ý %Ý *ß .Ý %Ý :Ý ß @Ñ @ç Fà˜IÑ%Ð Ø $ y¡/Ñ1Ð ñ Ø~Ø(ñô1�ó 1ó	ð1ñ ØZØ(ñô)˜ó )ó	ð)ð ×ÒÕØ×ÒØØ,ØCòñ ØlØ,ñô0¨:ó 0ó	ð0÷ ð" ×ÒÕØ×ÒØØ,Øfòñ ØtØ,ñô0Ð3Eó 0ó	ð0÷ ð" ×ÒÕØ×ÒØØ,òñ ˜-¨zÐ<NÑ/NÑO€KØ˜;Ñ'€O÷ ð  Ð ð Ø	ñ
à�ˆ}Ð0Ð0Ñ1ñ2ð ˆ{Ð.Ð.Ñ/ñ0ð ñ˜Kð ¨cð ¸Cð È3õ ð! ¨$¡ð !°8ô !ðJ MNñ,Øð,Ø%-¨hÑ%7ð,ØFIð,à	õ,ð^Ð'ð ¨Mô ð.$Ø�{Ñ#ð$à	ô$ñ> ð IØ(ñð$ !ð Ø*.Ø+/Ø+/Ø'+Ø(,Ø"Ø)-Ø(,ØØ#'Øò9TØØñà�˜W XÑ.Ð/°Ð>Ñ?ñ@ð �˜W XÑ.Ð/°¸=Ñ1IÐIÑJñKð Ø	�g˜hÑ'Ð(¨(Ð3EÀ{Ð3RÑ*SÐSññ	ð Ø	�g˜hÑ'Ð(Ø�(Ð-¨{Ð:Ñ;Ñ<ð	>ññ
ðTð �H˜xÑ'¨$¨s°C¨x©.Ñ8Ñ9¸HÑDðTð �T‰MðTð .ØˆCÐ)Ð)Ñ*ñ+à
ñðTð$ ! 4Ñ'ð%Tð& " DÑ(ð'Tð( " DÑ(ð)Tð* ˜‘I Ñ$ð+Tð,  Ñ%ð-Tð. �tÑð/Tð0 ˜3‘i $Ñ&ð1Tð2 ˜#‘Y Ñ%ð3Tð4 ð5Tð6 �ZÑ ð7Tð8 �‰*ð9Tð: ð;Tð< ô=Tó	ðTðp  2Ð ò�÷G Öú÷" Öú÷" Öús$   Ã=(KÄ>(K*Å?!K<Ë
K'Ë*
K9Ë<
L