Skip to content

[Dotprompt] Support custom helpers #416

Closed
@mbleigh

Description

@mbleigh

Handlebars supports helpers and Dotprompt provides a few of its own as built-ins. We should allow developers to specify their own. Two possible approaches:

Helpers at Plugin Definition

function loud(input: string): string { return input.toUpperCase() }

configureGenkit({
  plugins: [dotprompt({helpers: {loud}})]
});

This puts everything in one place and makes sure that helpers are correctly registered ahead of time.

defineHelper

Dotprompt could export a defineHelper method:

defineHelper('loud', (input: string) => {
  return input.toUpperCase();
});

This feels more ergonomic at definition time but raises some issues - primarily, if the file containing this code hasn't been loaded and a prompt relying on the helper gets executed, it will break.

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