Update googleGemini.js
Browse files- googleGemini.js +4 -9
googleGemini.js
CHANGED
@@ -1,15 +1,12 @@
|
|
1 |
import { GoogleGenerativeAI } from "@google/generative-ai";
|
2 |
-
import dotenv from "dotenv";
|
3 |
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
if (!GoogleAPIKey) {
|
9 |
throw new Error("Missing variable: GOOGLE_API_KEY");
|
10 |
}
|
11 |
|
12 |
-
const genAI = new GoogleGenerativeAI(GoogleAPIKey);
|
13 |
|
14 |
/**
|
15 |
* Generate a response using the Gemini AI model.
|
@@ -22,9 +19,7 @@ async function GeminiResponse(prompt) {
|
|
22 |
model: "gemini-1.5-flash",
|
23 |
});
|
24 |
const result = await model.generateContent(prompt);
|
25 |
-
// console.log("Response:", result.response.candidates)
|
26 |
const text = result.response.candidates[0]?.content;
|
27 |
-
// console.log("Results text:", text.parts)
|
28 |
return text.parts[0].text || "No response content";
|
29 |
} catch (e) {
|
30 |
console.error(`Error in GeminiResponse: ${e.message}`);
|
@@ -32,4 +27,4 @@ async function GeminiResponse(prompt) {
|
|
32 |
}
|
33 |
}
|
34 |
|
35 |
-
export { GeminiResponse };
|
|
|
1 |
import { GoogleGenerativeAI } from "@google/generative-ai";
|
|
|
2 |
|
3 |
+
import * as config from '.config.js'
|
4 |
|
5 |
+
if (!config.GoogleAPIKey) {
|
|
|
|
|
6 |
throw new Error("Missing variable: GOOGLE_API_KEY");
|
7 |
}
|
8 |
|
9 |
+
const genAI = new GoogleGenerativeAI(config.GoogleAPIKey);
|
10 |
|
11 |
/**
|
12 |
* Generate a response using the Gemini AI model.
|
|
|
19 |
model: "gemini-1.5-flash",
|
20 |
});
|
21 |
const result = await model.generateContent(prompt);
|
|
|
22 |
const text = result.response.candidates[0]?.content;
|
|
|
23 |
return text.parts[0].text || "No response content";
|
24 |
} catch (e) {
|
25 |
console.error(`Error in GeminiResponse: ${e.message}`);
|
|
|
27 |
}
|
28 |
}
|
29 |
|
30 |
+
export { GeminiResponse };
|