mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-17 02:03:44 +00:00
Harrison/update regex (#1534)
Co-authored-by: Luis <57528712+LuisLechugaRuiz@users.noreply.github.com>
This commit is contained in:
parent
2a7215bc3b
commit
7eba828e1b
@ -78,7 +78,7 @@ class ConversationalAgent(Agent):
|
||||
def _extract_tool_and_input(self, llm_output: str) -> Optional[Tuple[str, str]]:
|
||||
if f"{self.ai_prefix}:" in llm_output:
|
||||
return self.ai_prefix, llm_output.split(f"{self.ai_prefix}:")[-1].strip()
|
||||
regex = r"Action: (.*?)\nAction Input: (.*)"
|
||||
regex = r"Action: (.*?)[\n]*Action Input: (.*)"
|
||||
match = re.search(regex, llm_output)
|
||||
if not match:
|
||||
raise ValueError(f"Could not parse LLM output: `{llm_output}`")
|
||||
|
@ -40,7 +40,7 @@ def get_action_and_input(llm_output: str) -> Tuple[str, str]:
|
||||
"""
|
||||
if FINAL_ANSWER_ACTION in llm_output:
|
||||
return "Final Answer", llm_output.split(FINAL_ANSWER_ACTION)[-1].strip()
|
||||
regex = r"Action: (.*?)\nAction Input: (.*)"
|
||||
regex = r"Action: (.*?)[\n]*Action Input: (.*)"
|
||||
match = re.search(regex, llm_output, re.DOTALL)
|
||||
if not match:
|
||||
raise ValueError(f"Could not parse LLM output: `{llm_output}`")
|
||||
|
Loading…
Reference in New Issue
Block a user