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:
@@ -2,6 +2,7 @@ import { register } from "../index.js";
|
||||
import { FORMATS } from "../formats.js";
|
||||
import { buildChunk } from "../helpers/chunkBuilder.js";
|
||||
import { buildUsage } from "../helpers/usageHelper.js";
|
||||
import { reasoningDelta } from "../helpers/reasoningHelper.js";
|
||||
|
||||
// Build chunk meta for current gemini state
|
||||
function chunkMeta(state) {
|
||||
@@ -42,7 +43,7 @@ export function geminiToOpenAIResponse(chunk, state) {
|
||||
if (hasTextContent) {
|
||||
results.push(buildChunk(
|
||||
chunkMeta(state),
|
||||
isThought ? { reasoning_content: part.text } : { content: part.text },
|
||||
isThought ? reasoningDelta(part.text) : { content: part.text },
|
||||
null
|
||||
));
|
||||
}
|
||||
@@ -78,7 +79,7 @@ export function geminiToOpenAIResponse(chunk, state) {
|
||||
if (part.text !== undefined && part.text !== "") {
|
||||
results.push(buildChunk(
|
||||
chunkMeta(state),
|
||||
isThought ? { reasoning_content: part.text } : { content: part.text },
|
||||
isThought ? reasoningDelta(part.text) : { content: part.text },
|
||||
null
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user