Skip to content

Commit

Permalink
chore: update comment (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Oct 14, 2023
1 parent 09233b1 commit b04031d
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/streaming.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { ReadableStream, type Response } from './_shims/index';
import { OpenAIError } from './error';

import { APIError } from 'openai/error';

type Bytes = string | ArrayBuffer | Uint8Array | Buffer | null | undefined;

type ServerSentEvent = {
Expand Down Expand Up @@ -60,21 +58,13 @@ export class Stream<Item> implements AsyncIterable<Item> {
}

if (sse.event === null) {
let data;

try {
data = JSON.parse(sse.data);
yield JSON.parse(sse.data);
} catch (e) {
console.error(`Could not parse message into JSON:`, sse.data);
console.error(`From chunk:`, sse.raw);
throw e;
}

if (data && data.error) {
throw new APIError(undefined, data.error, undefined, undefined);
}

yield data;
}
}
done = true;
Expand Down

0 comments on commit b04031d

Please sign in to comment.