diff --git a/langchain/agents/chat/output_parser.py b/langchain/agents/chat/output_parser.py index 4da19526db8..c7023426aa0 100644 --- a/langchain/agents/chat/output_parser.py +++ b/langchain/agents/chat/output_parser.py @@ -17,13 +17,15 @@ class ChatOutputParser(AgentOutputParser): try: action = text.split("```")[1] response = json.loads(action.strip()) - includes_action = "action" in response and "action_input" in response + includes_action = "action" in response if includes_answer and includes_action: raise OutputParserException( "Parsing LLM output produced a final answer " f"and a parse-able action: {text}" ) - return AgentAction(response["action"], response["action_input"], text) + return AgentAction( + response["action"], response.get("action_input", {}), text + ) except Exception: if not includes_answer: