genkit icon indicating copy to clipboard operation
genkit copied to clipboard

Improve error message when configureGenkit hasn't been called

Open i2amsam opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

I've gotten a few reports of folks running into this:

If you write code like

import { geminiPro } from "@genkit-ai/vertexai";
...

    const result = await generate({
      model: geminiPro,
      prompt: `Tell me a joke about {input}`,
      output: z.string()
    });

without ever calling configureGenkit() to configure Vertex you get and error like

Error: Model {"name":"vertexai/gemini-1.0-pro","info":{"label":"Vertex AI - Gemini Pro","versions":["gemini-1.0-pro","gemini-1.0-pro-001"],"supports":{"multiturn":true,"media":false,"tools":true,"systemRole":true}},"configSchema":{"_def":{"unknownKeys":"strip","catchall":{"_def":{"typeName":"ZodNever"}},"typeName":"ZodObject"},"_cached":null}} not found
    at /workspace/node_modules/@genkit-ai/ai/lib/generate.js:480:13
    at Generator.next (<anonymous>)
    at fulfilled (/workspace/node_modules/@genkit-ai/ai/lib/generate.js:53:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Describe the solution you'd like It would be better if the error said something like "Are you missing a call configureGenkit(...)"

Describe alternatives you've considered Or if there was a way to throw a error("Called without configuration") that could also be helpful.

Additional context Add any other context or screenshots about the feature request here.

i2amsam avatar May 15 '24 14:05 i2amsam