test(vertex): load local pricing in embedding billing tests

The gemini-embedding-2 batch embedding tests assert exact dollar amounts
using the in-repo pricing schema. Without LITELLM_LOCAL_MODEL_COST_MAP=True,
litellm.model_cost is fetched from main, which now bills those modalities
per-token instead. That mismatch drove the Vertex AI unit tests to fail
with prompt_cost of 0.0 or the per-token figure rather than the expected
per-image / per-second amount.

Add an autouse fixture that pins the cost map to the in-repo copy so the
billing assertions stay deterministic on this branch.
This commit is contained in:
Cursor Agent 2026-09-15 21:14:14 +00:00
parent 252c71c0b2
commit 13414f35d2
No known key found for this signature in database

View file

@ -10,6 +10,7 @@ Covers:
import pytest
import litellm
from litellm.litellm_core_utils.llm_cost_calc.utils import generic_cost_per_token
from litellm.llms.vertex_ai.gemini_embeddings.batch_embed_content_transformation import (
_build_part_for_input,
@ -27,6 +28,15 @@ IMAGE_DATA_URI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+
GCS_URL = "gs://my-bucket/image.png"
@pytest.fixture(autouse=True)
def _local_model_cost_map(monkeypatch):
monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url=""))
litellm.get_model_info.cache_clear()
yield
litellm.get_model_info.cache_clear()
class TestIsMultimodalInput:
def test_text_only_string(self):
assert _is_multimodal_input("hello world") is False