fix(main.py): forward headers to multimodal embeddings and refresh lock file

This commit is contained in:
Adnaan Ali 2026-02-13 07:02:38 +00:00
parent 2f0acfbea1
commit 567e61323c
3 changed files with 2344 additions and 1927 deletions

View file

@ -5148,6 +5148,7 @@ def embedding( # noqa: PLR0915
vertex_project=vertex_ai_project,
vertex_location=vertex_ai_location,
vertex_credentials=vertex_credentials,
headers=headers,
aembedding=aembedding,
print_verbose=print_verbose,
custom_llm_provider="vertex_ai",

4228
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -3,16 +3,9 @@ from unittest.mock import patch, MagicMock
from litellm import embedding
def test_vertex_ai_embedding_extra_headers():
"""
Test that extra_headers are correctly forwarded to the
vertex_embedding.embedding function.
"""
# We patch the exact location where main.py calls the vertex provider
with patch("litellm.main.vertex_embedding.embedding") as mock_vertex_embedding:
# Mock a successful return so the call doesn't fail
mock_vertex_embedding.return_value = MagicMock()
# Trigger the embedding call
"""Test standard vertex embedding header forwarding."""
with patch("litellm.main.vertex_embedding.embedding") as mock_vertex:
mock_vertex.return_value = MagicMock()
try:
embedding(
model="vertex_ai/text-embedding-004",
@ -20,13 +13,24 @@ def test_vertex_ai_embedding_extra_headers():
extra_headers={"X-Custom-Header": "test-value"},
)
except Exception:
# We don't care about subsequent errors, only the forwarding
pass
# VERIFICATION: This is the important part
mock_vertex_embedding.assert_called_once()
call_kwargs = mock_vertex_embedding.call_args.kwargs
# Check that the headers we passed actually reached the provider
assert call_kwargs.get("extra_headers") == {"X-Custom-Header": "test-value"}
print("\n✅ Success: extra_headers correctly forwarded to Vertex AI provider!")
mock_vertex.assert_called_once()
assert mock_vertex.call_args.kwargs.get("extra_headers") == {"X-Custom-Header": "test-value"}
def test_vertex_multimodal_embedding_headers():
"""Test multimodal vertex embedding header forwarding."""
with patch("litellm.main.vertex_multimodal_embedding.multimodal_embedding") as mock_multimodal:
mock_multimodal.return_value = MagicMock()
try:
# Using a multimodal model triggers the different provider path
embedding(
model="vertex_ai/multimodalembedding@001",
input=["hello"],
extra_headers={"X-Custom-Header": "multi-value"},
)
except Exception:
pass
mock_multimodal.assert_called_once()
# NOTE: The multimodal handler uses 'headers' as the parameter name
assert mock_multimodal.call_args.kwargs.get("headers") == {"X-Custom-Header": "multi-value"}
print("\n✅ Success: Headers forwarded for both standard and multimodal Vertex AI!")