
    h                        d Z ddlZddlmZ ddlmZmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ  eded      	 	 	 	 ddddee   dedee   dee
   dee   dee   deee      dedefd       Zy)zLoad agent.    N)Sequence)AnyOptional)
deprecated)BaseCallbackManager)BaseLanguageModel)BaseTool)AGENT_DEPRECATION_WARNING)AgentExecutor)	AgentType)
load_agent)AGENT_TO_CLASSz0.1.0z1.0)messageremoval)tagstoolsllmagentcallback_manager
agent_pathagent_kwargsr   kwargsreturnc                t   |rt        |      ng }||t        j                  }||d}	t        |	      ||t        vr&d| dt	        j
                          d}	t        |	      |j                  t        |t              r|j                  n|       t        |   }
|xs i } |
j                  || fd|i|}n\|Mt        ||| |      }t        j                  t              5  |j                  |j                         ddd       nd}	t        |	      t        j                   d
|| ||d	|S # 1 sw Y   #xY w)a\  Load an agent executor given tools and LLM.

    Args:
        tools: List of tools this agent has access to.
        llm: Language model to use as the agent.
        agent: Agent type to use. If None and agent_path is also None, will default
            to AgentType.ZERO_SHOT_REACT_DESCRIPTION. Defaults to None.
        callback_manager: CallbackManager to use. Global callback manager is used if
            not provided. Defaults to None.
        agent_path: Path to serialized agent to use. If None and agent is also None,
            will default to AgentType.ZERO_SHOT_REACT_DESCRIPTION. Defaults to None.
        agent_kwargs: Additional keyword arguments to pass to the underlying agent.
            Defaults to None.
        tags: Tags to apply to the traced runs. Defaults to None.
        kwargs: Additional keyword arguments passed to the agent executor.

    Returns:
        An agent executor.

    Raises:
        ValueError: If both `agent` and `agent_path` are specified.
        ValueError: If `agent` is not a valid agent type.
        ValueError: If both `agent` and `agent_path` are None.
    NzLBoth `agent` and `agent_path` are specified, but at most only one should be.zGot unknown agent type: z. Valid types are: .r   )r   r   r   zISomehow both `agent` and `agent_path` are None, this should never happen.)r   r   r   r    )listr   ZERO_SHOT_REACT_DESCRIPTION
ValueErrorr   keysappend
isinstancevaluefrom_llm_and_toolsr   
contextlibsuppressNotImplementedError_agent_typer   from_agent_and_tools)r   r   r   r   r   r   r   r   tags_msg	agent_cls	agent_objs               Y/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/langchain/agents/initialize.pyinitialize_agentr/      s   P DJBE}+55Z3. 	 o&*5' 2$$2$7$7$9#:!=  S/!Jui$@U[[eL"5)	#)r0I00
 .
 	
	 
	-	
	   !45 	0LL../	0 	0
 X 	 o-- )	
  	0 	0s   "D..D7)NNNN)__doc__r%   collections.abcr   typingr   r   langchain_core._apir   langchain_core.callbacksr   langchain_core.language_modelsr   langchain_core.toolsr	   langchain._api.deprecationr
   langchain.agents.agentr   langchain.agents.agent_typesr   langchain.agents.loadingr   langchain.agents.typesr   strdictr/   r       r.   <module>r?      s      $   * 8 < ) @ 0 2 / 1 % "&6: $#'Q %)QHQ	Q IQ 23	Q
 Q 4.Q 8C=
!Q Q Q
Qr>   