Open History to see the last commit
1import { z } from 'zod'
2
3export const guitarRecommendationSchema = z.object({
4 name: z.string(),
5 price: z.number(),
6 reason: z.string(),
7 rating: z.number().min(1).max(5),
8 // Optional field used to exercise strict-mode null-widening end to end:
9 // the schema converter widens this to `required` + nullable, so a provider
10 // returns `null` for an absent value. The engine must undo that widening so
11 // the field reads back as ABSENT (matching `.optional()`), not `null`. See
12 // `structured-output-stream.spec.ts`.
13 condition: z.string().optional(),
14})
15
16export const imageAnalysisSchema = z.object({
17 description: z.string(),
18 objects: z.array(z.string()),
19 mood: z.string(),
20})
21
22/**
23 * Recipe schema for the `multi-turn-structured` e2e feature. Mirrors the
24 * example app's RecipeSchema in
25 * `examples/ts-react-chat/src/routes/api.structured-chat.ts` so the harness
26 * exercises the same shape end users see in the demo.
27 *
28 * Constraints (`min`, `int`, `default`) are intentionally avoided — OpenAI
29 * strict structured outputs reject `integer`, `minimum`/`maximum`,
30 * `minLength`/`maxLength`, `minItems`/`maxItems`, and `default`.
31 */
32export const recipeSchema = z.object({
33 title: z.string(),
34 cuisine: z.string(),
35 servings: z.number(),
36 estimatedCostUsd: z.number(),
37 ingredients: z.array(
38 z.object({
39 item: z.string(),
40 amount: z.string(),
41 }),
42 ),
43 steps: z.array(z.string()),
44 tips: z.array(z.string()),
45})
46
47export type Recipe = z.infer<typeof recipeSchema>