Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[功能]: Gemini 支持文档上传 #622

Closed
kangfenmao opened this issue Jan 2, 2025 · 0 comments
Closed

[功能]: Gemini 支持文档上传 #622

kangfenmao opened this issue Jan 2, 2025 · 0 comments
Assignees

Comments

@kangfenmao
Copy link
Collaborator

您的功能建议是否与某个问题相关?

ref: https://ai.google.dev/gemini-api/docs/document-processing?hl=zh-TW&lang=node

请描述您希望实现的解决方案

import { GoogleGenerativeAI } from "@google/generative-ai";

const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);

const model = genAI.getGenerativeModel({ model: 'models/gemini-1.5-flash' });

const result = await model.generateContent([
    {
        inlineData: {
            data: Buffer.from(fs.readFileSync("/content/343019_3_art_0_py4t4l_convrt.pdf")).toString("base64"),
            mimeType: "application/pdf",
        },
    },
    'Summarize this document',
]);
console.log(result.response.text());

请描述您考虑过的其他方案

No response

其他补充信息

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant