mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
Refactor
This commit is contained in:
@@ -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 "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user