-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex.js
33 lines (24 loc) · 839 Bytes
/
ex.js
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
30
31
32
33
const { GoogleGenerativeAI } = require("@google/generative-ai");
const fs = require("fs");
const genAI = new GoogleGenerativeAI("api_key");
function fileToGenerativePart(path, mimeType) {
return {
inlineData: {
data: Buffer.from(fs.readFileSync(path)).toString("base64"),
mimeType,
},
};
}
async function run() {
const model = genAI.getGenerativeModel({ model: "gemini-pro-vision" });
const prompt = "이 두 사진 에서 누가 엔비디아 ceo일까?";
const imageParts = [
fileToGenerativePart("a.png", "image/png"),
fileToGenerativePart("b.png", "image/png"),
];
const result = await model.generateContent([prompt, ...imageParts]);
const response = await result.response;
const text = response.text();
console.log(text);
}
run();