(data: Record<string, unknown>)
| 410 | } |
| 411 | |
| 412 | function isFinalChunk(data: Record<string, unknown>): boolean { |
| 413 | const choices = data.choices as Array<Record<string, unknown>> | undefined |
| 414 | if (!choices || choices.length === 0) return true |
| 415 | return choices.some(c => c.finish_reason != null) |
| 416 | } |
| 417 | |
| 418 | async function handleResponse({ |
| 419 | userId, |