-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: define tool parameters with JSON schema instead of Zod #1624
Comments
Hi - sorry you're running into issues! This error is because the SDK uses Zod for the parameters schema. Try this: import { openai } from '@ai-sdk/openai';
import { streamText } from 'ai';
import { z } from "zod";
const response = await streamText({
model: openai('gpt-4o'),
prompt: 'This is a prompt',
tools: {
my_tool: {
description: 'A tool that does something',
parameters: z.object({
param1: z.string().describe('A parameter that does something')
}),
}
}
}
}); |
Is there anyway to do this without zod? Or would this project be open to supporting JSON Schemas? I'm mainly interested in this because my tool schemas are JSON Schemas and stored as JSON strings, which I've been using with the |
If helpful, there are some npm libraries like |
Duplicates #1062 |
implemented in #2386 |
Description
I'm trying to use
streamText
with a plaintools
object where theparameters
on each tool valid JSON schema. This works fine when I use the openai sdk (with atools
array), but I get the following error before the request is even made:TypeError: Cannot read properties of undefined (reading 'typeName')
Code example
Additional context
No response
The text was updated successfully, but these errors were encountered: