From 61c071e035d2e0acbfce74f313dec50796c94eec Mon Sep 17 00:00:00 2001 From: Leohearts Date: Mon, 26 Jan 2026 05:12:38 +0800 Subject: [PATCH] [fix] better json parsing in openai.py (#913) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks for the contribution\! This fix helps users who use alternative GPT APIs like Moonshot that don't support structured output mode. 🎉 --- backend/src/module/parser/analyser/openai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/module/parser/analyser/openai.py b/backend/src/module/parser/analyser/openai.py index c18d0f9d..9ac525a5 100644 --- a/backend/src/module/parser/analyser/openai.py +++ b/backend/src/module/parser/analyser/openai.py @@ -104,7 +104,7 @@ class OpenAIParser: if asdict: try: - result = json.loads(result) + result = json.loads(result[result.index("{"):result.rindex("}") + 1]) # find the first { and last } for better compatibility except json.JSONDecodeError: logger.warning(f"Cannot parse result {result} as python dict.")