
    l
i                     0   d Z ddl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 ddlmZ ddlmZ  eded          	 	 	 	 ddddee         dededz  de	dz  dedz  dedz  dee         dz  dedefd            ZdS )zLoad agent.    N)Sequence)Any)
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                   |rt          |          ng }||t          j        }||d}	t          |	          ||t          vr)d| dt	          j                     d}	t          |	          |                    t          |t                    r|j        n|           t          |         }
|pi } |
j	        || fd|i|}nr|_t          ||| |          }t          j        t                    5  |                    |j                   ddd           n# 1 swxY w Y   nd}	t          |	          t          j        d
|| ||d	|S )a  Load an agent executor given tools and LLM.

    !!! warning

        This function is no deprecated in favor of
        [`create_agent`][langchain.agents.create_agent] from the `langchain`
        package, which provides a more flexible agent factory with middleware
        support, structured output, and integration with LangGraph.

        For migration guidance, see
        [Migrating to langchain v1](https://docs.langchain.com/oss/python/migrate/langchain-v1)
        and
        [Migrating from AgentExecutor](https://python.langchain.com/docs/how_to/migrate_agent/).

    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.
        callback_manager: CallbackManager to use. Global callback manager is used if
            not provided.
        agent_path: Path to serialized agent to use. If `None` and agent is also None,
            will default to AgentType.ZERO_SHOT_REACT_DESCRIPTION.
        agent_kwargs: Additional keyword arguments to pass to the underlying agent.
        tags: Tags to apply to the traced runs.
        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               C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\langchain_classic/agents/initialize.pyinitialize_agentr.      s   f &DJJJBE}+5Z3. 	 oo&&=5 = =$2$7$9$9= = =  S//!Jui$@$@KU[[eLLL"5)	#)r0I0
 
 .
 	
 
		 
	-	
 
 
	  !455 	0 	0LL.///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0
 X 	 oo- )	 
   s   /DDD)NNNN)__doc__r$   collections.abcr   typingr   langchain_core._apir   langchain_core.callbacksr   langchain_core.language_modelsr   langchain_core.toolsr   "langchain_classic._api.deprecationr	   langchain_classic.agents.agentr
   $langchain_classic.agents.agent_typesr    langchain_classic.agents.loadingr   langchain_classic.agents.typesr   strdictr.   r       r-   <module>r>      s         $ $ $ $ $ $       * * * * * * 8 8 8 8 8 8 < < < < < < ) ) ) ) ) ) H H H H H H 8 8 8 8 8 8 : : : : : : 7 7 7 7 7 7 9 9 9 9 9 9 %   #37! $\ "&\ \ \H\	\ t\ *D0	\
 d
\ +\ 3-$
\ \ \ \ \ 
\ \ \r=   