Skip to content

[Dotprompt] Add support for partials #415

@mbleigh

Description

@mbleigh

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.

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