ai 5.0.88 → 5.0.90
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 +12 -0
- package/README.md +42 -17
- package/dist/index.d.mts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 5.0.90
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 818b144: fix not catching of empty arrays in validateUIMessage
|
|
8
|
+
|
|
9
|
+
## 5.0.89
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 7cfada6: feat(ai): `chat.addToolResult()` is now `chat.addToolOutput()`
|
|
14
|
+
|
|
3
15
|
## 5.0.88
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# AI SDK
|
|
4
4
|
|
|
5
|
-
The [AI SDK](https://ai-sdk.dev/docs) is a TypeScript toolkit designed to help you build AI-powered applications using popular frameworks like Next.js, React, Svelte, Vue and runtimes like Node.js.
|
|
5
|
+
The [AI SDK](https://ai-sdk.dev/docs) is a TypeScript toolkit designed to help you build AI-powered applications and agents using popular frameworks like Next.js, React, Svelte, Vue and runtimes like Node.js.
|
|
6
6
|
|
|
7
7
|
To learn more about how to use the AI SDK, check out our [API Reference](https://ai-sdk.dev/docs/reference) and [Documentation](https://ai-sdk.dev/docs).
|
|
8
8
|
|
|
@@ -14,38 +14,63 @@ You will need Node.js 18+ and npm (or another package manager) installed on your
|
|
|
14
14
|
npm install ai
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
### AI SDK Core
|
|
20
|
-
|
|
21
|
-
The [AI SDK Core](https://ai-sdk.dev/docs/ai-sdk-core/overview) module provides a unified API to interact with model providers like [OpenAI](https://ai-sdk.dev/providers/ai-sdk-providers/openai), [Anthropic](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic), [Google](https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai), and more.
|
|
17
|
+
## Unified Provider Architecture
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
The AI SDK provides a [unified API](https://ai-sdk.dev/docs/foundations/providers-and-models) to interact with model providers like [OpenAI](https://ai-sdk.dev/providers/ai-sdk-providers/openai), [Anthropic](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic), [Google](https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai), and [more](https://ai-sdk.dev/providers/ai-sdk-providers).
|
|
24
20
|
|
|
25
21
|
```shell
|
|
26
|
-
npm install @ai-sdk/openai
|
|
22
|
+
npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google
|
|
27
23
|
```
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
Alternatively you can use the [Vercel AI Gateway](https://vercel.com/docs/ai-gateway).
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Generating Text
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { generateText } from 'ai';
|
|
33
|
+
|
|
34
|
+
const { text } = await generateText({
|
|
35
|
+
model: 'openai/gpt-5', // use Vercel AI Gateway
|
|
36
|
+
prompt: 'What is an agent?',
|
|
37
|
+
});
|
|
38
|
+
```
|
|
30
39
|
|
|
31
40
|
```ts
|
|
32
41
|
import { generateText } from 'ai';
|
|
33
|
-
import { openai } from '@ai-sdk/openai';
|
|
42
|
+
import { openai } from '@ai-sdk/openai';
|
|
34
43
|
|
|
35
44
|
const { text } = await generateText({
|
|
36
|
-
model: openai('gpt-
|
|
37
|
-
|
|
38
|
-
prompt: 'Why is the sky blue?',
|
|
45
|
+
model: openai('gpt-5'), // use OpenAI Responses API directly
|
|
46
|
+
prompt: 'What is an agent?',
|
|
39
47
|
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Generating Structured Data
|
|
40
51
|
|
|
41
|
-
|
|
52
|
+
```ts
|
|
53
|
+
import { generateObject } from 'ai';
|
|
54
|
+
import { z } from 'zod';
|
|
55
|
+
|
|
56
|
+
const { object } = await generateObject({
|
|
57
|
+
model: 'openai/gpt-5',
|
|
58
|
+
schema: z.object({
|
|
59
|
+
recipe: z.object({
|
|
60
|
+
name: z.string(),
|
|
61
|
+
ingredients: z.array(z.object({ name: z.string(), amount: z.string() })),
|
|
62
|
+
steps: z.array(z.string()),
|
|
63
|
+
}),
|
|
64
|
+
}),
|
|
65
|
+
prompt: 'Generate a lasagna recipe.',
|
|
66
|
+
});
|
|
42
67
|
```
|
|
43
68
|
|
|
44
|
-
###
|
|
69
|
+
### UI Integration
|
|
45
70
|
|
|
46
71
|
The [AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview) module provides a set of hooks that help you build chatbots and generative user interfaces. These hooks are framework agnostic, so they can be used in Next.js, React, Svelte, and Vue.
|
|
47
72
|
|
|
48
|
-
You need to install the package for your framework
|
|
73
|
+
You need to install the package for your framework, e.g.:
|
|
49
74
|
|
|
50
75
|
```shell
|
|
51
76
|
npm install @ai-sdk/react
|
|
@@ -122,7 +147,7 @@ We've built [templates](https://vercel.com/templates?type=ai) that include AI SD
|
|
|
122
147
|
|
|
123
148
|
## Community
|
|
124
149
|
|
|
125
|
-
The AI SDK community can be found on [
|
|
150
|
+
The AI SDK community can be found on [the Vercel Community](https://community.vercel.com/c/ai-sdk/62) where you can ask questions, voice ideas, and share your projects with other people.
|
|
126
151
|
|
|
127
152
|
## Contributing
|
|
128
153
|
|
package/dist/index.d.mts
CHANGED
|
@@ -4195,6 +4195,20 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
4195
4195
|
* Clear the error state and set the status to ready if the chat is in an error state.
|
|
4196
4196
|
*/
|
|
4197
4197
|
clearError: () => void;
|
|
4198
|
+
addToolOutput: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ state, tool, toolCallId, output, errorText, }: {
|
|
4199
|
+
state?: "output-available";
|
|
4200
|
+
tool: TOOL;
|
|
4201
|
+
toolCallId: string;
|
|
4202
|
+
output: InferUIMessageTools<UI_MESSAGE>[TOOL]["output"];
|
|
4203
|
+
errorText?: never;
|
|
4204
|
+
} | {
|
|
4205
|
+
state: "output-error";
|
|
4206
|
+
tool: TOOL;
|
|
4207
|
+
toolCallId: string;
|
|
4208
|
+
output?: never;
|
|
4209
|
+
errorText: string;
|
|
4210
|
+
}) => Promise<void>;
|
|
4211
|
+
/** @deprecated Use addToolOutput */
|
|
4198
4212
|
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ state, tool, toolCallId, output, errorText, }: {
|
|
4199
4213
|
state?: "output-available";
|
|
4200
4214
|
tool: TOOL;
|
package/dist/index.d.ts
CHANGED
|
@@ -4195,6 +4195,20 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
4195
4195
|
* Clear the error state and set the status to ready if the chat is in an error state.
|
|
4196
4196
|
*/
|
|
4197
4197
|
clearError: () => void;
|
|
4198
|
+
addToolOutput: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ state, tool, toolCallId, output, errorText, }: {
|
|
4199
|
+
state?: "output-available";
|
|
4200
|
+
tool: TOOL;
|
|
4201
|
+
toolCallId: string;
|
|
4202
|
+
output: InferUIMessageTools<UI_MESSAGE>[TOOL]["output"];
|
|
4203
|
+
errorText?: never;
|
|
4204
|
+
} | {
|
|
4205
|
+
state: "output-error";
|
|
4206
|
+
tool: TOOL;
|
|
4207
|
+
toolCallId: string;
|
|
4208
|
+
output?: never;
|
|
4209
|
+
errorText: string;
|
|
4210
|
+
}) => Promise<void>;
|
|
4211
|
+
/** @deprecated Use addToolOutput */
|
|
4198
4212
|
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ state, tool, toolCallId, output, errorText, }: {
|
|
4199
4213
|
state?: "output-available";
|
|
4200
4214
|
tool: TOOL;
|
package/dist/index.js
CHANGED
|
@@ -764,7 +764,7 @@ function detectMediaType({
|
|
|
764
764
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
765
765
|
|
|
766
766
|
// src/version.ts
|
|
767
|
-
var VERSION = true ? "5.0.
|
|
767
|
+
var VERSION = true ? "5.0.90" : "0.0.0-test";
|
|
768
768
|
|
|
769
769
|
// src/util/download/download.ts
|
|
770
770
|
var download = async ({ url }) => {
|
|
@@ -9267,7 +9267,7 @@ var AbstractChat = class {
|
|
|
9267
9267
|
this.setStatus({ status: "ready" });
|
|
9268
9268
|
}
|
|
9269
9269
|
};
|
|
9270
|
-
this.
|
|
9270
|
+
this.addToolOutput = async ({
|
|
9271
9271
|
state = "output-available",
|
|
9272
9272
|
tool: tool2,
|
|
9273
9273
|
toolCallId,
|
|
@@ -9300,6 +9300,8 @@ var AbstractChat = class {
|
|
|
9300
9300
|
});
|
|
9301
9301
|
}
|
|
9302
9302
|
});
|
|
9303
|
+
/** @deprecated Use addToolOutput */
|
|
9304
|
+
this.addToolResult = this.addToolOutput;
|
|
9303
9305
|
/**
|
|
9304
9306
|
* Abort the current request immediately, keep the generated tokens if any.
|
|
9305
9307
|
*/
|
|
@@ -9735,9 +9737,9 @@ var uiMessagesSchema = (0, import_provider_utils32.lazyValidator)(
|
|
|
9735
9737
|
})
|
|
9736
9738
|
})
|
|
9737
9739
|
])
|
|
9738
|
-
)
|
|
9740
|
+
).nonempty("Message must contain at least one part")
|
|
9739
9741
|
})
|
|
9740
|
-
)
|
|
9742
|
+
).nonempty("Messages array must not be empty")
|
|
9741
9743
|
)
|
|
9742
9744
|
);
|
|
9743
9745
|
async function safeValidateUIMessages({
|