o
    Jjg                     @   sP   d dl Z d dlmZ d dlmZmZ d dlmZ d dlm	Z	 G dd de	Z
dS )    N)Union)AgentActionAgentFinish)OutputParserException)AgentOutputParserc                   @   s<   e Zd ZdZdedeeef fddZe	defddZ
dS )	ReActOutputParserz"Output parser for the ReAct agent.textreturnc                 C   s   d}|  dd |std| |  dd }|t|d  }td|}|d u r7td| |d|d}}|d	krMtd
|i|S t	|||S )NzAction: 
zCould not parse LLM Output: z(.*?)\[(.*?)\]z"Could not parse action directive:       Finishoutput)
stripsplit
startswithr   lenresearchgroupr   r   )selfr   action_prefixaction_block
action_str
re_matchesactionaction_input r   \/var/www/html/zoom/venv/lib/python3.10/site-packages/langchain/agents/react/output_parser.pyparse   s   zReActOutputParser.parsec                 C   s   dS )Nreactr   )r   r   r   r   _type    s   zReActOutputParser._typeN)__name__
__module____qualname____doc__strr   r   r   r    propertyr"   r   r   r   r   r   
   s
    r   )r   typingr   langchain_core.agentsr   r   langchain_core.exceptionsr   langchain.agents.agentr   r   r   r   r   r   <module>   s    