diff --git a/astrbot/core/provider/sources/gemini_source.py b/astrbot/core/provider/sources/gemini_source.py index 56526c121..09faffbd7 100644 --- a/astrbot/core/provider/sources/gemini_source.py +++ b/astrbot/core/provider/sources/gemini_source.py @@ -344,7 +344,8 @@ def _process_content_parts( if not result_parts: logger.debug(result.candidates) - raise Exception("API 返回的内容为空。") + logger.debug("API 可能返回了空消息。") + return MessageChain(chain=[]) chain = [] part: types.Part diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index 14c2da2de..9ce5315ff 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -214,6 +214,9 @@ async def parse_openai_completion( logger.error(f"API 返回的 completion 无法解析:{completion}。") raise Exception(f"API 返回的 completion 无法解析:{completion}。") + if llm_response.completion_text == "": + logger.debug("API 可能返回了空消息。") + llm_response.raw_completion = completion return llm_response