You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that when the output mode is array, then none of the .transform() methods on the schema will be called.
Code example
Here's a relevant example I expect many people to run into (working with dates):
const openAIModel = openai("gpt-4o-mini");
const { object } = await generateObject({
model: openAIModel,
output: "array",
schema: z.object( { date: z.string().transform((x)=>new Date(x)) } ),
prompt: "Get the date from the text",
});
While Typescript thinks that object.date is of type Date, in reality it is always of type string. The transformation doesn't happen.
AI provider
10.2.4
Additional context
I tried applying any other transformation, like adding a completely new property but those transformations also don't happen. I believe the entire transform() method is just ignored.
The text was updated successfully, but these errors were encountered:
Description
I noticed that when the output mode is
array
, then none of the.transform()
methods on the schema will be called.Code example
Here's a relevant example I expect many people to run into (working with dates):
While Typescript thinks that
object.date
is of typeDate
, in reality it is always of typestring
. The transformation doesn't happen.AI provider
10.2.4
Additional context
I tried applying any other transformation, like adding a completely new property but those transformations also don't happen. I believe the entire
transform()
method is just ignored.The text was updated successfully, but these errors were encountered: