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

[Bug]: Mime-type not working on upload #1390

Closed
1 task done
jay2jp opened this issue Nov 12, 2024 · 2 comments
Closed
1 task done

[Bug]: Mime-type not working on upload #1390

jay2jp opened this issue Nov 12, 2024 · 2 comments

Comments

@jay2jp
Copy link

jay2jp commented Nov 12, 2024

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

def upload_to_gemini(path, mime_type=None):
    """Uploads the given file to Gemini."""
    file = genai.upload_file(path, mime_type=mime_type)
    print(f"[UPLOAD] File uploaded as: {file.uri}")
    return file

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

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

  • I agree to follow this project's Code of Conduct
@adboio
Copy link

adboio commented Nov 12, 2024

related to google-gemini/generative-ai-python#628

@holtskinner
Copy link
Collaborator

Doesn't seem that this issue is related to this repository. It's related to the Gemini API, not Gemini API in Vertex AI. Refer to #628 for the fix.

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

3 participants