§
    ™Štjú  ã                  ó&  — d 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 ddlmZmZ ddlmZ ddlmZ ddlmZm Z m!Z! ddl"m#Z# ddl$m%Z%  eded¬¦  «         G d„ de¦  «        ¦   «         Z&dS )zDAn agent designed to hold a conversation in addition to using tools.é    )Úannotations)ÚSequence)ÚAny)Ú
deprecated)ÚBaseCallbackManager)ÚBaseLanguageModel)ÚPromptTemplate)ÚBaseTool)ÚField)Úoverride)ÚAGENT_DEPRECATION_WARNING)ÚAgentÚAgentOutputParser)Ú	AgentType©ÚConvoOutputParser)ÚFORMAT_INSTRUCTIONSÚPREFIXÚSUFFIX)Úvalidate_tools_single_input)ÚLLMChainz0.1.0z2.0.0)ÚmessageÚremovalc            	      ó.  ‡ — e Zd ZU dZdZded<   	  ee¬¦  «        Zded<   	 e	e
	 d$d%d„¦   «         ¦   «         Zed&d„¦   «         Zed&d„¦   «         Zed&d„¦   «         Ze	eeedddfd'd„¦   «         Ze	d(ˆ fd„¦   «         Ze	ddeeedddfd)d#„¦   «         Zˆ xZS )*ÚConversationalAgentz>An agent that holds a conversation in addition to using tools.ÚAIÚstrÚ	ai_prefix)Údefault_factoryr   Úoutput_parserÚkwargsr   Úreturnc                ó"   — t          |¬¦  «        S )N©r   r   )Úclsr   r!   s      új/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_classic/agents/conversational/base.pyÚ_get_default_output_parserz.ConversationalAgent._get_default_output_parser*   s   € õ !¨9Ð5Ñ5Ô5Ð5ó    c                ó   — t           j        S )z Return Identifier of agent type.)r   Ú CONVERSATIONAL_REACT_DESCRIPTION©Úselfs    r&   Ú_agent_typezConversationalAgent._agent_type3   s   € õ Ô9Ð9r(   c                ó   — dS )z]Prefix to append the observation with.

        Returns:
            "Observation: "
        zObservation: © r+   s    r&   Úobservation_prefixz&ConversationalAgent.observation_prefix8   s	   € ð ˆr(   c                ó   — dS )zVPrefix to append the llm call with.

        Returns:
            "Thought: "
        zThought:r/   r+   s    r&   Ú
llm_prefixzConversationalAgent.llm_prefixA   s	   € ð ˆzr(   ÚHumanNÚtoolsúSequence[BaseTool]ÚprefixÚsuffixÚformat_instructionsÚhuman_prefixÚinput_variablesúlist[str] | Noner	   c                óö   — d                      d„ |D ¦   «         ¦  «        }d                      d„ |D ¦   «         ¦  «        }	|                     |	||¬¦  «        }|› d|› d|› d|› �}
|€g d¢}t          |
|¬	¦  «        S )
aè  Create prompt in the style of the zero-shot agent.

        Args:
            tools: List of tools the agent will have access to, used to format the
                prompt.
            prefix: String to put before the list of tools.
            suffix: String to put after the list of tools.
            format_instructions: Instructions on how to use the tools.
            ai_prefix: String to use before AI output.
            human_prefix: String to use before human output.
            input_variables: List of input variables the final prompt will expect.
                Defaults to `["input", "chat_history", "agent_scratchpad"]`.

        Returns:
            A PromptTemplate with the template assembled from the pieces here.
        ú
c                ó2   — g | ]}d |j         › d|j        › �‘ŒS )z> z: )ÚnameÚdescription©Ú.0Útools     r&   ú
<listcomp>z5ConversationalAgent.create_prompt.<locals>.<listcomp>f   s.   € ÐDÐDÐD°dÐ1�$”)Ð1Ð1˜tÔ/Ð1Ð1ÐDÐDÐDr(   z, c                ó   — g | ]	}|j         ‘Œ
S r/   ©r?   rA   s     r&   rD   z5ConversationalAgent.create_prompt.<locals>.<listcomp>h   s   € Ð<Ð<Ð<¨d ¤	Ð<Ð<Ð<r(   )Ú
tool_namesr   r9   z

N)ÚinputÚchat_historyÚagent_scratchpad)Útemplater:   )ÚjoinÚformatr	   )r%   r4   r6   r7   r8   r   r9   r:   Útool_stringsrG   rK   s              r&   Úcreate_promptz!ConversationalAgent.create_promptJ   s¸   € ð6 —y’yØDÐD¸eÐDÑDÔDñ
ô 
ˆð —Y’YÐ<Ð<°eÐ<Ñ<Ô<Ñ=Ô=ˆ
Ø1×8Ò8Ø!ØØ%ð 9ñ 
ô 
Ðð
 ÐUÐU ,ÐUÐUÐ4GÐUÐUÈVÐUÐUˆØÐ"ØKÐKÐKˆOÝ xÀÐQÑQÔQÐQr(   ÚNonec                ót   •— t          ¦   «                              |¦  «         t          | j        |¦  «         d S )N)ÚsuperÚ_validate_toolsr   Ú__name__)r%   r4   Ú	__class__s     €r&   rS   z#ConversationalAgent._validate_toolss   s3   ø€ å‰Œ×Ò Ñ&Ô&Ð&Ý# C¤L°%Ñ8Ô8Ð8Ð8Ð8r(   Úllmr   Úcallback_managerúBaseCallbackManager | NoneúAgentOutputParser | Noner   c           	     óê   — |                       |¦  «         |                      |||	||||
¬¦  «        }t          |||¬¦  «        }d„ |D ¦   «         }|p|                      |¬¦  «        } | d||||dœ|¤ŽS )aÝ  Construct an agent from an LLM and tools.

        Args:
            llm: The language model to use.
            tools: A list of tools to use.
            callback_manager: The callback manager to use.
            output_parser: The output parser to use.
            prefix: The prefix to use in the prompt.
            suffix: The suffix to use in the prompt.
            format_instructions: The format instructions to use.
            ai_prefix: The prefix to use before AI output.
            human_prefix: The prefix to use before human output.
            input_variables: The input variables to use.
            **kwargs: Any additional keyword arguments to pass to the agent.

        Returns:
            An agent.
        )r   r9   r6   r7   r8   r:   )rV   ÚpromptrW   c                ó   — g | ]	}|j         ‘Œ
S r/   rF   rA   s     r&   rD   z:ConversationalAgent.from_llm_and_tools.<locals>.<listcomp>¨   s   € Ð2Ð2Ð2 D�d”iÐ2Ð2Ð2r(   r$   )Ú	llm_chainÚallowed_toolsr   r    r/   )rS   rO   r   r'   )r%   rV   r4   rW   r    r6   r7   r8   r   r9   r:   r!   r[   r]   rG   Ú_output_parsers                   r&   Úfrom_llm_and_toolsz&ConversationalAgent.from_llm_and_toolsx   s×   € ðB 	×Ò˜EÑ"Ô"Ð"Ø×"Ò"ØØØ%ØØØ 3Ø+ð #ñ 
ô 
ˆõ ØØØ-ð
ñ 
ô 
ˆ	ð
 3Ð2¨EÐ2Ñ2Ô2ˆ
Ø&ð 
¨#×*HÒ*HØð +Iñ +
ô +
ˆð ˆsð 
ØØ$ØØ(ð	
ð 
ð
 ð
ð 
ð 	
r(   )r   )r   r   r!   r   r"   r   )r"   r   )r4   r5   r6   r   r7   r   r8   r   r   r   r9   r   r:   r;   r"   r	   )r4   r5   r"   rP   )rV   r   r4   r5   rW   rX   r    rY   r6   r   r7   r   r8   r   r   r   r9   r   r:   r;   r!   r   r"   r   )rT   Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   r   r    Úclassmethodr   r'   Úpropertyr-   r0   r2   r   r   r   rO   rS   r`   Ú__classcell__)rU   s   @r&   r   r      sš  ø€ € € € € € ð IÐHà€IÐÐÐÑØ)Ø', uÐ=NÐ'OÑ'OÔ'O€MÐOÐOÐOÑOØ&àØð ð6ð 6ð 6ð 6ñ „Xñ „[ð6ð ð:ð :ð :ñ „Xð:ð ðð ð ñ „Xðð ðð ð ñ „Xðð ð ØØ#6ØØ#Ø,0ð&Rð &Rð &Rð &Rñ „[ð&RðP ð9ð 9ð 9ð 9ð 9ñ „[ð9ð ð
 8<Ø26ØØØ#6ØØ#Ø,0ð9
ð 9
ð 9
ð 9
ñ „[ð9
ð 9
ð 9
ð 9
ð 9
r(   r   N)'rc   Ú
__future__r   Úcollections.abcr   Útypingr   Úlangchain_core._apir   Úlangchain_core.callbacksr   Úlangchain_core.language_modelsr   Úlangchain_core.promptsr	   Úlangchain_core.toolsr
   Úpydanticr   Útyping_extensionsr   Ú"langchain_classic._api.deprecationr   Úlangchain_classic.agents.agentr   r   Ú$langchain_classic.agents.agent_typesr   Ú5langchain_classic.agents.conversational.output_parserr   Ú.langchain_classic.agents.conversational.promptr   r   r   Úlangchain_classic.agents.utilsr   Úlangchain_classic.chainsr   r   r/   r(   r&   ú<module>ry      sÍ  ðØ JÐ Jà "Ð "Ð "Ð "Ð "Ð "à $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð à *Ð *Ð *Ð *Ð *Ð *Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø <Ð <Ð <Ð <Ð <Ð <Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø )Ð )Ð )Ð )Ð )Ð )Ø Ð Ð Ð Ð Ð Ø &Ð &Ð &Ð &Ð &Ð &à HÐ HÐ HÐ HÐ HÐ HØ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CØ :Ð :Ð :Ð :Ð :Ð :Ø SÐ SÐ SÐ SÐ SÐ Sðð ð ð ð ð ð ð ð ð ð
 GÐ FÐ FÐ FÐ FÐ FØ -Ð -Ð -Ð -Ð -Ð -ð €ØØ%Øðñ ô ð
P
ð P
ð P
ð P
ð P
˜%ñ P
ô P
ñô ð
P
ð P
ð P
r(   