ai 6.0.253 → 6.0.255
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 +16 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/03-ai-sdk-core/38-video-generation.mdx +1 -0
- package/package.json +2 -2
- package/src/generate-text/index.ts +1 -0
- package/src/ui/chat.ts +6 -4
- package/src/ui/process-ui-message-stream.ts +6 -2
- package/src/ui-message-stream/handle-ui-message-stream-finish.ts +2 -1
- package/src/ui-message-stream/read-ui-message-stream.ts +32 -2
package/dist/internal/index.js
CHANGED
|
@@ -164,7 +164,7 @@ function detectMediaType({
|
|
|
164
164
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
165
165
|
|
|
166
166
|
// src/version.ts
|
|
167
|
-
var VERSION = true ? "6.0.
|
|
167
|
+
var VERSION = true ? "6.0.255" : "0.0.0-test";
|
|
168
168
|
|
|
169
169
|
// src/util/download/download.ts
|
|
170
170
|
var download = async ({
|
package/dist/internal/index.mjs
CHANGED
|
@@ -452,5 +452,6 @@ try {
|
|
|
452
452
|
| [Kling AI](/providers/ai-sdk-providers/klingai#video-models) | `kling-v2.6-motion-control` | Motion control |
|
|
453
453
|
| [Replicate](/providers/ai-sdk-providers/replicate#video-models) | `minimax/video-01` | Text-to-video |
|
|
454
454
|
| [xAI](/providers/ai-sdk-providers/xai#video-models) | `grok-imagine-video` | Text-to-video, image-to-video, editing, extension, R2V |
|
|
455
|
+
| [xAI](/providers/ai-sdk-providers/xai#video-models) | `grok-imagine-video-1.5` | Text-to-video, image-to-video, editing, extension, R2V |
|
|
455
456
|
|
|
456
457
|
Above are a small subset of the video models supported by the AI SDK providers. For more, see the respective provider documentation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.255",
|
|
4
4
|
"description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@opentelemetry/api": "^1.9.0",
|
|
48
|
-
"@ai-sdk/gateway": "3.0.
|
|
48
|
+
"@ai-sdk/gateway": "3.0.173",
|
|
49
49
|
"@ai-sdk/provider": "3.0.15",
|
|
50
50
|
"@ai-sdk/provider-utils": "4.0.45"
|
|
51
51
|
},
|
|
@@ -15,6 +15,7 @@ export {
|
|
|
15
15
|
type GeneratedFile,
|
|
16
16
|
} from './generated-file';
|
|
17
17
|
export * as Output from './output';
|
|
18
|
+
export type { Output as OutputInterface } from './output';
|
|
18
19
|
export type {
|
|
19
20
|
InferCompleteOutput as InferGenerateOutput,
|
|
20
21
|
InferPartialOutput as InferStreamOutput,
|
package/src/ui/chat.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
createStreamingUIMessageState,
|
|
16
16
|
processUIMessageStream,
|
|
17
17
|
type StreamingUIMessageState,
|
|
18
|
+
type UIMessageStreamWriteOptions,
|
|
18
19
|
} from './process-ui-message-stream';
|
|
19
20
|
import {
|
|
20
21
|
isToolUIPart,
|
|
@@ -742,7 +743,7 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
742
743
|
const runUpdateMessageJob = (
|
|
743
744
|
job: (options: {
|
|
744
745
|
state: StreamingUIMessageState<UI_MESSAGE>;
|
|
745
|
-
write: () => void;
|
|
746
|
+
write: (options?: UIMessageStreamWriteOptions) => void;
|
|
746
747
|
}) => Promise<void>,
|
|
747
748
|
) =>
|
|
748
749
|
// serialize the job execution to avoid race conditions:
|
|
@@ -753,13 +754,14 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
753
754
|
|
|
754
755
|
return job({
|
|
755
756
|
state: response.state,
|
|
756
|
-
write: () => {
|
|
757
|
+
write: ({ updateStatus = true } = {}) => {
|
|
757
758
|
if (response.abortController.signal.aborted) {
|
|
758
759
|
return;
|
|
759
760
|
}
|
|
760
761
|
|
|
761
|
-
|
|
762
|
-
|
|
762
|
+
if (updateStatus) {
|
|
763
|
+
this.setStatus({ status: 'streaming' });
|
|
764
|
+
}
|
|
763
765
|
|
|
764
766
|
const replaceLastMessage =
|
|
765
767
|
response.state.message.id === this.lastMessage?.id;
|
|
@@ -49,6 +49,10 @@ export type StreamingUIMessageState<UI_MESSAGE extends UIMessage> = {
|
|
|
49
49
|
finishReason?: FinishReason;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
export type UIMessageStreamWriteOptions = {
|
|
53
|
+
updateStatus?: boolean;
|
|
54
|
+
};
|
|
55
|
+
|
|
52
56
|
export function createStreamingUIMessageState<UI_MESSAGE extends UIMessage>({
|
|
53
57
|
lastMessage,
|
|
54
58
|
messageId,
|
|
@@ -95,7 +99,7 @@ export function processUIMessageStream<UI_MESSAGE extends UIMessage>({
|
|
|
95
99
|
runUpdateMessageJob: (
|
|
96
100
|
job: (options: {
|
|
97
101
|
state: StreamingUIMessageState<UI_MESSAGE>;
|
|
98
|
-
write: () => void;
|
|
102
|
+
write: (options?: UIMessageStreamWriteOptions) => void;
|
|
99
103
|
}) => Promise<void>,
|
|
100
104
|
) => Promise<void>;
|
|
101
105
|
onError: ErrorHandler;
|
|
@@ -831,7 +835,7 @@ export function processUIMessageStream<UI_MESSAGE extends UIMessage>({
|
|
|
831
835
|
await updateMessageMetadata(chunk.messageMetadata);
|
|
832
836
|
|
|
833
837
|
if (chunk.messageId != null || chunk.messageMetadata != null) {
|
|
834
|
-
write();
|
|
838
|
+
write({ updateStatus: false });
|
|
835
839
|
}
|
|
836
840
|
break;
|
|
837
841
|
}
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
createStreamingUIMessageState,
|
|
3
3
|
processUIMessageStream,
|
|
4
4
|
type StreamingUIMessageState,
|
|
5
|
+
type UIMessageStreamWriteOptions,
|
|
5
6
|
} from '../ui/process-ui-message-stream';
|
|
6
7
|
import type { UIMessage } from '../ui/ui-messages';
|
|
7
8
|
import type { ErrorHandler } from '../util/error-handler';
|
|
@@ -91,7 +92,7 @@ export function handleUIMessageStreamFinish<UI_MESSAGE extends UIMessage>({
|
|
|
91
92
|
const runUpdateMessageJob = async (
|
|
92
93
|
job: (options: {
|
|
93
94
|
state: StreamingUIMessageState<UI_MESSAGE>;
|
|
94
|
-
write: () => void;
|
|
95
|
+
write: (options?: UIMessageStreamWriteOptions) => void;
|
|
95
96
|
}) => Promise<void>,
|
|
96
97
|
) => {
|
|
97
98
|
await job({ state, write: () => {} });
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
createStreamingUIMessageState,
|
|
5
5
|
processUIMessageStream,
|
|
6
6
|
type StreamingUIMessageState,
|
|
7
|
+
type UIMessageStreamWriteOptions,
|
|
7
8
|
} from '../ui/process-ui-message-stream';
|
|
8
9
|
import {
|
|
9
10
|
createAsyncIterableStream,
|
|
@@ -11,6 +12,35 @@ import {
|
|
|
11
12
|
} from '../util/async-iterable-stream';
|
|
12
13
|
import { consumeStream } from '../util/consume-stream';
|
|
13
14
|
|
|
15
|
+
function createUIMessageSnapshot<UI_MESSAGE extends UIMessage>(
|
|
16
|
+
message: UI_MESSAGE,
|
|
17
|
+
): UI_MESSAGE {
|
|
18
|
+
const textByPartIndex = new Map<number, string>();
|
|
19
|
+
const messageWithoutText = {
|
|
20
|
+
...message,
|
|
21
|
+
parts: message.parts.map((part, index) => {
|
|
22
|
+
if (part.type === 'text' || part.type === 'reasoning') {
|
|
23
|
+
textByPartIndex.set(index, part.text);
|
|
24
|
+
return { ...part, text: '' };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return part;
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const snapshot = structuredClone(messageWithoutText) as UI_MESSAGE;
|
|
32
|
+
|
|
33
|
+
for (const [index, text] of textByPartIndex) {
|
|
34
|
+
const part = snapshot.parts[index];
|
|
35
|
+
|
|
36
|
+
if (part.type === 'text' || part.type === 'reasoning') {
|
|
37
|
+
part.text = text;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return snapshot;
|
|
42
|
+
}
|
|
43
|
+
|
|
14
44
|
/**
|
|
15
45
|
* Transforms a stream of `UIMessageChunk`s into an `AsyncIterableStream` of `UIMessage`s.
|
|
16
46
|
*
|
|
@@ -62,13 +92,13 @@ export function readUIMessageStream<UI_MESSAGE extends UIMessage>({
|
|
|
62
92
|
runUpdateMessageJob(
|
|
63
93
|
job: (options: {
|
|
64
94
|
state: StreamingUIMessageState<UI_MESSAGE>;
|
|
65
|
-
write: () => void;
|
|
95
|
+
write: (options?: UIMessageStreamWriteOptions) => void;
|
|
66
96
|
}) => Promise<void>,
|
|
67
97
|
) {
|
|
68
98
|
return job({
|
|
69
99
|
state,
|
|
70
100
|
write: () => {
|
|
71
|
-
controller?.enqueue(
|
|
101
|
+
controller?.enqueue(createUIMessageSnapshot(state.message));
|
|
72
102
|
},
|
|
73
103
|
});
|
|
74
104
|
},
|