From b0631ec943a496f702afebb4126216583843927a Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Wed, 8 May 2024 21:22:59 +0800 Subject: [PATCH] fix: Add compatibility for devchat-api without JSON MODE - Modified content_to_json function to handle non-JSON content - Introduced _try_remove_markdown_block_flag to preprocess content - Ensured backward compatibility with older devchat-api versions --- devchat/llm/openai.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/devchat/llm/openai.py b/devchat/llm/openai.py index 1b4e938b..4760ac50 100644 --- a/devchat/llm/openai.py +++ b/devchat/llm/openai.py @@ -123,7 +123,8 @@ def chunks_call(chunks): def content_to_json(content): try: - response_obj = json.loads(content) + content_no_block = _try_remove_markdown_block_flag(content) + response_obj = json.loads(content_no_block) return response_obj except json.JSONDecodeError as err: raise RetryException(err) from err