class_docstr: MRKL Output parser for the chat agent.
code: def parse(self, text: str) -> Union[AgentAction, AgentFinish]:
      includes_answer = FINAL_ANSWER_ACTION in text
      regex = r"Action\s*\d*\s*:[\s]*(.*?)[\s]*Action\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)"
      action_match = re.search(regex, text, re.DOTALL)
      if includes_answer:
          return AgentFinish(
              {"output": text.split(FINAL_ANSWER_ACTION)[-1].strip()},
              text,
          )
      elif action_match:
          action = action_match.group(1).strip()
          action_input = action_match.group(2)
          tool_input = action_input.strip(" ")
          # ensure if its a well formed SQL query we don't remove any trailing " chars
          if tool_input.startswith("SELECT ") is False:
              tool_input = tool_input.strip('"')
  
          return AgentAction(action, tool_input, text)
  
      if not re.search(r"Action\s*\d*\s*:[\s]*(.*?)", text, re.DOTALL):
          raise OutputParserException(
              f"Could not parse LLM output: `{text}`",
              observation=MISSING_ACTION_AFTER_THOUGHT_ERROR_MESSAGE,
              llm_output=text,
              send_to_llm=True,
          )
      elif not re.search(
          r"[\s]*Action\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)",
          text,
          re.DOTALL,
      ):
          raise OutputParserException(
              f"Could not parse LLM output: `{text}`",
              observation=MISSING_ACTION_INPUT_AFTER_ACTION_ERROR_MESSAGE,
              llm_output=text,
              send_to_llm=True,
          )
      else:
          raise OutputParserException(
              f"Could not parse LLM output: `{text}`"
          )
  
file_path: h2ogpt/src/output_parser.py
imports: import re
  from typing import Union
  from langchain.agents.mrkl.output_parser import MRKLOutputParser
  from langchain.schema import AgentAction, AgentFinish, OutputParserException
label_desc: Use image node_id 2 for calling the H2OMRKLOutputParser obj's underlying member method code with example usage: obj.parse(text) and returns: AgentFinish, AgentAction