ai 6.0.40 → 6.0.41

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/src/ui/chat.ts CHANGED
@@ -5,7 +5,6 @@ import {
5
5
  InferSchema,
6
6
  } from '@ai-sdk/provider-utils';
7
7
  import { FinishReason } from '../types/language-model';
8
- import { LanguageModelUsage } from '../types/usage';
9
8
  import { UIMessageChunk } from '../ui-message-stream/ui-message-chunks';
10
9
  import { consumeStream } from '../util/consume-stream';
11
10
  import { SerialJobExecutor } from '../util/serial-job-executor';
@@ -125,7 +124,6 @@ export type ChatOnDataCallback<UI_MESSAGE extends UIMessage> = (
125
124
  * @param isDisconnect Indicates whether the request has been ended by a network error.
126
125
  * @param isError Indicates whether the request has been ended by an error.
127
126
  * @param finishReason The reason why the generation finished.
128
- * @param usage Token usage information for the response.
129
127
  */
130
128
  export type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
131
129
  message: UI_MESSAGE;
@@ -134,7 +132,6 @@ export type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
134
132
  isDisconnect: boolean;
135
133
  isError: boolean;
136
134
  finishReason?: FinishReason;
137
- usage?: LanguageModelUsage;
138
135
  }) => void;
139
136
 
140
137
  export interface ChatInit<UI_MESSAGE extends UIMessage> {
@@ -694,9 +691,6 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
694
691
  isDisconnect,
695
692
  isError,
696
693
  finishReason: this.activeResponse?.state.finishReason,
697
- ...(this.activeResponse?.state.usage != null && {
698
- usage: this.activeResponse.state.usage,
699
- }),
700
694
  });
701
695
  } catch (err) {
702
696
  console.error(err);
@@ -2,7 +2,6 @@ import { FlexibleSchema, validateTypes } from '@ai-sdk/provider-utils';
2
2
  import { UIMessageStreamError } from '../error/ui-message-stream-error';
3
3
  import { ProviderMetadata } from '../types';
4
4
  import { FinishReason } from '../types/language-model';
5
- import { LanguageModelUsage } from '../types/usage';
6
5
  import {
7
6
  DataUIMessageChunk,
8
7
  InferUIMessageChunk,
@@ -45,7 +44,6 @@ export type StreamingUIMessageState<UI_MESSAGE extends UIMessage> = {
45
44
  }
46
45
  >;
47
46
  finishReason?: FinishReason;
48
- usage?: LanguageModelUsage;
49
47
  };
50
48
 
51
49
  export function createStreamingUIMessageState<UI_MESSAGE extends UIMessage>({
@@ -688,9 +686,6 @@ export function processUIMessageStream<UI_MESSAGE extends UIMessage>({
688
686
  if (chunk.finishReason != null) {
689
687
  state.finishReason = chunk.finishReason;
690
688
  }
691
- if (chunk.usage != null) {
692
- state.usage = chunk.usage;
693
- }
694
689
  await updateMessageMetadata(chunk.messageMetadata);
695
690
  if (chunk.messageMetadata != null) {
696
691
  write();
@@ -4,7 +4,6 @@ import {
4
4
  providerMetadataSchema,
5
5
  } from '../types/provider-metadata';
6
6
  import { FinishReason } from '../types/language-model';
7
- import { LanguageModelUsage, languageModelUsageSchema } from '../types/usage';
8
7
  import {
9
8
  InferUIMessageData,
10
9
  InferUIMessageMetadata,
@@ -166,7 +165,6 @@ export const uiMessageChunkSchema = lazySchema(() =>
166
165
  'other',
167
166
  ] as const satisfies readonly FinishReason[])
168
167
  .optional(),
169
- usage: languageModelUsageSchema.optional(),
170
168
  messageMetadata: z.unknown().optional(),
171
169
  }),
172
170
  z.strictObject({
@@ -325,7 +323,6 @@ export type UIMessageChunk<
325
323
  | {
326
324
  type: 'finish';
327
325
  finishReason?: FinishReason;
328
- usage?: LanguageModelUsage;
329
326
  messageMetadata?: METADATA;
330
327
  }
331
328
  | {