Closed mikewadhera closed 1 week ago
We are seeing this as well (also Hi Mike!)
Same issue here, even manually setting the mime_type doesn't do anything
Even the example notebooks on Gemini docs are broken e.g. https://ai.google.dev/gemini-api/docs/vision?lang=python
same here.
Following up for visibility. I reached out on Twitter and got a response, so they should be aware. https://x.com/OfficialLoganK/status/1856130496058495019
+1 seeing this as well.
my errors started with a generic 400:
400 Request contains an invalid argument.
after digging around a bit and changing some params, i'm now seeing this for every content gen call that includes a file:
400 Unable to submit request because it has an empty mimeType parameter in fileData. Add a value to the parameter and try again. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini
i'm uploading with an explicit mime-type:
model = genai.GenerativeModel("gemini-1.5-flash")
media_file = genai.upload_file(media_filepath, mime_type=mime_type)
sample file response
genai.File({
'name': 'files/emcdwwnbjjpz',
'display_name': 'video.mp4',
'mime_type': '',
'sha256_hash': '',
'size_bytes': '0',
'state': 'ACTIVE',
'uri': 'https://generativelanguage.googleapis.com/v1beta/files/emcdwwnbjjpz',
'create_time': '2024-11-12T01:12:51.359555Z',
'expiration_time': '2024-11-14T01:12:51.344144581Z',
'update_time': '2024-11-12T01:12:51.359555Z'})
is this only happening with the python SDK? can we call the API directly as a temp fix here?
is this only happening with the python SDK? can we call the API directly as a temp fix here?
failing with the node sdk as well @adboio
related post on google cloud forums: https://www.googlecloudcommunity.com/gc/AI-ML/Gemini-API-method-models-generateContent-returns-error-code-400/m-p/831749
and issue in another repo https://github.com/GoogleCloudPlatform/generative-ai/issues/1390
So happy to not just be the only one. Who changed the server side of file_upload?
found a potential workaround! :rocket:
instead of calling upload_file
, use the Blob
type and pass file contents directly to the generate_content
:
from google.generativeai import protos
model = genai.GenerativeModel("gemini-1.5-pro")
with open(media_filepath, 'rb') as fp:
file_contents = fp.read()
media_blob = protos.Blob(data=file_contents, mime_type=mime_type)
response = model.generate_content([media_blob, prompt_text],
generation_config=genai.GenerationConfig(
response_mime_type="application/json", response_schema=Recipe
)
)
edit: welp, this only works up to a limit...
400 Request payload size exceeds the limit: 20971520 bytes. The file size is too large. Please use the File API to upload your files instead. Example: `f = genai.upload_file(path); m.generate_content(['tell me about this file:', f])`
I'm having the same issue
my use-case is for video files, and the workaround i posted above does not work if the files are too large... i tried splitting the file into multiple parts and uploading the blobs individually (like generate_content([ blob1, blob2, blob3, "prompt" ])
), but it seems the payload limit is on the entire payload, not individual parts... so i'm not sure of any workaround for larger files at this point
My work around is to wait. Is this the first major outage of this beautiful product?
It is fixed. Well done GOOGLE!
working for me now too!
It’s finally working again!
But, Why?
Hey! We rolled out a fix for this issue, apologies for the delay. I am going to also get a status page setup to make it easier to follow this stuff in the future.
Description of the bug:
genai.upload_file(path=path, mime_type=mime_type)
Any code that was once working downstream of this, including
generate_content
now failsLooks like this was from a production push? Started today 11/11/24 around noon PDT.
Also #627 likely related
Actual vs expected behavior:
Expected: a file with proper
size_bytes
andmime_type
Actual:
size_bytes
always zero andmime_type
always''
Any other information you'd like to share?
Looks like this was from a production push? Started today 11/11/24 around noon PDT.
Also #627 likely related