google-gemini / generative-ai-python

The official Python library for the Google Gemini API
https://pypi.org/project/google-generativeai/
Apache License 2.0
1.18k stars 225 forks source link

glm.FileData issue? with uris #357

Open stephaniegoldman12 opened 1 month ago

stephaniegoldman12 commented 1 month ago

Description of the bug:

google.api_core.exceptions.InvalidArgument: 400 Invalid or unsupported file uri:

glm.FileData with a uri doesn't seem to work? I need to use Part.from_uri from the old vertex.preview library, but that library does not let me use model = genai.GenerativeModel('gemini-1.5-pro-latest')

Actual vs expected behavior:

api_key = os.getenv("GEMINI_API_KEY") genai.configure(api_key=api_key) model = genai.GenerativeModel('gemini-1.5-pro-latest') response = model.generate_content( glm.Content( parts = [ glm.Part(text="What is this image of?"), glm.Part( file_data=glm.FileData( mime_type='image/png', file_uri="gs://urihere.png" ) ), ], ), stream=False)

print(response)

I'd expect this to work...but it says unsupported file uri (note: the uri is correct i just put a placeholder here for the example)

Any other information you'd like to share?

No response

zadiaz commented 1 month ago

same here

Screenshot 2024-05-24 at 11 29 39 AM
va-mzaki commented 1 week ago

@zadiaz i think the only supported URI is the URIs from google file manager that start with https://generativelanguage.googleapis.com/v1beta/files