
    f3fio                    r    d 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 erddlmZmZ  G d d	e	      Zy
)(Callback Handler that prints to std out.    )annotations)TYPE_CHECKINGAny)override)BaseCallbackHandler)
print_text)AgentActionAgentFinishc                      e Zd ZdZd
ddZe	 	 	 	 	 	 	 	 dd       Zedd       Ze	 d
	 	 	 	 	 	 	 dd       Ze	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dd       Z	e	 	 d	 	 	 	 	 	 	 	 	 dd       Z
e	 d
	 	 	 	 	 	 	 dd	       Zy)StdOutCallbackHandlerr   Nc                    || _         y)zfInitialize callback handler.

        Args:
            color: The color to use for the text.
        Ncolor)selfr   s     ]/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_core/callbacks/stdout.py__init__zStdOutCallbackHandler.__init__   s     
    c                    d|v r|d   }n+|r'|j                  d|j                  ddg      d         }nd}t        d| d       y)zPrint out that we are entering a chain.

        Args:
            serialized: The serialized chain.
            inputs: The inputs to the chain.
            **kwargs: Additional keyword arguments.
        nameidz	<unknown>z

[1m> Entering new z chain...[0mN)getprint)r   
serializedinputskwargsr   s        r   on_chain_startz$StdOutCallbackHandler.on_chain_start   sR     V&>D>>&*..}*Mb*QRDD*4&0@ABr   c                    t        d       y)zPrint out that we finished a chain.

        Args:
            outputs: The outputs of the chain.
            **kwargs: Additional keyword arguments.
        z
[1m> Finished chain.[0mN)r   )r   outputsr   s      r   on_chain_endz"StdOutCallbackHandler.on_chain_end.   s     	12r   c                N    t        |j                  |xs | j                         y)zRun on agent action.

        Args:
            action: The agent action.
            color: The color to use for the text.
            **kwargs: Additional keyword arguments.
        r   Nr	   logr   )r   actionr   r   s       r   on_agent_actionz%StdOutCallbackHandler.on_agent_action8   s     	6::U%8djj9r   c                    t        |      }|t        d|        t        ||xs | j                         |t        d|        yy)a6  If not the final action, print out observation.

        Args:
            output: The output to print.
            color: The color to use for the text.
            observation_prefix: The observation prefix.
            llm_prefix: The LLM prefix.
            **kwargs: Additional keyword arguments.
        N
r   )strr	   r   )r   outputr   observation_prefix
llm_prefixr   s         r   on_tool_endz!StdOutCallbackHandler.on_tool_endE   sQ    $ V)./016!4$**5!J<() "r   c                <    t        ||xs | j                  |       y)zRun when the agent ends.

        Args:
            text: The text to print.
            color: The color to use for the text.
            end: The end character to use.
            **kwargs: Additional keyword arguments.
        r   endN)r	   r   )r   textr   r0   r   s        r   on_textzStdOutCallbackHandler.on_text^   s      	4u2

<r   c                P    t        |j                  |xs | j                  d       y)zRun on the agent end.

        Args:
            finish: The agent finish.
            color: The color to use for the text.
            **kwargs: Additional keyword arguments.
        r(   r/   Nr#   )r   finishr   r   s       r   on_agent_finishz%StdOutCallbackHandler.on_agent_finishp   s     	6::U%8djjdCr   )N)r   
str | NonereturnNone)r   dict[str, Any]r   r9   r   r   r7   r8   )r    r9   r   r   r7   r8   )r%   r
   r   r6   r   r   r7   r   )NNN)r*   r   r   r6   r+   r6   r,   r6   r   r   r7   r8   )N )
r1   r)   r   r6   r0   r)   r   r   r7   r8   )r4   r   r   r6   r   r   r7   r8   )__name__
__module____qualname____doc__r   r   r   r!   r&   r-   r2   r5    r   r   r   r      sq   2 C(C2@CLOC	C C$ 3 3 7;
:!
:*4
:GJ
:	
: 
:  !)-!%** * '	*
 * * 
* *0  !	== = 	=
 = 
= =" 7;
D!
D*4
DGJ
D	
D 
Dr   r   N)r>   
__future__r   typingr   r   typing_extensionsr   langchain_core.callbacks.baser   langchain_core.utilsr	   langchain_core.agentsr
   r   r   r?   r   r   <module>rF      s.    . " % & = +>kD/ kDr   