fix: map reasoning-delta to reasoning_content instead of content (#11847)
The Vercel stream converter was incorrectly mapping reasoning-delta events to delta.content, causing reasoning/thinking content to be treated as regular assistant content. This fix maps it to delta.reasoning_content so downstream consumers can properly distinguish reasoning from regular output. Fixes #11069 Co-authored-by: MumuTW <clothl47364@gmail.com>
This commit is contained in:
parent
ff89a88299
commit
a936c9d04d
2 changed files with 11 additions and 3 deletions
|
|
@ -34,7 +34,10 @@ describe("convertVercelStreamPart", () => {
|
|||
const result = convertVercelStreamPart(part, options);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.choices[0].delta.content).toBe("Let me think...");
|
||||
expect((result?.choices[0].delta as any).reasoning_content).toBe(
|
||||
"Let me think...",
|
||||
);
|
||||
expect(result?.choices[0].delta.content).toBeUndefined();
|
||||
});
|
||||
|
||||
test("returns null for tool-call without thoughtSignature", () => {
|
||||
|
|
|
|||
|
|
@ -94,8 +94,13 @@ export function convertVercelStreamPart(
|
|||
});
|
||||
|
||||
case "reasoning-delta":
|
||||
return chatChunk({
|
||||
content: part.text,
|
||||
return chatChunkFromDelta({
|
||||
delta: {
|
||||
role: "assistant",
|
||||
reasoning_content: part.text,
|
||||
} as ChatCompletionChunk.Choice["delta"] & {
|
||||
reasoning_content?: string;
|
||||
},
|
||||
model,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue