ai 6.0.40 → 6.0.42
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 +13 -0
- package/dist/index.d.mts +0 -4
- package/dist/index.d.ts +0 -4
- package/dist/index.js +322 -349
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +322 -349
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -20
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +1 -20
- package/dist/internal/index.mjs.map +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +1 -0
- package/docs/02-foundations/04-tools.mdx +89 -0
- package/docs/02-getting-started/02-nextjs-app-router.mdx +3 -3
- package/docs/02-getting-started/03-nextjs-pages-router.mdx +2 -2
- package/docs/02-getting-started/04-svelte.mdx +2 -2
- package/docs/02-getting-started/05-nuxt.mdx +2 -2
- package/docs/02-getting-started/06-nodejs.mdx +2 -2
- package/docs/02-getting-started/07-expo.mdx +1 -1
- package/docs/02-getting-started/08-tanstack-start.mdx +2 -2
- package/docs/05-ai-sdk-rsc/03-generative-ui-state.mdx +1 -1
- package/docs/05-ai-sdk-rsc/05-streaming-values.mdx +1 -1
- package/docs/06-advanced/02-stopping-streams.mdx +2 -2
- package/docs/07-reference/02-ai-sdk-ui/01-use-chat.mdx +0 -7
- package/docs/07-reference/02-ai-sdk-ui/02-use-completion.mdx +1 -1
- package/docs/08-migration-guides/26-migration-guide-5-0.mdx +2 -2
- package/docs/09-troubleshooting/15-abort-breaks-resumable-streams.mdx +1 -1
- package/package.json +2 -2
- package/src/agent/create-agent-ui-stream-response.test.ts +1 -1
- package/src/generate-text/__snapshots__/stream-text.test.ts.snap +4 -52
- package/src/generate-text/stream-text.test.ts +7 -407
- package/src/generate-text/stream-text.ts +0 -1
- package/src/types/usage.ts +0 -24
- package/src/ui/chat.ts +0 -6
- package/src/ui/process-ui-message-stream.ts +0 -5
- package/src/ui-message-stream/ui-message-chunks.ts +0 -3
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
|
| {
|