This commit is contained in:
decolua
2026-06-15 18:18:04 +07:00
parent 8ab5af0052
commit b282f05549
66 changed files with 2328 additions and 213 deletions
+16
View File
@@ -6,3 +6,19 @@ export function reasoningDelta(text, withRole = false) {
? { role: ROLE.ASSISTANT, reasoning_content: text }
: { reasoning_content: text };
}
// Extract reasoning text from a streamed OpenAI-compatible delta across vendor shapes:
// - reasoning_content (GLM, Qwen, DeepSeek, Kimi, Step, Hunyuan)
// - reasoning (some compat layers)
// - reasoning_details[] (MiniMax reasoning_split=true): [{ text|content }]
// Returns concatenated reasoning string, or "" when none.
export function extractReasoningText(delta) {
if (!delta || typeof delta !== "object") return "";
if (typeof delta.reasoning_content === "string" && delta.reasoning_content) return delta.reasoning_content;
if (typeof delta.reasoning === "string" && delta.reasoning) return delta.reasoning;
const details = delta.reasoning_details;
if (Array.isArray(details)) {
return details.map((d) => (typeof d === "string" ? d : d?.text || d?.content || "")).join("");
}
return "";
}