mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 07:04:45 +00:00
Add reasoning events and abort-aware finish reason to chat endpoint
Map thinking_start/delta/end to Vercel AI SDK reasoning-start/delta/end chunk types. Derive finish reason from enqueueMessage result - aborted sessions get a clean finish with reason "error" instead of an error chunk.
This commit is contained in:
parent
fcd51005e2
commit
8a61de15fa
2 changed files with 25 additions and 1 deletions
|
|
@ -638,7 +638,12 @@ export class GatewayRuntime {
|
|||
if (result.ok) {
|
||||
finishVercelStream(response, "stop");
|
||||
} else {
|
||||
errorVercelStream(response, result.error ?? "Unknown error");
|
||||
const isAbort = result.error?.includes("aborted");
|
||||
if (isAbort) {
|
||||
finishVercelStream(response, "error");
|
||||
} else {
|
||||
errorVercelStream(response, result.error ?? "Unknown error");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -125,6 +125,25 @@ export function createVercelStreamListener(
|
|||
input: inner.toolCall.arguments,
|
||||
});
|
||||
return;
|
||||
case "thinking_start":
|
||||
writeChunk(response, {
|
||||
type: "reasoning-start",
|
||||
id: `reasoning_${inner.contentIndex}`,
|
||||
});
|
||||
return;
|
||||
case "thinking_delta":
|
||||
writeChunk(response, {
|
||||
type: "reasoning-delta",
|
||||
id: `reasoning_${inner.contentIndex}`,
|
||||
delta: inner.delta,
|
||||
});
|
||||
return;
|
||||
case "thinking_end":
|
||||
writeChunk(response, {
|
||||
type: "reasoning-end",
|
||||
id: `reasoning_${inner.contentIndex}`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue