Skip to content

Commit

Permalink
chore(bedrock): use chunk for internal SSE parsing instead of `comp…
Browse files Browse the repository at this point in the history
…letion` (#472)
  • Loading branch information
RobertCraigie authored and stainless-app[bot] committed Jul 29, 2024
1 parent 8274f4b commit 9515f60
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/bedrock-sdk/src/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Stream<Item> extends CoreStream<Item> {
for await (const event of eventStream) {
if (event.chunk && event.chunk.bytes) {
const s = toUtf8(event.chunk.bytes);
yield { event: 'completion', data: s, raw: [] };
yield { event: 'chunk', data: s, raw: [] };
} else if (event.internalServerException) {
yield { event: 'error', data: 'InternalServerException', raw: [] };
} else if (event.modelStreamErrorException) {
Expand All @@ -69,7 +69,7 @@ export class Stream<Item> extends CoreStream<Item> {
let done = false;
try {
for await (const sse of iterMessages()) {
if (sse.event === 'completion') {
if (sse.event === 'chunk') {
try {
yield JSON.parse(sse.data);
} catch (e) {
Expand Down

0 comments on commit 9515f60

Please sign in to comment.