o
    Jjg-                     @   s   d 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
 ddlmZ ddlmZ ddlmZ dd	lmZmZ ed
dd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dZdS )zLoad agent.    )AnyOptionalSequence)
deprecated)BaseCallbackManager)BaseLanguageModel)BaseTool)AgentExecutor)	AgentType)AGENT_TO_CLASS
load_agentz0.1.0zpUse new agent constructor methods like create_react_agent, create_json_agent, create_structured_chat_agent, etc.z1.0)alternativeremovalN)tagstoolsllmagentcallback_manager
agent_pathagent_kwargsr   kwargsreturnc                K   s
  |rt |ng }|du r|du rtj}|dur|durtd|durV|tvr4td| dt  d|t|tr>|jn| t| }	|pHi }|	j	|| fd|i|}
n"|durtt
||| |d}
z||
j W n tys   Y nw tdtjd
|
| ||d	|S )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   _agent_typeNotImplementedErrorr	   from_agent_and_tools)r   r   r   r   r   r   r   r   tags_	agent_cls	agent_objr   r   S/var/www/html/zoom/venv/lib/python3.10/site-packages/langchain/agents/initialize.pyinitialize_agent   sX   +r)   )NNNN)__doc__typingr   r   r   langchain_core._apir   langchain_core.callbacksr   langchain_core.language_modelsr   langchain_core.toolsr   langchain.agents.agentr	   langchain.agents.agent_typesr
   langchain.agents.loadingr   r   strdictr)   r   r   r   r(   <module>   sN    
	
