(res: Response)
| 35 | } |
| 36 | |
| 37 | protected async *streamSSE<T>(res: Response): AsyncGenerator<T> { |
| 38 | for await (const event of parseSSE(res)) { |
| 39 | if (event.data === '[DONE]') break; |
| 40 | if (!event.data) continue; |
| 41 | try { |
| 42 | yield JSON.parse(event.data) as T; |
| 43 | } catch (err) { |
| 44 | throw new SDKError( |
| 45 | `Failed to parse stream chunk: ${err instanceof Error ? err.message : String(err)}`, |
| 46 | ExitCode.GENERAL, |
| 47 | ); |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | } |
no test coverage detected