
    ih                     V    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e	      Z
y)    N)Union)AgentActionAgentFinish)OutputParserException)AgentOutputParserc                   @    e Zd ZdZdedeeef   fdZe	defd       Z
y)ReActOutputParserz"Output parser for the ReAct agent.textreturnc                    d}|j                         j                  d      d   j                  |      st        d|       |j                         j                  d      d   }|t	        |      d  }t        j                  d|      }|t        d|       |j                  d      |j                  d      }}|d	k(  rt        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_inputs           b/var/www/html/dev/engine/venv/lib/python3.12/site-packages/langchain/agents/react/output_parser.pyparsezReActOutputParser.parse   s    "zz|!!$'+66}E'*Ftf(MNNzz|))$/3!#m"4"67
YY0*=
'4ZLA   *//2J4D4DQ4GX,7>>v|T::    c                      y)Nreact )r   s    r!   _typezReActOutputParser._type    s    r#   N)__name__
__module____qualname____doc__strr   r   r   r"   propertyr'   r&   r#   r!   r	   r	   
   s=    ,;# ;%[(@"A ;& s  r#   r	   )r   typingr   langchain_core.agentsr   r   langchain_core.exceptionsr   langchain.agents.agentr   r	   r&   r#   r!   <module>r2      s!    	  : ; 4) r#   