ai 6.0.39 → 6.0.40

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.40
4
+
5
+ ### Patch Changes
6
+
7
+ - ab57783: Add usage information to onFinish callback in useChat
8
+
3
9
  ## 6.0.39
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1749,6 +1749,7 @@ declare const uiMessageChunkSchema: _ai_sdk_provider_utils.LazySchema<{
1749
1749
  } | {
1750
1750
  type: "finish";
1751
1751
  finishReason?: "length" | "error" | "stop" | "content-filter" | "tool-calls" | "other" | undefined;
1752
+ usage?: LanguageModelUsage | undefined;
1752
1753
  messageMetadata?: unknown;
1753
1754
  } | {
1754
1755
  type: "abort";
@@ -1874,6 +1875,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
1874
1875
  } | {
1875
1876
  type: 'finish';
1876
1877
  finishReason?: FinishReason;
1878
+ usage?: LanguageModelUsage;
1877
1879
  messageMetadata?: METADATA;
1878
1880
  } | {
1879
1881
  type: 'abort';
@@ -3217,6 +3219,7 @@ type ChatOnDataCallback<UI_MESSAGE extends UIMessage> = (dataPart: DataUIPart<In
3217
3219
  * @param isDisconnect Indicates whether the request has been ended by a network error.
3218
3220
  * @param isError Indicates whether the request has been ended by an error.
3219
3221
  * @param finishReason The reason why the generation finished.
3222
+ * @param usage Token usage information for the response.
3220
3223
  */
3221
3224
  type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
3222
3225
  message: UI_MESSAGE;
@@ -3225,6 +3228,7 @@ type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
3225
3228
  isDisconnect: boolean;
3226
3229
  isError: boolean;
3227
3230
  finishReason?: FinishReason;
3231
+ usage?: LanguageModelUsage;
3228
3232
  }) => void;
3229
3233
  interface ChatInit<UI_MESSAGE extends UIMessage> {
3230
3234
  /**
package/dist/index.d.ts CHANGED
@@ -1749,6 +1749,7 @@ declare const uiMessageChunkSchema: _ai_sdk_provider_utils.LazySchema<{
1749
1749
  } | {
1750
1750
  type: "finish";
1751
1751
  finishReason?: "length" | "error" | "stop" | "content-filter" | "tool-calls" | "other" | undefined;
1752
+ usage?: LanguageModelUsage | undefined;
1752
1753
  messageMetadata?: unknown;
1753
1754
  } | {
1754
1755
  type: "abort";
@@ -1874,6 +1875,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
1874
1875
  } | {
1875
1876
  type: 'finish';
1876
1877
  finishReason?: FinishReason;
1878
+ usage?: LanguageModelUsage;
1877
1879
  messageMetadata?: METADATA;
1878
1880
  } | {
1879
1881
  type: 'abort';
@@ -3217,6 +3219,7 @@ type ChatOnDataCallback<UI_MESSAGE extends UIMessage> = (dataPart: DataUIPart<In
3217
3219
  * @param isDisconnect Indicates whether the request has been ended by a network error.
3218
3220
  * @param isError Indicates whether the request has been ended by an error.
3219
3221
  * @param finishReason The reason why the generation finished.
3222
+ * @param usage Token usage information for the response.
3220
3223
  */
3221
3224
  type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
3222
3225
  message: UI_MESSAGE;
@@ -3225,6 +3228,7 @@ type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
3225
3228
  isDisconnect: boolean;
3226
3229
  isError: boolean;
3227
3230
  finishReason?: FinishReason;
3231
+ usage?: LanguageModelUsage;
3228
3232
  }) => void;
3229
3233
  interface ChatInit<UI_MESSAGE extends UIMessage> {
3230
3234
  /**