From 15d4e9dbf5c46594e8bfa4179e6526788549986d Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 26 Mar 2026 13:08:22 +0000 Subject: [PATCH] fix: strict json in openai base --- application/llm/openai.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/application/llm/openai.py b/application/llm/openai.py index d3ece394..8bfc3cef 100644 --- a/application/llm/openai.py +++ b/application/llm/openai.py @@ -101,9 +101,13 @@ class OpenAILLM(BaseLLM): for item in content: if "function_call" in item: # Function calls need their own message - cleaned_args = self._remove_null_values( - item["function_call"]["args"] - ) + args = item["function_call"]["args"] + if isinstance(args, str): + try: + args = json.loads(args) + except (json.JSONDecodeError, TypeError): + pass + cleaned_args = self._remove_null_values(args) tool_call = { "id": item["function_call"]["call_id"], "type": "function",