From 379c7435ed5d508458e9cdc22386039b84fcec5e Mon Sep 17 00:00:00 2001 From: Robert Craigie Date: Mon, 13 Jan 2025 16:28:31 +0000 Subject: [PATCH] chore: fix streaming --- src/streaming.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/streaming.ts b/src/streaming.ts index da633f7fd..9cfd18176 100644 --- a/src/streaming.ts +++ b/src/streaming.ts @@ -52,22 +52,12 @@ export class Stream implements AsyncIterable { if (data && data.error) { throw new APIError(undefined, data.error, undefined, undefined); } - - yield data; - } else { - let data; - try { - data = JSON.parse(sse.data); - } catch (e) { - console.error(`Could not parse message into JSON:`, sse.data); - console.error(`From chunk:`, sse.raw); - throw e; - } // TODO: Is this where the error should be thrown? if (sse.event == 'error') { throw new APIError(undefined, data.error, data.message, undefined); } - yield { event: sse.event, data: data } as any; + + yield data; } } done = true;