
    @h                     V    S SK r S SKJr  S SKJrJr  S SKJr  S SKJ	r	   " S S\	5      r
g)    N)Union)AgentActionAgentFinish)OutputParserException)AgentOutputParserc                   L    \ rS rSrSrS\S\\\4   4S jr	\
S\4S j5       rSrg)	ReActOutputParser
   z"Output parser for the ReAct agent.textreturnc                    SnUR                  5       R                  S5      S   R                  U5      (       d  SU 3n[        U5      eUR                  5       R                  S5      S   nU[	        U5      S  n[
        R                  " SU5      nUc  SU 3n[        U5      eUR                  S5      UR                  S5      pUS	:X  a  [        S
U0U5      $ [        XxU5      $ )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msgaction_block
action_str
re_matchesactionaction_inputs	            \/var/www/html/shao/venv/lib/python3.13/site-packages/langchain/agents/react/output_parser.pyparseReActOutputParser.parse   s    "zz|!!$'+66}EE07C',,zz|))$/3!#m"4"67
YY0*=
6zlCC',,)//2J4D4DQ4GX,7>>666    c                     g)Nreact )r   s    r#   _typeReActOutputParser._type   s    r&   r)   N)__name__
__module____qualname____firstlineno____doc__strr   r   r   r$   propertyr*   __static_attributes__r)   r&   r#   r	   r	   
   s=    ,7# 7%[(@"A 7$ s  r&   r	   )r   typingr   langchain_core.agentsr   r   langchain_core.exceptionsr   langchain.agents.agentr   r	   r)   r&   r#   <module>r8      s!    	  : ; 4) r&   