From bbc98a234dde1b0479d05d655fbfa25fa302b122 Mon Sep 17 00:00:00 2001 From: William FH <13333726+hinthornw@users.noreply.github.com> Date: Sun, 17 Dec 2023 20:02:07 -0800 Subject: [PATCH] Update parser (#14831) Gpt-3.5 sometimes calls with empty string arguments instead of `{}` I'd assume it's because the typescript representation on their backend makes it a bit ambiguous. --- libs/langchain/langchain/agents/output_parsers/openai_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/langchain/langchain/agents/output_parsers/openai_tools.py b/libs/langchain/langchain/agents/output_parsers/openai_tools.py index a1e38a9409..4c4759d58a 100644 --- a/libs/langchain/langchain/agents/output_parsers/openai_tools.py +++ b/libs/langchain/langchain/agents/output_parsers/openai_tools.py @@ -36,7 +36,7 @@ def parse_ai_message_to_openai_tool_action( function = tool_call["function"] function_name = function["name"] try: - _tool_input = json.loads(function["arguments"]) + _tool_input = json.loads(function["arguments"] or "{}") except JSONDecodeError: raise OutputParserException( f"Could not parse tool input: {function} because "