
    l
i                        d Z ddlZddlZddlmZ ddlm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mZ dd	lmZ dd
lmZmZ  ej        e          ZdZdededee         dedeez  f
dZ e	dd          	 	 ddededz  dee         dz  dedeez  f
d            Z e	dd          deez  dedeez  fd            Zdeez  dedeez  fdZ dS )z!Functionality for loading agents.    N)Path)Any)
deprecated)BaseLanguageModel)Tool)BaseMultiActionAgentBaseSingleActionAgent)AGENT_TO_CLASS)
load_chainload_chain_from_configzHhttps://raw.githubusercontent.com/hwchase17/langchain-hub/master/agents/configllmtoolskwargsreturnc                     |                      d          }|t          vrd| d}t          |          t          |         }i | |} |j        ||fi |S )N_typeLoading  agent not supported)popr
   
ValueErrorfrom_llm_and_tools)r   r   r   r   config_typemsg	agent_clscombined_configs           C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\langchain_classic/agents/loading.py_load_agent_from_toolsr      sr     **W%%K.((::::oo{+I**6*O'9'UFFoFFF    z0.1.0z1.0)removalc                 n   d| vrd}t          |          |                     dd          }|r5|d}t          |          |d}t          |          t          | ||fi |S |                     d          }|t          vrd| d	}t          |          t          |         }d
| v r&t	          |                     d
                    | d
<   n;d| v r&t          |                     d                    | d
<   nd}t          |          d| v rt                              d           | d= i | |} |di |S )a  Load agent from Config Dict.

    Args:
        config: Config dict to load agent from.
        llm: Language model to use as the agent.
        tools: List of tools this agent has access to.
        kwargs: Additional keyword arguments passed to the agent executor.

    Returns:
        An agent executor.

    Raises:
        ValueError: If agent type is not specified in the config.
    r   z$Must specify an agent Type in configload_from_llm_and_toolsFNzFIf `load_from_llm_and_tools` is set to True, then LLM must be providedzHIf `load_from_llm_and_tools` is set to True, then tools must be providedr   r   	llm_chainllm_chain_pathz<One of `llm_chain` and `llm_chain_path` should be specified.output_parserzZCurrently loading output parsers on agent is not supported, will just use the default one. )r   r   r   r
   r   r   loggerwarning)	r   r   r   r   r   load_from_toolsr   r   r   s	            r   load_agent_from_configr*   &   s   * f4oojj!:EBBO D;X  S//!=.  S//!%fc5CCFCCC**W%%K.((::::oo{+If4VZZ5L5LMM{	V	#	#(4D)E)EFF{Loo&  -	
 	
 	
 ?#**6*O9'''''r   pathc                     t          | t                    r&|                     d          rd}t          |          t	          | fi |S )aY  Unified method for loading an agent from LangChainHub or local fs.

    Args:
        path: Path to the agent file.
        kwargs: Additional keyword arguments passed to the agent executor.

    Returns:
        An agent executor.

    Raises:
        RuntimeError: If loading from the deprecated github-based
            Hub is attempted.
    zlc://zLoading from the deprecated github-based Hub is no longer supported. Please use the new LangChain Hub at https://smith.langchain.com/hub instead.)
isinstancestr
startswithRuntimeError_load_agent_from_file)r+   r   r   s      r   
load_agentr2   e   sY    $ $  !9!9   	
 3 00000r   filec                    ddh}t          | t                    rt          |           n| }|j        dd         dk    rA|                                5 }t          j        |          }ddd           n# 1 swxY w Y   ni|j        dd         dk    rA|                                5 }t          j        |          }ddd           n# 1 swxY w Y   nd| d}t          |          t          |fi |S )zLoad agent from file.jsonyaml   Nz&Unsupported file type, must be one of .)r-   r.   r   suffixopenr5   loadr6   	safe_loadr   r*   )r3   r   valid_suffixes	file_pathfr   r   s          r   r1   r1      sq   
 f%N(s33=T


Iv%%^^ 	"Yq\\F	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"		!""		'	'^^ 	'^A&&F	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' I~HHHoo!&33F333s$   A33A7:A7&CCC)NN)!__doc__r5   loggingpathlibr   typingr   r6   langchain_core._apir   langchain_core.language_modelsr   langchain_core.toolsr   langchain_classic.agents.agentr   r	   langchain_classic.agents.typesr
    langchain_classic.chains.loadingr   r   	getLogger__name__r'   URL_BASEdictlistr   r*   r.   r2   r1   r&   r   r   <module>rO      sD   ' '                * * * * * * < < < < < < % % % % % % V V V V V V V V 9 9 9 9 9 9 O O O O O O O O		8	$	$UGG	G :G 	G
 11G G G G  GU### %)#;( ;(;(	T	!;( :;( 	;(
 11;( ;( ;( $#;(| GU###1
*11 111 1 1 $#164
*44 114 4 4 4 4 4r   