-
Notifications
You must be signed in to change notification settings - Fork 479
Closed
Labels
Description
Describe the bug
When the apiKey
is not passed in the configuration for the generate
function, the error message is confusing and suggests that the model is not found, instead of indicating that the apiKey
is missing.
To Reproduce
Steps to reproduce the behavior:
- Set up a project using Genkit.
- Do not include the
apiKey
in thegenerate
function's configuration. - Run the code.
Expected behavior
A clear error message indicating that the apiKey
is missing and should be included in the configuration.
Code Snippet
const { generate } = require('@genkit-ai/ai');
const { geminiPro } = require('@genkit-ai/googleai');
exports.generate = function() {
console.log('generate for', geminiPro);
return generate({
model: geminiPro,
config: {
temperature: 0.3,
maxOutputTokens: 200
// apiKey is missing here
},
prompt: 'What makes you the best LLM out there?',
})
.then(result => {
return result.text();
})
.catch(error => {
console.error('Error generating response:', error);
throw error;
});
}
Error Message
Error: Model {"name":"googleai/gemini-pro","info":{"label":"Google AI - Gemini Pro","versions":["gemini-1.0-pro","gemini-1.0-pro-latest","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 C:\work\Promptrepo\functions\node_modules\@genkit-ai\ai\lib\generate.js:513:13
at Generator.next (<anonymous>)
at fulfilled (C:\work\Promptrepo\functions\node_modules\@genkit-ai\ai\lib\generate.js:53:24)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Additional context
The error message should more accurately reflect the issue with the missing apiKey
. It would help if the error message guided the user to include the apiKey
in the configuration using configureGenkit
.
Environment:
- OS: [e.g., Windows 10]
- Node.js version: [e.g., 14.17.0]
- Genkit version: [e.g., 1.0.0-beta]