mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
fix: emit reasoning_content in Responses→Chat streaming translation
This commit is contained in:
@@ -602,10 +602,21 @@ export function openaiResponsesToOpenAIResponse(chunk, state) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Reasoning events (convert to content or skip)
|
||||
// Reasoning events — emit as reasoning_content in Chat format
|
||||
if (eventType === "response.reasoning_summary_text.delta") {
|
||||
// Optionally include reasoning as content, or skip
|
||||
return null;
|
||||
const reasoningDelta = data.delta || "";
|
||||
if (!reasoningDelta) return null;
|
||||
return {
|
||||
id: state.chatId,
|
||||
object: "chat.completion.chunk",
|
||||
created: state.created,
|
||||
model: state.model || "gpt-4",
|
||||
choices: [{
|
||||
index: 0,
|
||||
delta: { reasoning_content: reasoningDelta },
|
||||
finish_reason: null,
|
||||
}],
|
||||
};
|
||||
}
|
||||
|
||||
// Ignore other events
|
||||
|
||||
@@ -342,7 +342,7 @@ test("Chat→Responses: deprecated function role message converted to function_c
|
||||
assert.equal(fcOutput.call_id, fcItem.call_id);
|
||||
});
|
||||
|
||||
const { openaiToOpenAIResponsesResponse } = await import(
|
||||
const { openaiToOpenAIResponsesResponse, openaiResponsesToOpenAIResponse } = await import(
|
||||
"../../open-sse/translator/response/openai-responses.ts"
|
||||
);
|
||||
const { initState } = await import("../../open-sse/translator/index.ts");
|
||||
@@ -388,3 +388,18 @@ test("Chat→Responses streaming: completed event includes accumulated output",
|
||||
const msgOutput = completedEvent.data.response.output.find((o) => o.type === "message");
|
||||
assert.ok(msgOutput, "should have message output item");
|
||||
});
|
||||
|
||||
test("Responses→Chat streaming: reasoning delta emits reasoning_content in Chat chunk", () => {
|
||||
const state = { started: false, chatId: null, created: null, toolCallIndex: 0, finishReasonSent: false };
|
||||
|
||||
const chunk = {
|
||||
type: "response.reasoning_summary_text.delta",
|
||||
delta: "thinking step...",
|
||||
item_id: "rs_1",
|
||||
output_index: 0,
|
||||
summary_index: 0,
|
||||
};
|
||||
const result = openaiResponsesToOpenAIResponse(chunk, state);
|
||||
assert.ok(result, "should return a chunk");
|
||||
assert.equal(result.choices[0].delta.reasoning_content, "thinking step...");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user