(data: Record<string, unknown>)
| 560 | } |
| 561 | |
| 562 | function isFinalChunk(data: Record<string, unknown>): boolean { |
| 563 | const choices = data.choices as Array<Record<string, unknown>> | undefined |
| 564 | if (!choices || choices.length === 0) return true |
| 565 | return choices.some((choice) => choice.finish_reason != null) |
| 566 | } |
| 567 | |
| 568 | async function handleResponse({ |
| 569 | userId, |