Closed
Description
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.