HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/langchain/agents/__pycache__/loading.cpython-310.pyc
o

���g��@shdZddlZddlZddlmZddlmZmZmZm	Z	ddl
Z
ddlmZddl
mZddlmZddlmZmZdd	lmZdd
lmZmZe�e�ZdZded
edeedede	eeff
dd�Zeddd�		dded
eedeeedede	eeff
dd��Zeddd�de	e efdede	eeffdd��Z!de	e efdede	eeffdd�Z"dS)z!Functionality for loading agents.�N)�Path)�Any�List�Optional�Union)�
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�returncKsJ|�d�}|tvrtd|�d���t|}i|�|�}|j||fi|��S)N�_type�Loading � agent not supported)�popr�
ValueError�from_llm_and_tools)rrrr�config_type�	agent_cls�combined_config�r�C/usr/local/lib/python3.10/dist-packages/langchain/agents/loading.py�_load_agent_from_toolss
rz0.1.0z1.0)�removalcKs�d|vrtd��|�dd�}|r*|durtd��|dur td��t|||fi|��S|�d�}|tvr;td|�d	���t|}d
|vrMt|�d
��|d
<nd|vr[t|�d��|d
<ntd��d
|vrkt�d�|d
=i|�|�}|di|��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.
    rz$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 providedrr�	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)rrrrrr
�logger�warning)rrrr�load_from_toolsrrrrrr�load_agent_from_config"s:��
�r(�pathcKs,t|t�r|�d�rtd��t|fi|��S)aYUnified 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.
    zlc://z�Loading 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)rrrr�
load_agent\s
�r/�filecKs�ddh}t|t�rt|�}n|}|jdd�dkr3t|��
}t�|�}Wd�n1s-wYn,|jdd�dkrWt|d��
}t�|�}Wd�n1sQwYnt	d|�d���t
|fi|��S)zLoad agent from file.�json�yaml�N�rz&Unsupported file type, must be one of �.)r*r+r�suffix�openr1�loadr2�	safe_loadrr()r0r�valid_suffixes�	file_path�frrrrr.vs 


����r.)NN)#�__doc__r1�logging�pathlibr�typingrrrrr2�langchain_core._apir�langchain_core.language_modelsr�langchain_core.toolsr	�langchain.agents.agentr
r�langchain.agents.typesr�langchain.chains.loadingr
r�	getLogger�__file__r%�URL_BASE�dictrr(r+r/r.rrrr�<module>sl
����

�
���
��
�
9
��
�
��
�