forked from ankit14-dev/Meet-Sync-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenaiService.js
More file actions
29 lines (23 loc) · 774 Bytes
/
Copy pathopenaiService.js
File metadata and controls
29 lines (23 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// geminiService.js
const { GoogleGenerativeAI } = require("@google/generative-ai");
require('dotenv').config();
// Initialize Gemini
const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
const generateSummary = async (text) => {
try {
// Get the generative model
const model = genAI.getGenerativeModel({ model: "gemini-pro" });
// Generate summary
const prompt = `Please provide a concise summary of the following text:\n\n${text}`;
const result = await model.generateContent(prompt);
console.log(result)
const response = result.response;
return response.text();
} catch (error) {
console.error("Error generating summary with Gemini:", error);
throw error;
}
};
module.exports = {
generateSummary
};