@ai-sdk/valibot 2.0.0-beta.51 → 2.0.0-beta.52
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 +36 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
# AI SDK - Valibot Schema Support
|
|
2
2
|
|
|
3
|
+
Allows you to use [Valibot](https://valibot.dev/) schemas with AI SDK.
|
|
4
|
+
|
|
5
|
+
The `valibotSchema` function supports both validation and JSON schema conversion
|
|
6
|
+
for Valibot schemas.
|
|
7
|
+
|
|
3
8
|
## Setup
|
|
4
9
|
|
|
5
10
|
```bash
|
|
6
|
-
npm
|
|
11
|
+
npm install @ai-sdk/valibot
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Example
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { anthropic } from '@ai-sdk/anthropic';
|
|
18
|
+
import { valibotSchema } from '@ai-sdk/valibot';
|
|
19
|
+
import { generateText, Output } from 'ai';
|
|
20
|
+
import * as v from 'valibot';
|
|
21
|
+
|
|
22
|
+
const result = await generateText({
|
|
23
|
+
model: anthropic('claude-3-7-sonnet-latest'),
|
|
24
|
+
output: Output.object({
|
|
25
|
+
schema: valibotSchema(
|
|
26
|
+
v.object({
|
|
27
|
+
recipe: v.object({
|
|
28
|
+
name: v.string(),
|
|
29
|
+
ingredients: v.array(
|
|
30
|
+
v.object({
|
|
31
|
+
name: v.string(),
|
|
32
|
+
amount: v.string(),
|
|
33
|
+
}),
|
|
34
|
+
),
|
|
35
|
+
steps: v.array(v.string()),
|
|
36
|
+
}),
|
|
37
|
+
}),
|
|
38
|
+
),
|
|
39
|
+
}),
|
|
40
|
+
prompt: 'Generate a lasagna recipe.',
|
|
41
|
+
});
|
|
7
42
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/valibot",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.52",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@ai-sdk/provider-utils": "4.0.0-beta.
|
|
23
|
+
"@ai-sdk/provider-utils": "4.0.0-beta.52"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "20.17.24",
|