(data: Record<string, unknown>)
| 580 | } |
| 581 | |
| 582 | function isFinalChunk(data: Record<string, unknown>): boolean { |
| 583 | const choices = data.choices as Array<Record<string, unknown>> | undefined |
| 584 | if (!choices || choices.length === 0) return true |
| 585 | return choices.some((choice) => choice.finish_reason != null) |
| 586 | } |
| 587 | |
| 588 | async function handleResponse({ |
| 589 | userId, |