genkit icon indicating copy to clipboard operation
genkit copied to clipboard

[Docs] Align the dotprompt example with the sample flow

Open mjchristy opened this issue 1 year ago • 3 comments

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.

mjchristy avatar Jul 16 '24 17:07 mjchristy

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

cabljac avatar Jul 18 '24 10:07 cabljac

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

mjchristy avatar Jul 19 '24 13:07 mjchristy

@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.

pr-Mais avatar Jul 23 '24 13:07 pr-Mais