aaaaa
/*
* Install the Generative AI SDK
*
* $ npm install @google/generative-ai
*/
const {
GoogleGenerativeAI,
HarmCategory,
HarmBlockThreshold,
} = require("@google/generative-ai");
const apiKey = process.env.GEMINI_API_KEY;
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",
};
async function run() {
const chatSession = model.startChat({
generationConfig,
// safetySettings: Adjust safety settings
// See https://ai.google.dev/gemini-api/docs/safety-settings
history: [
{
role: "user",
parts: [
{text: "Using this video, please answer the below questions:\n\n1. Who is the main subject of the video?\n2. List out how Ashley navigated her trip.\n3. At what timestamp did musicians appear playing instruments?"},
],
},
{
role: "model",
parts: [
{text: "Here are the answers to your questions.\n\n1. The main subject of the video is Ashley. \n2. Ashley used Google Trips to navigate her trip. She downloaded the app, which allowed her to have access to all of her trip details, including her flights, hotel information, and itinerary, even without internet access. She was able to personalize her itinerary and get directions to her destinations. \n3. Musicians appeared playing instruments at the 1:34 timestamp. \n"},
],
},
],
});
const result = await chatSession.sendMessage("INSERT_INPUT_HERE");
console.log(result.response.text());
}
run();