From 72f216b4898dce86b416909f76648fe199e3f34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Doucy?= Date: Mon, 17 Jun 2024 18:15:57 +0200 Subject: [PATCH 1/2] Fix missing usageMetadata in streamed aggregated response (#174) --- packages/main/src/requests/stream-reader.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/main/src/requests/stream-reader.ts b/packages/main/src/requests/stream-reader.ts index ebd98534..8257ffda 100644 --- a/packages/main/src/requests/stream-reader.ts +++ b/packages/main/src/requests/stream-reader.ts @@ -188,6 +188,9 @@ export function aggregateResponses( } } } + if (response.usageMetadata) { + aggregatedResponse.usageMetadata = response.usageMetadata; + } } return aggregatedResponse; } From eba7ea48cf34080452141d6eb9c4ebef04c03cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Doucy?= Date: Mon, 17 Jun 2024 21:08:25 +0200 Subject: [PATCH 2/2] Add changeset --- .changeset/quick-horses-retire.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/quick-horses-retire.md diff --git a/.changeset/quick-horses-retire.md b/.changeset/quick-horses-retire.md new file mode 100644 index 00000000..efd40731 --- /dev/null +++ b/.changeset/quick-horses-retire.md @@ -0,0 +1,5 @@ +--- +"@google/generative-ai": patch +--- + +Fix missing usageMetadata in streamed aggregated response (#174)