Hi,
I’m currently experimenting with structured outputs using NodeJS SDK. Is there any way to assign a null value or to catch whenever information is not available? (One of the information not the whole thing)
For example, I have this Zod schema:
const InstructionFormat = z.object({
time: z.string(),
task: z.string(),
assignee: z.string(),
});
Let’s say the time is not available, I want something like
{ time: null, task: ‘finish math homework’, assignee: ‘Alice’ }
Adding .optional () didn’t work. My current workaround is by adjusting the prompt:
{ role: "system", content: "Extract the todo information from the prompt. Assign '-' if something not specified" },
So I can get something like this
{ time: '-', task: 'finish math homework', assignee: 'Alice' }
I guess it’s more reliable to have a null value than a certain string.