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.
Apache License 2.0
607 stars 74 forks source link

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

Closed njpearman closed 2 months ago

njpearman commented 2 months ago

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.

MichaelDoyle commented 2 months ago

Thanks for reporting - we'll take a closer look.

maxl0rd commented 2 months ago

This was a feature of an earlier iteration of dotprompt, but it was removed in the final plugin. We'll update the docs to reflect that change.