From 6e780919f5bef447fcaa61e326d58234873e951e Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Fri, 29 Mar 2024 10:07:33 +0000 Subject: [PATCH] fix(streaming): correct accumulation of output tokens (#361) --- src/lib/MessageStream.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/MessageStream.ts b/src/lib/MessageStream.ts index 628b8255..cf90bda6 100644 --- a/src/lib/MessageStream.ts +++ b/src/lib/MessageStream.ts @@ -450,6 +450,7 @@ export class MessageStream implements AsyncIterable { case 'message_delta': snapshot.stop_reason = event.delta.stop_reason; snapshot.stop_sequence = event.delta.stop_sequence; + snapshot.usage.output_tokens = event.usage.output_tokens; return snapshot; case 'content_block_start': snapshot.content.push(event.content_block);