Update googleGemini.js
Browse files- googleGemini.js +6 -5
googleGemini.js
CHANGED
@@ -6,7 +6,7 @@ dotenv.config();
|
|
6 |
const GoogleAPIKey = process.env.GOOGLE_API_KEY;
|
7 |
|
8 |
if (!GoogleAPIKey) {
|
9 |
-
throw new Error("Missing
|
10 |
}
|
11 |
|
12 |
const genAI = new GoogleGenerativeAI(GoogleAPIKey);
|
@@ -22,12 +22,13 @@ async function GeminiResponse(prompt) {
|
|
22 |
model: "gemini-1.5-flash",
|
23 |
});
|
24 |
const result = await model.generateContent(prompt);
|
25 |
-
console.log("Response", result)
|
26 |
-
|
|
|
27 |
} catch (e) {
|
28 |
console.error(`Error in GeminiResponse: ${e.message}`);
|
29 |
-
return "";
|
30 |
}
|
31 |
}
|
32 |
|
33 |
-
export { GeminiResponse };
|
|
|
6 |
const GoogleAPIKey = process.env.GOOGLE_API_KEY;
|
7 |
|
8 |
if (!GoogleAPIKey) {
|
9 |
+
throw new Error("Missing variable: GOOGLE_API_KEY");
|
10 |
}
|
11 |
|
12 |
const genAI = new GoogleGenerativeAI(GoogleAPIKey);
|
|
|
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 |
+
return text || "No response content";
|
28 |
} catch (e) {
|
29 |
console.error(`Error in GeminiResponse: ${e.message}`);
|
30 |
+
return "Error generating response.";
|
31 |
}
|
32 |
}
|
33 |
|
34 |
+
export { GeminiResponse };
|