Skip to content

Clarify usage of defineDotPrompt vs definePrompt #338

@MichaelDoyle

Description

@MichaelDoyle

Problem

The existence of both definePrompt and defineDotPrompt is causing confusion. See also: discussion https://github.com/firebase/genkit/discussions/337. I believe this at least partially stems from the following documentation which frames definePrompt as a starting point, and dotprompt as a more advanced capability:

https://firebase.google.com/docs/genkit/prompts

I don't think this is what we intend; rather I think we intend for developers to start with dotprompt.

Background history/context:

When we first implemented the dotprompt library, we had a method definePrompt that was used to create and register a prompt action in the registry. Calling this action conveniently hydrated any input variables into the prompt and then called the model to generate a response.

Later, when we added dotprompt functionality to the Developer UI, we needed an action that would simply render the prompt template without doing the generate step. This led to the following changes:

  • definePrompt was repurposed as a lower level method that registers a prompt action which returns a GenerateRequest without doing the generate step.
  • A new dotprompt plugin was then created that exported a defineDotPrompt method, which followed the old semantics (render the template and then call generate). It uses definePrompt under the covers to register the prompt, which allows the Developer UI to call the underlying prompt action in cases where it only needs the rendered prompt template.

Proposal

  1. At minimum, we should update the docs to orient users toward dotPrompt first.
  2. Consider renaming definePrompt to something more indicative of what it should be used for.

Metadata

Metadata

Labels

docsImprovements or additions to documentation

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions