mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-27 01:22:18 +00:00
fix(vertex_ai/gemini): strip MIME parameters from GCS contentType
GCS object metadata's contentType field can include parameters such as 'text/html; charset=utf-8'. Strip them in _apply_gemini_mime_type_aliases so downstream get_file_extension_from_mime_type sees a bare MIME type. Co-authored-by: Yassin Kortam <yassin@berri.ai>
This commit is contained in:
parent
e54528096f
commit
d5f3224309
1 changed files with 7 additions and 4 deletions
|
|
@ -73,10 +73,13 @@ _GEMINI_MIME_TYPE_ALIASES: Dict[str, str] = {
|
|||
|
||||
|
||||
def _apply_gemini_mime_type_aliases(mime_type: str) -> str:
|
||||
"""Normalize known MIME aliases only; does not consult the file-type registry."""
|
||||
return _GEMINI_MIME_TYPE_ALIASES.get(
|
||||
mime_type.strip().lower(), mime_type.strip().lower()
|
||||
)
|
||||
"""Normalize known MIME aliases only; does not consult the file-type registry.
|
||||
|
||||
Also strips MIME parameters (e.g. ``; charset=utf-8``) so that values
|
||||
sourced from GCS object metadata (``contentType``) validate correctly.
|
||||
"""
|
||||
normalized = mime_type.split(";", 1)[0].strip().lower()
|
||||
return _GEMINI_MIME_TYPE_ALIASES.get(normalized, normalized)
|
||||
|
||||
|
||||
def _get_vertex_base() -> Any:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue