Skip to content

[Dotprompt] Schema registry #417

@mbleigh

Description

@mbleigh

This feature would actually be usable throughout Genkit but would be most useful for Dotprompt. If Genkit supported a schema registry, it would be much easier to share schema definitions between text prompt files and code.

export const MySchema = defineSchema("MySchema", z.object({
  field1: z.string(),
  field2: z.string().optional(),
}));

Once a schema has been registered, it can be used inside a Dotprompt file:

---
model: vertexai/gemini-1.5-flash-preview
input:
  schema:
    name: string
output:
  schema: MySchema
---

Hello, {{name}}! This prompt outputs MySchema.

Then when using the prompt, we can pass the schema to a generic argument:

import { MySchema } from "./schemas";

const myPrompt = prompt<{name: string}, typeof MySchema>("myPrompt");

This would be a big win for prompts that end up with complex output schemas that then have to essentially be defined twice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions