[JS] dotprompt doesn't propagate input/output schemas in typescript
Describe the bug
Schemas in dotprompt managed prompts don't propagate through to typescript. Input and output types are 'unknown'.
To Reproduce
- Definte a dotprompt file with input & output schemas. Any of the examples from https://firebase.google.com/docs/genkit/dotprompt#defining_inputoutput_schemas_with_picoschema
- Initialize the prompt and write code to call
generate - Note that input type in typescript is 'unknown'. The type for the
data()orobject()on the response is also 'unknown'
Expected behavior Input/output types are correctly typed.
At a minimum, update documentation to indicate that dotprompt prompts don't expose it.
Thanks for the report! This is a known limitation as there's no way for us to dynamically infer a strong type from a text template, but you're right that we should probably document it.
I've filed #417 as one way to help with this problem but you're right that we should at least document it.
Figured as much. Like the idea of being able to reference schema defined in code, that would help with the duplication.
Alternate would be a preprocessor/generator to export the types from dotprompt files.
Yep a build step is something I've thought about (even played with a bit at one point).
@mbleigh still relevant?
I'm going to say that this is mitigated by defineSchema.
const MySchema = ai.defineSchema('MySchema', z.object({...});
---
input:
schema: MySchema
---
it'd be nice to have something even more magical, but this is workable for now.