This has happened on my local machine as well as google cloud run functions.
Relevant log output
TRACEBACK: Traceback (most recent call last):
File "/Users/User/OWL/main.py", line 668, in analyze_single_call
response = chat.send_message([
File "/Users/User/OWL/venv/lib/python3.10/site-packages/google/generativeai/generative_models.py", line 578, in send_message
response = self.model.generate_content(
File "/Users/User/OWL/venv/lib/python3.10/site-packages/google/generativeai/generative_models.py", line 331, in generate_content
response = self._client.generate_content(
File "/Users/User/OWL/venv/lib/python3.10/site-packages/google/ai/generativelanguage_v1beta/services/generative_service/client.py", line 830, in generate_content
response = rpc(
File "/Users/User/OWL/venv/lib/python3.10/site-packages/google/api_core/gapic_v1/method.py", line 131, in __call__
return wrapped_func(*args, **kwargs)
File "/Users/User/OWL/venv/lib/python3.10/site-packages/google/api_core/retry/retry_unary.py", line 293, in retry_wrapped_func
return retry_target(
File "/Users/User/OWL/venv/lib/python3.10/site-packages/google/api_core/retry/retry_unary.py", line 153, in retry_target
_retry_error_helper(
File "/Users/User/OWL/venv/lib/python3.10/site-packages/google/api_core/retry/retry_base.py", line 212, in _retry_error_helper
raise final_exc from source_exc
File "/Users/User/OWL/venv/lib/python3.10/site-packages/google/api_core/retry/retry_unary.py", line 144, in retry_target
result = target()
File "/Users/User/OWL/venv/lib/python3.10/site-packages/google/api_core/timeout.py", line 120, in func_with_timeout
return func(*args, **kwargs)
File "/Users/User/OWL/venv/lib/python3.10/site-packages/google/api_core/grpc_helpers.py", line 78, in error_remapped_callable
raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.InvalidArgument: 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
Code of Conduct
[X] I agree to follow this project's Code of Conduct
File Name
generativeai/files.py
What happened?
Mime-type assignment is not working properly
Gemini stopped working due to the file upload in the python sdk being broken.
this is how i use the file upload
when i upload a file like so
audio_file = upload_to_gemini(temp_path, "audio/wav")
it uploads correctly but the mime type is not set
AUDIO FILE: genai.File({ 'name': 'files/30txz5yr4lnt', 'display_name': 'tmp8nqzekug.wav', 'mime_type': '', 'sha256_hash': '', 'size_bytes': '0', 'state': 'ACTIVE', 'create_time': '2024-11-11T23:28:05.021763Z', 'expiration_time': '2024-11-13T23:28:05.001887117Z', 'update_time': '2024-11-11T23:28:05.021763Z'})
as you can see the mime type is not set
resulting in this issue: 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
This has happened on my local machine as well as google cloud run functions.
Relevant log output
Code of Conduct