Changed text output method again
CI Test Guard / validate-code (push) Has been cancelled

This commit is contained in:
Tyler
2026-05-14 22:08:40 -04:00
parent de6156933a
commit 3d31b2d1b6
+13 -3
View File
@@ -1171,10 +1171,20 @@ class SXNGPlugin(Plugin):
if not choices: if not choices:
return '', "No choices in API response." return '', "No choices in API response."
message = choices[0].get("message", {}) message = choices[0].get("message", {})
content = message.get("content") or "" content = re.sub(r'<think>.*?</think>', '', message.get("content") or "", flags=re.DOTALL).strip()
content = re.sub(r'<think>.*?</think>', '', content, flags=re.DOTALL).strip()
reasoning = message.get("reasoning") or message.get("reasoning_content") or "" reasoning = message.get("reasoning") or message.get("reasoning_content") or ""
full = (f"<think>\n{reasoning}\n</think>\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"<think>\n{reasoning}\n</think>\n\n" if reasoning else "") + content
full = re.sub(r'<think>.*?</think>', '', full, flags=re.DOTALL).strip()
return full, None return full, None
except Exception as e: except Exception as e:
logger.error(f"{PLUGIN_NAME}: {self.provider} call error: {e}", exc_info=True) logger.error(f"{PLUGIN_NAME}: {self.provider} call error: {e}", exc_info=True)