From eb0325e627790a16ca8fb078e0a7f35cb2ac9637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=A0=E4=BB=AC=E7=9A=84=E9=A5=BA=E5=AD=90?= <64739528+MCjiaozi@users.noreply.github.com> Date: Sat, 2 Aug 2025 15:46:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=20OpenAI=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=9A=84=20LLM=20=E7=A9=BA=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E5=AF=BC=E8=87=B4=E7=9A=84=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=20completion=20=E7=9A=84=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E3=80=82=20(#2279)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/provider/sources/openai_source.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index e7ce0d54a..14c2da2de 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -176,7 +176,7 @@ class ProviderOpenAIOfficial(Provider): raise Exception("API 返回的 completion 为空。") choice = completion.choices[0] - if choice.message.content: + if choice.message.content is not None: # text completion completion_text = str(choice.message.content).strip() llm_response.result_chain = MessageChain().message(completion_text) @@ -210,7 +210,7 @@ class ProviderOpenAIOfficial(Provider): "API 返回的 completion 由于内容安全过滤被拒绝(非 AstrBot)。" ) - if not llm_response.completion_text and not llm_response.tools_call_args: + if llm_response.completion_text is None and not llm_response.tools_call_args: logger.error(f"API 返回的 completion 无法解析:{completion}。") raise Exception(f"API 返回的 completion 无法解析:{completion}。")