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
Sometimes, I want the AI to return null if it cannot return a reliable response. Therefore, I would like to be able to return a null.
Example:
import{generateObject}from'ai';import{z}from'zod';const{ object }=awaitgenerateObject({model: yourModel,schema: z.object({recipe: z.object({name: z.string(),ingredients: z.array(z.object({name: z.string(),amount: z.string()})),steps: z.array(z.string()),}).nullable(),}),prompt: `Generate a lasagna recipe with these ingredients. If there is an egg in the ingredients, return null.Ingredients:- tomato- cheese- eggs`,});
Use Cases
I want to get an object only if the information is reliable.
Additional context
No response
The text was updated successfully, but these errors were encountered:
Feature Description
Sometimes, I want the AI to return null if it cannot return a reliable response. Therefore, I would like to be able to return a null.
Example:
Use Cases
I want to get an object only if the information is reliable.
Additional context
No response
The text was updated successfully, but these errors were encountered: