google-gemini / generative-ai-js

The official Node.js / Typescript library for the Google Gemini API
https://ai.google.dev/
Apache License 2.0
502 stars 96 forks source link

Unsupported PDF type #182

Closed Flucadetena closed 1 day ago

Flucadetena commented 4 days ago

Description of the bug:

Trying to process a pdf throws an error saying the file type is not supported. gemini-1.5-pro-latest:generateContent: [400 Bad Request] Unsupported MIME type: application/pdf

Actual vs expected behavior:

Throughs the error of mime type not supported when in theory it is.

Any other information you'd like to share?

I'm using the code generated from Gemini Studio with small changes as the js version from studio does not seem to be the same as the latest release on npm.

For example the GoogleAIFileManager has to be access through the /serve subpath and not the /files subpath as Gemeni Studio does.

All files seem to upload without an issue and their state is active.

Thanks for the work in advance if I can be of assistance, happy to help.

singhniraj08 commented 2 days ago

@Flucadetena, Gemini API doesn't directly handle PDFs yet. This is not related to JS SDK. You can do something like this to upload the text and/or screenshots: convert a PDF file so that it can be read by the Gemini API.

If the above tutorial doesn't fits your use-case, we would suggest you to use "Send Feedback" option in Gemini docs. Ref: Screenshot below. You can also post this issue on Discourse forum.

image

Flucadetena commented 1 day ago

@singhniraj08 great thank you very much for the quick answer. It was just confusing as the code generate by "Google Studio" uses de JS SDK of Gemini and works. But I understand that it may use some version in development or use some workaround with Vertex AI that does not share.

Thanks a lot!