ai 6.0.274 → 6.0.276
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 +19 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -6
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +6 -0
- package/docs/07-reference/01-ai-sdk-core/80-smooth-stream.mdx +1 -1
- package/package.json +2 -2
- package/src/generate-text/smooth-stream.ts +19 -4
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.276" : "0.0.0-test";
|
|
168
168
|
|
|
169
169
|
// src/util/download/download.ts
|
|
170
170
|
var download = async ({
|
package/dist/internal/index.mjs
CHANGED
|
@@ -140,6 +140,7 @@ Here are the capabilities of popular models:
|
|
|
140
140
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5.1` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
141
141
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5-codex` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
142
142
|
| [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5-chat-latest` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
143
|
+
| [Anthropic](/providers/ai-sdk-providers/anthropic) | `claude-fable-5-1` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
143
144
|
| [Anthropic](/providers/ai-sdk-providers/anthropic) | `claude-sonnet-5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
144
145
|
| [Anthropic](/providers/ai-sdk-providers/anthropic) | `claude-fable-5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
145
146
|
| [Anthropic](/providers/ai-sdk-providers/anthropic) | `claude-opus-4-8` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
@@ -150,6 +151,11 @@ Here are the capabilities of popular models:
|
|
|
150
151
|
| [Anthropic](/providers/ai-sdk-providers/anthropic) | `claude-opus-4-1` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
151
152
|
| [Anthropic](/providers/ai-sdk-providers/anthropic) | `claude-opus-4-0` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
152
153
|
| [Anthropic](/providers/ai-sdk-providers/anthropic) | `claude-sonnet-4-0` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
154
|
+
| [Google Generative AI](/providers/ai-sdk-providers/google-generative-ai) | `gemini-3.8-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
155
|
+
| [Google Generative AI](/providers/ai-sdk-providers/google-generative-ai) | `gemini-3.1-pro-preview` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
156
|
+
| [Google Generative AI](/providers/ai-sdk-providers/google-generative-ai) | `gemini-3-pro-preview` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
157
|
+
| [Google Generative AI](/providers/ai-sdk-providers/google-generative-ai) | `gemini-2.5-pro` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
158
|
+
| [Google Generative AI](/providers/ai-sdk-providers/google-generative-ai) | `gemini-2.5-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
153
159
|
| [Mistral](/providers/ai-sdk-providers/mistral) | `pixtral-large-latest` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
154
160
|
| [Mistral](/providers/ai-sdk-providers/mistral) | `mistral-large-latest` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
155
161
|
| [Mistral](/providers/ai-sdk-providers/mistral) | `mistral-medium-latest` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
@@ -38,7 +38,7 @@ const result = streamText({
|
|
|
38
38
|
type: 'number | null',
|
|
39
39
|
isOptional: true,
|
|
40
40
|
description:
|
|
41
|
-
'The delay in milliseconds between outputting each chunk. Defaults to 10ms. Set to `null` to disable delays.',
|
|
41
|
+
'The delay in milliseconds between outputting each chunk. Defaults to 10ms. Set to `null` to disable delays. The delay is skipped while the document is hidden (e.g. browser background tabs), where timer throttling would otherwise stall the stream.',
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
name: 'chunking',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.276",
|
|
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.188",
|
|
49
49
|
"@ai-sdk/provider": "3.0.15",
|
|
50
50
|
"@ai-sdk/provider-utils": "4.0.50"
|
|
51
51
|
},
|
|
@@ -11,6 +11,15 @@ const CHUNKING_REGEXPS = {
|
|
|
11
11
|
line: /\n+/m,
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
// Browsers heavily throttle timers in hidden documents (e.g. background tabs),
|
|
15
|
+
// which would stall the smoothing delay and, through backpressure, the entire
|
|
16
|
+
// stream. Smoothing has no visual purpose there, so the delay is skipped.
|
|
17
|
+
function isDocumentHidden(): boolean {
|
|
18
|
+
return (
|
|
19
|
+
typeof document !== 'undefined' && document.visibilityState === 'hidden'
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
14
23
|
/**
|
|
15
24
|
* Detects the first chunk in a buffer.
|
|
16
25
|
*
|
|
@@ -23,7 +32,7 @@ export type ChunkDetector = (buffer: string) => string | undefined | null;
|
|
|
23
32
|
/**
|
|
24
33
|
* Smooths text and reasoning streaming output.
|
|
25
34
|
*
|
|
26
|
-
* @param delayInMs - The delay in milliseconds between each chunk. Defaults to 10ms. Can be set to `null` to skip the delay.
|
|
35
|
+
* @param delayInMs - The delay in milliseconds between each chunk. Defaults to 10ms. Can be set to `null` to skip the delay. The delay is skipped while the document is hidden (e.g. browser background tabs), where timer throttling would otherwise stall the stream.
|
|
27
36
|
* @param chunking - Controls how the text is chunked for streaming. Use "word" to stream word by word (default), "line" to stream line by line, provide a custom RegExp pattern for custom chunking, provide an Intl.Segmenter for locale-aware word segmentation (recommended for CJK languages), or provide a custom ChunkDetector function.
|
|
28
37
|
*
|
|
29
38
|
* @returns A transform stream that smooths text streaming output.
|
|
@@ -115,7 +124,10 @@ export function smoothStream<TOOLS extends ToolSet>({
|
|
|
115
124
|
function flushBuffer(
|
|
116
125
|
controller: TransformStreamDefaultController<TextStreamPart<TOOLS>>,
|
|
117
126
|
) {
|
|
118
|
-
if (
|
|
127
|
+
if (
|
|
128
|
+
type !== undefined &&
|
|
129
|
+
(buffer.length > 0 || providerMetadata != null)
|
|
130
|
+
) {
|
|
119
131
|
controller.enqueue({
|
|
120
132
|
type,
|
|
121
133
|
text: buffer,
|
|
@@ -137,7 +149,10 @@ export function smoothStream<TOOLS extends ToolSet>({
|
|
|
137
149
|
}
|
|
138
150
|
|
|
139
151
|
// Flush buffer when type or id changes
|
|
140
|
-
if (
|
|
152
|
+
if (
|
|
153
|
+
(chunk.type !== type || chunk.id !== id) &&
|
|
154
|
+
(buffer.length > 0 || providerMetadata != null)
|
|
155
|
+
) {
|
|
141
156
|
flushBuffer(controller);
|
|
142
157
|
}
|
|
143
158
|
|
|
@@ -156,7 +171,7 @@ export function smoothStream<TOOLS extends ToolSet>({
|
|
|
156
171
|
controller.enqueue({ type, text: match, id });
|
|
157
172
|
buffer = buffer.slice(match.length);
|
|
158
173
|
|
|
159
|
-
await delay(delayInMs);
|
|
174
|
+
await delay(isDocumentHidden() ? null : delayInMs);
|
|
160
175
|
}
|
|
161
176
|
},
|
|
162
177
|
});
|