Auspicious14's picture
Upload 94 files
77610ec verified
Raw
History Blame Contribute Delete
518 Bytes
import { GoogleGenerativeAI } from "@google/generative-ai";
const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || "");
export const getGeminiResponse = async (
prompt: string,
history: { role: string; parts: { text: string }[] }[] = []
) => {
const model = genAI.getGenerativeModel({ model: "gemini-2.5-flash" });
const chat = model.startChat({
history: history,
});
const result = await chat.sendMessage(prompt);
const response = await result.response;
return response.text();
};