genkit icon indicating copy to clipboard operation
genkit copied to clipboard

Adds generateText and generateOutput convenience methods.

Open mbleigh opened this issue 1 year ago • 1 comments

This adds new generateText and generateOutput convenience methods that return like so:

const {text, response} = await generateText({prompt: "Tell me a joke"});

const {output, response} = await generateOutput({
  prompt: "Create a creature",
  output: {
    schema: z.object({
      name: z.string(),
      hitPoints: z.number()
    })
  }
});

It's a small ergonomic change but it prevents needing to assign the response to a variable if you don't care about it.

If you like the idea we can talk about how we'd want to document it vs. other options.

mbleigh avatar Jun 13 '24 23:06 mbleigh

@mbleigh I saw you added these things to the 0.6 release doc. Did you want to submit this PR?

apascal07 avatar Aug 19 '24 18:08 apascal07