From a5c5d29dedb438e536b4b372d433965f4bee2684 Mon Sep 17 00:00:00 2001 From: Kingston-SCYD Date: Sun, 16 Aug 2026 23:27:56 -0500 Subject: [PATCH] Handle DeepSeek reasoning_content fallback for empty responses --- assistant/assistant.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/assistant/assistant.py b/assistant/assistant.py index ce43901..043586b 100644 --- a/assistant/assistant.py +++ b/assistant/assistant.py @@ -170,12 +170,18 @@ class Assistant(commands.Cog): return f"Request failed: {exc}" try: - reply = data["choices"][0]["message"]["content"] + choice = data["choices"][0]["message"] + reply = choice.get("content") or "" + # Some models (e.g. DeepSeek) put their response in reasoning_content + if not reply.strip(): + reasoning = choice.get("reasoning_content") or "" + if reasoning.strip(): + reply = reasoning except (KeyError, IndexError): return f"Unexpected API response: {str(data)[:300]}" - if not reply: - return f"Empty response. Raw: {str(data)[:300]}" + if not reply or not reply.strip(): + return "The model returned an empty response. Try rephrasing or switching models." self.history[key].append({"role": "assistant", "content": reply})