
    Ng	                     Z    d dl mZmZ d dlmZmZ d dlmZ d dlm	Z	  G d de	          Z
dS )    )SequenceUnion)AgentActionAgentFinish)OutputParserException)AgentOutputParserc                   x    e Zd ZU dZdZee         ed<   dZeed<   dede	e
ef         fdZedefd	            Zd
S )SelfAskOutputParseraA  Parses self-ask style LLM calls.

    Expects output to be in one of two formats.

    If the output signals that an action should be taken,
    should be in the below format. This will result in an AgentAction
    being returned.

    ```
    Thoughts go here...
    Follow up: what is the temperature in SF?
    ```

    If the output signals that a final answer should be given,
    should be in the below format. This will result in an AgentFinish
    being returned.

    ```
    Thoughts go here...
    So the final answer is: The temperature is 100 degrees
    ```

    )z
Follow up:z	Followup:	followupszSo the final answer is: finish_stringtextreturnc                    |                     d          d         t          fd| j        D                       sG| j        vrt	          d|           t          dt          | j                  d          i|          S |                     d          d                                         }t          d||          S )N
c                     g | ]}|v S  r   ).0follow	last_lines     d/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain/agents/output_parsers/self_ask.py
<listcomp>z-SelfAskOutputParser.parse.<locals>.<listcomp>'   s    EEEFFi'EEE    zCould not parse output: output:zIntermediate Answer)	splitanyr   r   r   r   lenstripr   )selfr   after_colonr   s      @r   parsezSelfAskOutputParser.parse%   s    JJt$$R(	EEEEdnEEEFF 	W!22+,Mt,M,MNNN)C8J4K4K4M4M*NOQUVVVjjoob)//110+tDDDr   c                     dS )Nself_askr   )r    s    r   _typezSelfAskOutputParser._type/   s    zr   N)__name__
__module____qualname____doc__r   r   str__annotations__r   r   r   r   r"   propertyr%   r   r   r   r
   r
   	   s          0  ;Ix}:::3M3333E# E%[(@"A E E E E s    X  r   r
   N)typingr   r   langchain_core.agentsr   r   langchain_core.exceptionsr   langchain.agents.agentr   r
   r   r   r   <module>r1      s    " " " " " " " " : : : : : : : : ; ; ; ; ; ; 4 4 4 4 4 4( ( ( ( (+ ( ( ( ( (r   