ai 5.1.0-beta.19 → 5.1.0-beta.20
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 +8 -0
- package/README.md +24 -5
- package/dist/index.js +15 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -9
- 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
package/README.md
CHANGED
|
@@ -8,10 +8,10 @@ To learn more about how to use the AI SDK, check out our [API Reference](https:/
|
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
|
-
You will need Node.js 18+ and
|
|
11
|
+
You will need Node.js 18+ and npm (or another package manager) installed on your local development machine.
|
|
12
12
|
|
|
13
13
|
```shell
|
|
14
|
-
npm
|
|
14
|
+
npm install ai
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Unified Provider Architecture
|
|
@@ -19,7 +19,7 @@ npm i ai
|
|
|
19
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).
|
|
20
20
|
|
|
21
21
|
```shell
|
|
22
|
-
npm
|
|
22
|
+
npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Alternatively you can use the [Vercel AI Gateway](https://vercel.com/docs/ai-gateway).
|
|
@@ -47,7 +47,26 @@ const { text } = await generateText({
|
|
|
47
47
|
});
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
###
|
|
50
|
+
### Generating Structured Data
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { generateObject } from 'ai';
|
|
54
|
+
import { z } from 'zod';
|
|
55
|
+
|
|
56
|
+
const { object } = await generateObject({
|
|
57
|
+
model: 'openai/gpt-4.1',
|
|
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
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Agents
|
|
51
70
|
|
|
52
71
|
```ts
|
|
53
72
|
import { Agent } from 'ai';
|
|
@@ -75,7 +94,7 @@ The [AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview) module provides a se
|
|
|
75
94
|
You need to install the package for your framework, e.g.:
|
|
76
95
|
|
|
77
96
|
```shell
|
|
78
|
-
npm
|
|
97
|
+
npm install @ai-sdk/react
|
|
79
98
|
```
|
|
80
99
|
|
|
81
100
|
#### Agent @/agent/image-generation-agent.ts
|
package/dist/index.js
CHANGED
|
@@ -558,16 +558,22 @@ _a15 = symbol15;
|
|
|
558
558
|
|
|
559
559
|
// src/model/resolve-model.ts
|
|
560
560
|
function transformToV3LanguageModel(model) {
|
|
561
|
-
return {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
561
|
+
return new Proxy(model, {
|
|
562
|
+
get(target, prop) {
|
|
563
|
+
if (prop === "specificationVersion")
|
|
564
|
+
return "v3";
|
|
565
|
+
return target[prop];
|
|
566
|
+
}
|
|
567
|
+
});
|
|
565
568
|
}
|
|
566
569
|
function transformToV3EmbeddingModel(model) {
|
|
567
|
-
return {
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
570
|
+
return new Proxy(model, {
|
|
571
|
+
get(target, prop) {
|
|
572
|
+
if (prop === "specificationVersion")
|
|
573
|
+
return "v3";
|
|
574
|
+
return target[prop];
|
|
575
|
+
}
|
|
576
|
+
});
|
|
571
577
|
}
|
|
572
578
|
function resolveLanguageModel(model) {
|
|
573
579
|
if (typeof model !== "string") {
|
|
@@ -802,7 +808,7 @@ function detectMediaType({
|
|
|
802
808
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
803
809
|
|
|
804
810
|
// src/version.ts
|
|
805
|
-
var VERSION = true ? "5.1.0-beta.
|
|
811
|
+
var VERSION = true ? "5.1.0-beta.20" : "0.0.0-test";
|
|
806
812
|
|
|
807
813
|
// src/util/download/download.ts
|
|
808
814
|
var download = async ({ url }) => {
|