a
    ag                     @   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eeeef dddZe	ed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 rntd| |d|d }}|d	krtd
|i|S t	|||S d S )NzAction: 
zCould not parse LLM Output: z(.*?)\[(.*?)\]z"Could not parse action directive:       ZFinishoutput)
stripsplit
startswithr   lenresearchgroupr   r   )selfr   Zaction_prefixZaction_blockZ
action_strZ
re_matchesactionZaction_input r   r/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain/agents/react/output_parser.pyparse   s    zReActOutputParser.parse)r	   c                 C   s   dS )NZ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   Zlangchain_core.agentsr   r   Zlangchain_core.exceptionsr   Zlangchain.agents.agentr   r   r   r   r   r   <module>   s
   