From 2984ad39645c80411cee5e7f77a3c116b88d008e Mon Sep 17 00:00:00 2001 From: __Jay__ <90436829+pythoninoffice@users.noreply.github.com> Date: Tue, 18 Apr 2023 00:42:13 -0400 Subject: [PATCH] updated llm response parsing action (#3058) Sometimes the LLM response (generated code) tends to miss the ending ticks "```". Therefore causing the text parsing to fail due to not enough values to unpack. The 2 extra `_` don't add value and can cause errors. Suggest to simply update the `_, action, _` to just `action` then with index. Fixes issue #3057 --- langchain/agents/chat/output_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain/agents/chat/output_parser.py b/langchain/agents/chat/output_parser.py index 7c79a5b26d..0d07e7e0c2 100644 --- a/langchain/agents/chat/output_parser.py +++ b/langchain/agents/chat/output_parser.py @@ -14,7 +14,7 @@ class ChatOutputParser(AgentOutputParser): {"output": text.split(FINAL_ANSWER_ACTION)[-1].strip()}, text ) try: - _, action, _ = text.split("```") + action = text.split("```")[1] response = json.loads(action.strip()) return AgentAction(response["action"], response["action_input"], text)