Open BrianHung opened 2 hours ago
Workaround would be to manually do it
import { zodToJsonSchema } from 'zod-to-json-schema';
import { jsonSchema, tool } from 'ai';
import { JSONSchema7 } from 'json-schema';
tool({
description: value.description,
parameters: jsonSchema(
zodToJsonSchema(
value.parameters().items[0],
{ $refStrategy: 'none' }
) as JSONSchema7
),
})
Description
I have a schema where I'm re-using zod objects. By default, the ref strategy used by zod to json schema is to re-use schemas that have been seen before.
https://github.com/StefanTerdell/zod-to-json-schema https://json-schema.org/understanding-json-schema/structuring#dollarref
OpenAI is able to accept this json schema, but Google AI is not and errors with
One possible fix is to set
$refsStrategy: 'none'
to disable json schema re-use (re-using zod objects works but duplicated in json schema).Code example
No response
Additional context
No response