'use strict'; const conf = require('../conf'); const { GoogleGenerativeAI, HarmCategory, HarmBlockThreshold, } = require("@google/generative-ai"); const genAI = new GoogleGenerativeAI(conf.ai.key); const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash", }); const generationConfig = { temperature: 1, topP: 0.95, topK: 64, maxOutputTokens: 8192, responseMimeType: "application/json", }; async function run(name, interval, players) { const chatSession = model.startChat({ generationConfig, safetySettings:[ // See https://ai.google.dev/gemini-api/docs/safety-settings { category: HarmCategory.HARM_CATEGORY_HARASSMENT, threshold: HarmBlockThreshold.BLOCK_NONE, }, { category: HarmCategory.HARM_CATEGORY_HATE_SPEECH, threshold: HarmBlockThreshold.BLOCK_NONE, }, { category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, threshold: HarmBlockThreshold.BLOCK_NONE, }, { category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, threshold: HarmBlockThreshold.BLOCK_NONE, }, ], history: [ { role: "user", parts: [ {text: conf.ai.prompt(name, interval, players)}, ], }, { role: "model", parts: [ {text: "Chat stuff"}, ], } ], }); return chatSession; } module.exports = {run}; // run();