The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Fix Custom LLM Agent example (#6429)
Nir Gazit95b77a52153b
diff --git a/docs/snippets/modules/agents/how_to/custom_llm_agent.mdx b/docs/snippets/modules/agents/how_to/custom_llm_agent.mdxindex ac892816d5..eebf7429f0 100644--- a/docs/snippets/modules/agents/how_to/custom_llm_agent.mdx+++ b/docs/snippets/modules/agents/how_to/custom_llm_agent.mdx@@ -22,7 +22,7 @@ from langchain.agents import Tool, AgentExecutor, LLMSingleActionAgent, AgentOutfrom langchain.prompts import StringPromptTemplatefrom langchain import OpenAI, SerpAPIWrapper, LLMChainfrom typing import List, Union-from langchain.schema import AgentAction, AgentFinish+from langchain.schema import AgentAction, AgentFinish, OutputParserExceptionimport re```@@ -135,7 +135,7 @@ class CustomOutputParser(AgentOutputParser):regex = r"Action\s*\d*\s*:(.*?)\nAction\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)"match = re.search(regex, llm_output, re.DOTALL)if not match:- raise ValueError(f"Could not parse LLM output: `{llm_output}`")+ raise OutputParserException(f"Could not parse LLM output: `{llm_output}`")action = match.group(1).strip()action_input = match.group(2)# Return the action and action input