firebase / genkit

An open source framework for building AI-powered apps with familiar code-centric patterns. Genkit makes it easy to integrate, test, and deploy sophisticated AI features to Firebase or Google Cloud.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Dotprompt] Add support for partials

mbleigh opened this issue · comments

Handlebars partials make composition easy, and we should support it in Dotprompt. Proposed implementation:

  1. Partials are stored in the prompt directory and prefixed with a _.
  2. Partials do not have YAML frontmatter.
  3. Partials are available to all prompts by name (omitting the _).
  4. Partials follow standard Handlebars conventions for passing arguments etc.

Let's say I have information about the user that I want to include in many prompts. I create _userMeta.prompt in my prompts directory with the following content:

== User Information

Name: {{name}}
Email: {{email}}
Birthday: {{birthday}}

I can then use this in any other prompt by passing in appropriate context data:

---
model: vertexai/gemini-1.5-flash-preview
input:
  schema:
    user:
      name: string
      email: string
      birthday: string
---

{{> userMeta user}}

== Instructions

This is specific to the current prompt but I didn't have to copy/paste the user meta stuff.