
    KKi                       S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJrJr  SSKJr  SSKJr  SSKJrJ r J!r!  SSK"J#r#  SSK$J%r%  \" S\SS9 " S S\5      5       r&g)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1.0)messageremovalc            	      f  ^  \ rS rSr% SrSrS\S'    \" \S9r	S\S'    \
\ S     SS	 jj5       5       r\SS
 j5       r\SS j5       r\SS j5       r\
\\\SSS4               SS jj5       r\
SU 4S jj5       r\
SS\\\SSS4                       SS jj5       rSrU =r$ )ConversationalAgent   z>An agent that holds a conversation in addition to using tools.AIstr	ai_prefix)default_factoryr   output_parserc                    [        US9$ )Nr   r   )clsr   kwargss      n/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/langchain_classic/agents/conversational/base.py_get_default_output_parser.ConversationalAgent._get_default_output_parser*   s     !955    c                "    [         R                  $ )z Return Identifier of agent type.)r    CONVERSATIONAL_REACT_DESCRIPTIONselfs    r&   _agent_typeConversationalAgent._agent_type3   s     999r)   c                    g)zEPrefix to append the observation with.

Returns:
    "Observation: "
zObservation:  r,   s    r&   observation_prefix&ConversationalAgent.observation_prefix8   s     r)   c                    g)z>Prefix to append the llm call with.

Returns:
    "Thought: "
zThought:r1   r,   s    r&   
llm_prefixConversationalAgent.llm_prefixA   s     r)   HumanNc           	     @   SR                  U Vs/ s H  nSUR                   SUR                   3PM!     sn5      n	SR                  U Vs/ s H  oR                  PM     sn5      n
UR                  U
UUS9nU SU	 SU SU 3nUc  / SQn[	        XS9$ s  snf s  snf )	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.

z> z: z, )
tool_namesr   human_prefixz

)inputchat_historyagent_scratchpad)templateinput_variables)joinnamedescriptionformatr	   )r$   toolsprefixsuffixformat_instructionsr   r;   r@   tooltool_stringsr:   r?   s               r&   create_prompt!ConversationalAgent.create_promptJ   s    6 yy>CDedr$))Bt//01eD
 YYe<ed		e<=
188!% 9 

 XT,t4G3HVHU"KOxQQ E<s   &BBc                P   > [         TU ]  U5        [        U R                  U5        g )N)super_validate_toolsr   __name__)r$   rE   	__class__s     r&   rO   #ConversationalAgent._validate_toolss   s    &#CLL%8r)   c           
         U R                  U5        U R                  UUU	UUUU
S9n[        UUUS9nU Vs/ s H  oR                  PM     nnU=(       d    U R	                  US9nU " SUUUUS.UD6$ s  snf )ae  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   r;   rF   rG   rH   r@   )llmpromptcallback_managerr#   )	llm_chainallowed_toolsr   r!   r1   )rO   rK   r   rB   r'   )r$   rT   rE   rV   r!   rF   rG   rH   r   r;   r@   r%   rU   rW   rI   r:   _output_parsers                    r&   from_llm_and_tools&ConversationalAgent.from_llm_and_toolsx   s    B 	E"""% 3+ # 
 -
	
 -22EDiiE
2& 
#*H*H +I +
  
$(	

 
 	
	 3s   A2r1   )r   )r   r   r%   r   returnr   )r\   r   )rE   Sequence[BaseTool]rF   r   rG   r   rH   r   r   r   r;   r   r@   list[str] | Noner\   r	   )rE   r]   r\   None)rT   r   rE   r]   rV   zBaseCallbackManager | Noner!   zAgentOutputParser | NonerF   r   rG   r   rH   r   r   r   r;   r   r@   r^   r%   r   r\   r   )rP   
__module____qualname____firstlineno____doc__r   __annotations__r   r   r!   classmethodr   r'   propertyr.   r2   r5   r   r   r   rK   rO   rZ   __static_attributes____classcell__)rQ   s   @r&   r   r      s    IIs)',=N'OM$O& 66 6 
	6  6 : :      #6#,0&R!&R &R 	&R
 !&R &R &R *&R 
&R &RP 9 9 
 8<26#6#,09
9
 "9
 5	9

 09
 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   r1   r)   r&   <module>rz      sq    J " $  * 8 < 1 )  & H C : S 
 G - %
P
% P

P
r)   