Skip to content
Snippets Groups Projects
Commit 4d5d8d4d authored by timothycarambat's avatar timothycarambat
Browse files

patch gemini embedding key preference

resolves #2972
parent 21af8108
No related branches found
No related tags found
No related merge requests found
class GeminiEmbedder { class GeminiEmbedder {
constructor() { constructor() {
if (!process.env.GEMINI_API_KEY) if (!process.env.GEMINI_EMBEDDING_API_KEY)
throw new Error("No Gemini API key was set."); throw new Error("No Gemini API key was set.");
const { GoogleGenerativeAI } = require("@google/generative-ai"); const { GoogleGenerativeAI } = require("@google/generative-ai");
const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY); const genAI = new GoogleGenerativeAI(process.env.GEMINI_EMBEDDING_API_KEY);
this.model = process.env.EMBEDDING_MODEL_PREF || "text-embedding-004"; this.model = process.env.EMBEDDING_MODEL_PREF || "text-embedding-004";
this.gemini = genAI.getGenerativeModel({ model: this.model }); this.gemini = genAI.getGenerativeModel({ model: this.model });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment