199
*/
200
export function bridgeResultToSseFrames(result: IByokLmChatResult, model: string): string[] {
202
>
const created = Math.floor(Date.now() / 1000);
203
>
const base = { id, object: 'chat.completion.chunk', created, model };
204
>
const frames: string[] = [];
205
>
206
>
// Role delta first, matching the OpenAI streaming contract.
207
>
frames.push(sseFrame({ ...base, choices: [{ index: 0, delta: { role: 'assistant' }, finish_reason: null }] }));
208
>
209
>
if (result.content) {
210
frames.push(sseFrame({ ...base, choices: [{ index: 0, delta: { content: result.content }, finish_reason: null }] }));
211
}
213
>
let finishReason: 'stop' | 'tool_calls' = 'stop';
214
>
if (result.toolCalls && result.toolCalls.length > 0) {
215
finishReason = 'tool_calls';
216
const toolCallsDelta = result.toolCalls.map((call, index) => ({