Spaces:
Sleeping
Sleeping
| const { | |
| GoogleGenerativeAI, | |
| HarmCategory, | |
| HarmBlockThreshold, | |
| } = require("@google/generative-ai"); | |
| const apiKey = process.env.GEMINI_API_KEY; | |
| if (!apiKey) { | |
| throw new Error("GEMINI_API_KEY is missing"); | |
| } | |
| const genAI = new GoogleGenerativeAI(apiKey); | |
| const model = genAI.getGenerativeModel({ | |
| model: "gemini-1.5-flash", | |
| }); | |
| const generationConfig = { | |
| temperature: 1, | |
| topP: 0.95, | |
| topK: 64, | |
| maxOutputTokens: 8192, | |
| responseMimeType: "text/plain", | |
| }; | |
| export const chatSession = model.startChat({ | |
| generationConfig, | |
| // safetySettings: Adjust safety settings | |
| // See https://ai.google.dev/gemini-api/docs/safety-settings | |
| history: [], | |
| }); | |