mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
refactor(open-sse): add reasoningDelta helper, dedup thinking deltas (B4)
Centralize the reasoning_content delta shape (optional assistant role) used by claude/gemini/kiro/codex/commandcode response translators. Keeps the cross-format convention consistent for future translators. Output byte-for-byte identical; golden + gate clean. Ollama left as-is (mutates existing delta object). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
import { register } from "../index.js";
|
||||
import { FORMATS } from "../formats.js";
|
||||
import { buildChunk } from "../helpers/chunkBuilder.js";
|
||||
import { reasoningDelta } from "../helpers/reasoningHelper.js";
|
||||
|
||||
function ensureState(state, model) {
|
||||
if (!state.responseId) {
|
||||
@@ -96,9 +97,7 @@ export function convertCommandCodeToOpenAI(chunk, state) {
|
||||
const text = event.text || "";
|
||||
if (!text) break;
|
||||
// Map reasoning to OpenAI "reasoning_content" field (used by deepseek-reasoner-style clients).
|
||||
const delta = state.chunkIndex === 0
|
||||
? { role: "assistant", reasoning_content: text }
|
||||
: { reasoning_content: text };
|
||||
const delta = reasoningDelta(text, state.chunkIndex === 0);
|
||||
state.chunkIndex++;
|
||||
out.push(makeChunk(state, delta));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user