ai 6.0.238 → 6.0.240
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 +14 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/03-ai-sdk-core/10-generating-structured-data.mdx +24 -9
- package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +3 -3
- package/docs/07-reference/01-ai-sdk-core/23-create-mcp-client.mdx +7 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-output-generated-error.mdx +5 -0
- package/docs/08-migration-guides/26-migration-guide-5-0.mdx +40 -3
- package/package.json +2 -2
- package/src/generate-text/generate-text-result.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.240
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [b28367e]
|
|
8
|
+
- @ai-sdk/gateway@3.0.162
|
|
9
|
+
|
|
10
|
+
## 6.0.239
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [d3d9e0b]
|
|
15
|
+
- @ai-sdk/gateway@3.0.161
|
|
16
|
+
|
|
3
17
|
## 6.0.238
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1170,8 +1170,10 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
|
|
|
1170
1170
|
*/
|
|
1171
1171
|
readonly experimental_output: InferCompleteOutput<OUTPUT>;
|
|
1172
1172
|
/**
|
|
1173
|
-
* The generated
|
|
1173
|
+
* The generated output according to the `output` specification.
|
|
1174
1174
|
*
|
|
1175
|
+
* @throws {NoOutputGeneratedError} When no output is available, for example
|
|
1176
|
+
* when the final step does not finish with a `stop` reason.
|
|
1175
1177
|
*/
|
|
1176
1178
|
readonly output: InferCompleteOutput<OUTPUT>;
|
|
1177
1179
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1170,8 +1170,10 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
|
|
|
1170
1170
|
*/
|
|
1171
1171
|
readonly experimental_output: InferCompleteOutput<OUTPUT>;
|
|
1172
1172
|
/**
|
|
1173
|
-
* The generated
|
|
1173
|
+
* The generated output according to the `output` specification.
|
|
1174
1174
|
*
|
|
1175
|
+
* @throws {NoOutputGeneratedError} When no output is available, for example
|
|
1176
|
+
* when the final step does not finish with a `stop` reason.
|
|
1175
1177
|
*/
|
|
1176
1178
|
readonly output: InferCompleteOutput<OUTPUT>;
|
|
1177
1179
|
}
|
package/dist/index.js
CHANGED
|
@@ -1304,7 +1304,7 @@ function detectMediaType({
|
|
|
1304
1304
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1305
1305
|
|
|
1306
1306
|
// src/version.ts
|
|
1307
|
-
var VERSION = true ? "6.0.
|
|
1307
|
+
var VERSION = true ? "6.0.240" : "0.0.0-test";
|
|
1308
1308
|
|
|
1309
1309
|
// src/util/download/download.ts
|
|
1310
1310
|
var download = async ({
|
package/dist/index.mjs
CHANGED
|
@@ -1193,7 +1193,7 @@ import {
|
|
|
1193
1193
|
} from "@ai-sdk/provider-utils";
|
|
1194
1194
|
|
|
1195
1195
|
// src/version.ts
|
|
1196
|
-
var VERSION = true ? "6.0.
|
|
1196
|
+
var VERSION = true ? "6.0.240" : "0.0.0-test";
|
|
1197
1197
|
|
|
1198
1198
|
// src/util/download/download.ts
|
|
1199
1199
|
var download = async ({
|
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.240" : "0.0.0-test";
|
|
168
168
|
|
|
169
169
|
// src/util/download/download.ts
|
|
170
170
|
var download = async ({
|
package/dist/internal/index.mjs
CHANGED
|
@@ -415,16 +415,22 @@ console.log(result.reasoningText);
|
|
|
415
415
|
|
|
416
416
|
## Error Handling
|
|
417
417
|
|
|
418
|
-
|
|
418
|
+
`generateText` can report structured output failures in two ways:
|
|
419
419
|
|
|
420
|
-
|
|
421
|
-
|
|
420
|
+
- If the model response cannot be parsed or validated against the schema,
|
|
421
|
+
`generateText` rejects with an
|
|
422
|
+
[`AI_NoObjectGeneratedError`](/docs/reference/ai-sdk-errors/ai-no-object-generated-error).
|
|
423
|
+
- If `generateText` returns a result without an output, accessing `result.output`
|
|
424
|
+
throws an
|
|
425
|
+
[`AI_NoOutputGeneratedError`](/docs/reference/ai-sdk-errors/ai-no-output-generated-error).
|
|
426
|
+
This can happen when the final step does not finish with a `stop` reason, for
|
|
427
|
+
example when it finishes with `tool-calls`.
|
|
422
428
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
- The model generated a response that could not be validated against the schema.
|
|
429
|
+
The `output` property is a getter, so destructuring it also triggers this
|
|
430
|
+
access.
|
|
426
431
|
|
|
427
|
-
|
|
432
|
+
`NoObjectGeneratedError` preserves the following information to help you log
|
|
433
|
+
the issue:
|
|
428
434
|
|
|
429
435
|
- `text`: The text that was generated by the model. This can be the raw text or the tool call text, depending on the object generation mode.
|
|
430
436
|
- `response`: Metadata about the language model response, including response id, timestamp, and model.
|
|
@@ -432,14 +438,21 @@ The error preserves the following information to help you log the issue:
|
|
|
432
438
|
- `cause`: The cause of the error (e.g. a JSON parsing error). You can use this for more detailed error handling.
|
|
433
439
|
|
|
434
440
|
```ts
|
|
435
|
-
import {
|
|
441
|
+
import {
|
|
442
|
+
generateText,
|
|
443
|
+
NoObjectGeneratedError,
|
|
444
|
+
NoOutputGeneratedError,
|
|
445
|
+
Output,
|
|
446
|
+
} from 'ai';
|
|
436
447
|
|
|
437
448
|
try {
|
|
438
|
-
await generateText({
|
|
449
|
+
const result = await generateText({
|
|
439
450
|
model,
|
|
440
451
|
output: Output.object({ schema }),
|
|
441
452
|
prompt,
|
|
442
453
|
});
|
|
454
|
+
|
|
455
|
+
console.log(result.output);
|
|
443
456
|
} catch (error) {
|
|
444
457
|
if (NoObjectGeneratedError.isInstance(error)) {
|
|
445
458
|
console.log('NoObjectGeneratedError');
|
|
@@ -447,6 +460,8 @@ try {
|
|
|
447
460
|
console.log('Text:', error.text);
|
|
448
461
|
console.log('Response:', error.response);
|
|
449
462
|
console.log('Usage:', error.usage);
|
|
463
|
+
} else if (NoOutputGeneratedError.isInstance(error)) {
|
|
464
|
+
console.log('NoOutputGeneratedError');
|
|
450
465
|
}
|
|
451
466
|
}
|
|
452
467
|
```
|
|
@@ -2396,9 +2396,9 @@ To see `generateText` in action, check out [these examples](#examples).
|
|
|
2396
2396
|
},
|
|
2397
2397
|
{
|
|
2398
2398
|
name: 'output',
|
|
2399
|
-
type: '
|
|
2400
|
-
|
|
2401
|
-
|
|
2399
|
+
type: 'InferCompleteOutput<OUTPUT>',
|
|
2400
|
+
description:
|
|
2401
|
+
'The generated output according to the `output` specification. Accessing this property throws `NoOutputGeneratedError` when no output is available, for example when the final step does not finish with a `stop` reason.',
|
|
2402
2402
|
},
|
|
2403
2403
|
{
|
|
2404
2404
|
name: 'steps',
|
|
@@ -120,6 +120,13 @@ It currently does not support accepting notifications from an MCP server, and cu
|
|
|
120
120
|
},
|
|
121
121
|
],
|
|
122
122
|
},
|
|
123
|
+
{
|
|
124
|
+
name: 'initializationOptions',
|
|
125
|
+
type: 'RequestOptions',
|
|
126
|
+
isOptional: true,
|
|
127
|
+
description:
|
|
128
|
+
'Optional signal and timeout settings that bound transport startup and the initialize request. A timeout or abort closes the transport and rejects createMCPClient.',
|
|
129
|
+
},
|
|
123
130
|
{
|
|
124
131
|
name: 'clientName',
|
|
125
132
|
type: 'string',
|
|
@@ -7,6 +7,11 @@ description: Learn how to fix AI_NoOutputGeneratedError
|
|
|
7
7
|
|
|
8
8
|
This error is thrown when no LLM output was generated, e.g. because of errors.
|
|
9
9
|
|
|
10
|
+
For `generateText`, accessing `result.output` throws this error when the result
|
|
11
|
+
does not contain an output. This can happen when the final step does not finish
|
|
12
|
+
with a `stop` reason, for example when it finishes with `tool-calls`. The
|
|
13
|
+
`output` property is a getter, so destructuring it also triggers this access.
|
|
14
|
+
|
|
10
15
|
## Properties
|
|
11
16
|
|
|
12
17
|
- `message`: The error message (optional, defaults to `'No output generated.'`)
|
|
@@ -2069,11 +2069,48 @@ import { useAssistant } from '@ai-sdk/react';
|
|
|
2069
2069
|
```
|
|
2070
2070
|
|
|
2071
2071
|
```tsx filename="AI SDK 5.0"
|
|
2072
|
-
|
|
2073
|
-
|
|
2072
|
+
import { useChat } from '@ai-sdk/react';
|
|
2073
|
+
import { DefaultChatTransport } from 'ai';
|
|
2074
|
+
|
|
2075
|
+
function Chat() {
|
|
2076
|
+
const { messages, sendMessage } = useChat({
|
|
2077
|
+
transport: new DefaultChatTransport({
|
|
2078
|
+
api: '/api/chat',
|
|
2079
|
+
}),
|
|
2080
|
+
});
|
|
2081
|
+
|
|
2082
|
+
// ...
|
|
2083
|
+
}
|
|
2074
2084
|
```
|
|
2075
2085
|
|
|
2076
|
-
|
|
2086
|
+
The `useAssistant` hook was specific to the OpenAI Assistants API. OpenAI has
|
|
2087
|
+
deprecated that API in favor of the Responses API. Configure `useChat` for your
|
|
2088
|
+
route as shown above, then return a UI message stream from the route:
|
|
2089
|
+
|
|
2090
|
+
```tsx filename="app/api/chat/route.ts"
|
|
2091
|
+
import { openai } from '@ai-sdk/openai';
|
|
2092
|
+
import { convertToModelMessages, streamText, type UIMessage } from 'ai';
|
|
2093
|
+
|
|
2094
|
+
export async function POST(req: Request) {
|
|
2095
|
+
const { messages }: { messages: UIMessage[] } = await req.json();
|
|
2096
|
+
|
|
2097
|
+
const result = streamText({
|
|
2098
|
+
model: openai.responses('gpt-4o-mini'),
|
|
2099
|
+
prompt: convertToModelMessages(messages),
|
|
2100
|
+
});
|
|
2101
|
+
|
|
2102
|
+
return result.toUIMessageStreamResponse();
|
|
2103
|
+
}
|
|
2104
|
+
```
|
|
2105
|
+
|
|
2106
|
+
For persistent conversation state and built-in tools, see the
|
|
2107
|
+
[OpenAI Responses API guide](/cookbook/guides/openai-responses).
|
|
2108
|
+
|
|
2109
|
+
If you need to connect `useChat` to another backend, see the
|
|
2110
|
+
[transport documentation](/docs/ai-sdk-ui/transport) and
|
|
2111
|
+
[stream protocol](/docs/ai-sdk-ui/stream-protocol). For migrating existing
|
|
2112
|
+
OpenAI Assistants data and API calls, see OpenAI's
|
|
2113
|
+
[Assistants migration guide](https://platform.openai.com/docs/assistants/migration).
|
|
2077
2114
|
|
|
2078
2115
|
#### Attachments → File Parts
|
|
2079
2116
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.240",
|
|
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.162",
|
|
49
49
|
"@ai-sdk/provider": "3.0.14",
|
|
50
50
|
"@ai-sdk/provider-utils": "4.0.41"
|
|
51
51
|
},
|
|
@@ -167,8 +167,10 @@ export interface GenerateTextResult<
|
|
|
167
167
|
readonly experimental_output: InferCompleteOutput<OUTPUT>;
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
|
-
* The generated
|
|
170
|
+
* The generated output according to the `output` specification.
|
|
171
171
|
*
|
|
172
|
+
* @throws {NoOutputGeneratedError} When no output is available, for example
|
|
173
|
+
* when the final step does not finish with a `stop` reason.
|
|
172
174
|
*/
|
|
173
175
|
readonly output: InferCompleteOutput<OUTPUT>;
|
|
174
176
|
}
|