Skip to content

Commit d7cb6b4

Browse files
dancerlgrammel
andauthored
chore (valibot): update to valibot 1.1 (#6712)
## background valibot is now stable with version 1.1 ## summary upgrade to valibot 1.1 ## verification test type inference and run example ## future work right now the conversion for valibot is not openai-compatible. waiting for valibot updates to solve this. --------- Co-authored-by: Lars Grammel <lars.grammel@gmail.com>
1 parent 0261b70 commit d7cb6b4

File tree

5 files changed

+36
-18
lines changed

5 files changed

+36
-18
lines changed

‎.changeset/shiny-parents-know.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ai-sdk/valibot': patch
3+
---
4+
5+
chore (valibot): update to valibot 1.1

‎examples/ai-core/src/generate-object/openai-valibot.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { openai } from '@ai-sdk/openai';
1+
import { anthropic } from '@ai-sdk/anthropic';
22
import { valibotSchema } from '@ai-sdk/valibot';
33
import { generateObject } from 'ai';
44
import 'dotenv/config';
55
import * as v from 'valibot';
66

77
async function main() {
88
const result = await generateObject({
9-
model: openai('gpt-4o-mini'),
9+
model: anthropic('claude-3-5-sonnet-20240620'),
1010
schema: valibotSchema(
1111
v.object({
1212
recipe: v.object({

‎packages/valibot/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131
},
3232
"devDependencies": {
3333
"@types/node": "20.17.24",
34+
"@valibot/to-json-schema": "^1.3.0",
3435
"@vercel/ai-tsconfig": "workspace:*",
3536
"tsup": "^8",
3637
"typescript": "5.8.3",
37-
"valibot": "^1.0.0-rc.0 || ^1.0.0"
38+
"valibot": "^1.1.0"
3839
},
3940
"peerDependencies": {
40-
"@valibot/to-json-schema": "^1.0.0-rc.0 || ^1.0.0",
41-
"valibot": "^1.0.0-rc.0 || ^1.0.0"
41+
"@valibot/to-json-schema": "^1.3.0",
42+
"valibot": "^1.1.0"
4243
},
4344
"engines": {
4445
"node": ">=18"

‎packages/valibot/src/valibot-schema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { toJsonSchema as valibotToJsonSchema } from '@valibot/to-json-schema';
22
import { jsonSchema, Schema } from '@ai-sdk/provider-utils';
33
import * as v from 'valibot';
44

5-
export function valibotSchema<OBJECT>(
6-
valibotSchema: v.GenericSchema<unknown, OBJECT>,
7-
): Schema<OBJECT> {
5+
export function valibotSchema<
6+
SCHEMA extends v.GenericSchema<unknown, unknown, v.BaseIssue<unknown>>,
7+
>(valibotSchema: SCHEMA): Schema<v.InferOutput<SCHEMA>> {
88
return jsonSchema(valibotToJsonSchema(valibotSchema), {
99
validate: value => {
1010
const result = v.safeParse(valibotSchema, value);

‎pnpm-lock.yaml

Lines changed: 22 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)