@reverbia/sdk 1.0.0-next.20251127132400 → 1.0.0-next.20251127161729

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -937,7 +937,7 @@ function useChat(options) {
937
937
  let accumulatedContent = "";
938
938
  let completionId = "";
939
939
  let completionModel = "";
940
- let usage;
940
+ let accumulatedUsage = {};
941
941
  let finishReason;
942
942
  for await (const chunk of sseResult.stream) {
943
943
  if (typeof chunk === "string" && (chunk.trim() === "[DONE]" || chunk.includes("[DONE]"))) {
@@ -952,7 +952,10 @@ function useChat(options) {
952
952
  completionModel = chunkData.model;
953
953
  }
954
954
  if (chunkData.usage) {
955
- usage = chunkData.usage;
955
+ accumulatedUsage = {
956
+ ...accumulatedUsage,
957
+ ...chunkData.usage
958
+ };
956
959
  }
957
960
  if (chunkData.choices && Array.isArray(chunkData.choices) && chunkData.choices.length > 0) {
958
961
  const choice = chunkData.choices[0];
@@ -985,7 +988,7 @@ function useChat(options) {
985
988
  finish_reason: finishReason
986
989
  }
987
990
  ],
988
- usage
991
+ usage: Object.keys(accumulatedUsage).length > 0 ? accumulatedUsage : void 0
989
992
  };
990
993
  setIsLoading(false);
991
994
  if (onFinish) {
@@ -893,7 +893,7 @@ function useChat(options) {
893
893
  let accumulatedContent = "";
894
894
  let completionId = "";
895
895
  let completionModel = "";
896
- let usage;
896
+ let accumulatedUsage = {};
897
897
  let finishReason;
898
898
  for await (const chunk of sseResult.stream) {
899
899
  if (typeof chunk === "string" && (chunk.trim() === "[DONE]" || chunk.includes("[DONE]"))) {
@@ -908,7 +908,10 @@ function useChat(options) {
908
908
  completionModel = chunkData.model;
909
909
  }
910
910
  if (chunkData.usage) {
911
- usage = chunkData.usage;
911
+ accumulatedUsage = {
912
+ ...accumulatedUsage,
913
+ ...chunkData.usage
914
+ };
912
915
  }
913
916
  if (chunkData.choices && Array.isArray(chunkData.choices) && chunkData.choices.length > 0) {
914
917
  const choice = chunkData.choices[0];
@@ -941,7 +944,7 @@ function useChat(options) {
941
944
  finish_reason: finishReason
942
945
  }
943
946
  ],
944
- usage
947
+ usage: Object.keys(accumulatedUsage).length > 0 ? accumulatedUsage : void 0
945
948
  };
946
949
  setIsLoading(false);
947
950
  if (onFinish) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reverbia/sdk",
3
- "version": "1.0.0-next.20251127132400",
3
+ "version": "1.0.0-next.20251127161729",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",