Skip to content

[dotprompt] dotprompt variants don't fall through to "defaults" as documented  #496

@njpearman

Description

@njpearman

Describe the bug
The Prompt Variants section of the documentation for .prompt files states:

The prompt loader will attempt to load the variant of that name, and fall back to the baseline if none exists.

However, it seems that this is not the case and, looking at the registry file, there doesn't seem to be any logic to attempt to load a file without the variant when a variant has been used. I'm looking in particular at maybeLoadPrompt but I've looked around related areas too: https://github.com/firebase/genkit/blob/main/js/plugins/dotprompt/src/registry.ts

To Reproduce
Create a prompt file with the following name:

prompts/
  random-recipe.prompt

Then try to load the prompt with the following set up:

const prompt = await loadPrompt("random-recipe", { variant: "wacky" });

Rather than loading the prompt, you will see the error:

Error: dotprompt: NOT_FOUND: Could not find 'random-recipe.wacky.prompt' in the prompts folder.

Expected behavior
I would expect behaviour as per the documents, which is that the random-recipe.prompt file is loaded as a fallback and then executed.

Additional context
I'd be happy to pick this up with a bit of guidance on expectations around behaviour.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocsImprovements or additions to documentationjs

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions