(body: string)
| 12 | } |
| 13 | |
| 14 | function parseAllSSEChunks(body: string): SSEChunkWithUsage[] { |
| 15 | return body |
| 16 | .split("\n\n") |
| 17 | .filter((line) => line.startsWith("data: ") && !line.includes("[DONE]")) |
| 18 | .map((line) => JSON.parse(line.slice(6))); |
| 19 | } |
| 20 | |
| 21 | function hasUsageChunk(chunks: SSEChunkWithUsage[]): boolean { |
| 22 | return chunks.some((c) => c.usage !== undefined && c.choices.length === 0); |
no outgoing calls
no test coverage detected
searching dependent graphs…