(data: Record<string, unknown>)
| 445 | } |
| 446 | |
| 447 | function isFinalChunk(data: Record<string, unknown>): boolean { |
| 448 | const choices = data.choices as Array<Record<string, unknown>> | undefined |
| 449 | if (!choices || choices.length === 0) return true |
| 450 | return choices.some(c => c.finish_reason != null) |
| 451 | } |
| 452 | |
| 453 | async function handleResponse({ |
| 454 | userId, |