The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Harrison/update regex (#1534)
Harrison Chase7eba828e1b95
diff --git a/langchain/agents/conversational/base.py b/langchain/agents/conversational/base.pyindex 1673988197..e47329d2ed 100644--- a/langchain/agents/conversational/base.py+++ b/langchain/agents/conversational/base.py@@ -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}`")diff --git a/langchain/agents/mrkl/base.py b/langchain/agents/mrkl/base.pyindex 2b0e190a7e..64f0ed71e6 100644--- a/langchain/agents/mrkl/base.py+++ b/langchain/agents/mrkl/base.py@@ -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}`")