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
611 stars 74 forks source link

[Docs] Align the dotprompt example with the sample flow #634

Open mjchristy opened 2 months ago

mjchristy commented 2 months ago

I was trying to convert the sample flow to use dotprompt and I (newbie Node dev) had trouble doing this. I thought it might be nice to use the same example with the same inputs for our first dotprompt sample, to eliminate things that could go wrong.

I also found it confusing that the dotPrompt example hardcodes values in the generate function while the sample flow relies on inputs coming from the devui/app. I think you might want to consider only hardcoding inputs when we are executing flows on the command line.

const menuSuggestionPrompt = await prompt(menuSuggestion);

const llmResponse = await menuSuggestionPrompt.generate({input});

console.log(llmResponse.text());

Requested changes:

  1. Update result to be llmResponse to keep in line with sample flow
  2. Use the menu suggestion prompt text in the dotprompt file.
  3. [maybe?] tell users to replace everything in the async (input) => {} function, or figure out some way to be clear how you can make this work.
  4. [maybe?] Explain what input object is.

Additional context This might be resolved with a better example in the future.

cabljac commented 1 month ago

Sorry just to clarify, can you link which dotPrompt example you're talking about?

mjchristy commented 1 month ago

Sure! https://firebase.google.com/docs/genkit/dotprompt the dot prompt example.

pr-Mais commented 1 month ago

@mjchristy on point 2:

Use the menu suggestion prompt text in the dotprompt file.

If I'm not mistaken, you're referring to the following sample (taken from here):

---
model: vertexai/gemini-1.0-pro
input:
  schema:
    theme: string
output:
  format: json
  schema:
    name: string
    price: integer
    ingredients(array): string
---

Generate a menu item that could be found at a {{theme}} themed restaurant.

and by "prompt text" you mean the theme parameter in the input schema, which is banana in the sample?

const createMenuPrompt = await prompt('create_menu');

const menu = await createMenuPrompt.generate({
  input: {
    theme: 'banana',
  },
});

console.log(menu.output());

I looked up for the sample you pasted but couldn't find it in this page.