From 3d31b2d1b6c72b72ba045c97d0ab215a6ae89bc6 Mon Sep 17 00:00:00 2001
From: Tyler <68524461+TySP-Dev@users.noreply.github.com>
Date: Thu, 14 May 2026 22:08:40 -0400
Subject: [PATCH] Changed text output method again
---
ai_answers.py | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/ai_answers.py b/ai_answers.py
index 82b9b5c..a8921fb 100644
--- a/ai_answers.py
+++ b/ai_answers.py
@@ -1171,10 +1171,20 @@ class SXNGPlugin(Plugin):
if not choices:
return '', "No choices in API response."
message = choices[0].get("message", {})
- content = message.get("content") or ""
- content = re.sub(r'.*?', '', content, flags=re.DOTALL).strip()
+ content = re.sub(r'.*?', '', message.get("content") or "", flags=re.DOTALL).strip()
reasoning = message.get("reasoning") or message.get("reasoning_content") or ""
- full = (f"\n{reasoning}\n\n\n" if reasoning else "") + content
+ if not content and reasoning:
+ # Model put the answer in the reasoning field (qwen3 think:False behaviour).
+ # Extract the final answer: take everything after the last numbered/bulleted
+ # step line, or fall back to the last two non-empty paragraphs.
+ answer = re.split(r'\n(?:\d+[.)]\s|\*\s)', reasoning)[-1].strip()
+ if not answer:
+ paras = [p.strip() for p in re.split(r'\n{2,}', reasoning) if p.strip()]
+ answer = '\n\n'.join(paras[-2:]) if len(paras) >= 2 else reasoning.strip()
+ full = answer
+ else:
+ full = (f"\n{reasoning}\n\n\n" if reasoning else "") + content
+ full = re.sub(r'.*?', '', full, flags=re.DOTALL).strip()
return full, None
except Exception as e:
logger.error(f"{PLUGIN_NAME}: {self.provider} call error: {e}", exc_info=True)