From 087a4da1163a4f83391744ac4c2b140993cf8962 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 20 May 2026 16:17:56 +0000 Subject: [PATCH] fix(tests): backfill local model_cost into remote-fetched map litellm.model_cost is loaded at import time from LITELLM_MODEL_COST_MAP_URL (pinned to main), so pricing entries that exist only in this branch (e.g. mistral/ministral-8b-2512, freshly added because Mistral's API now returns this id from mistral-tiny) are absent at test time and completion_cost lookups raise 'This model isn't mapped yet'. Backfill the in-tree backup into litellm.model_cost in the local_testing conftest so cassette-driven cost calculations resolve against the entries that ship with the branch under test. Fixes local_testing_part1 failures on test_completion_mistral_api and test_completion_mistral_api_modified_input. --- tests/local_testing/conftest.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/local_testing/conftest.py b/tests/local_testing/conftest.py index 6a746041f15..401a1fb85ec 100644 --- a/tests/local_testing/conftest.py +++ b/tests/local_testing/conftest.py @@ -22,6 +22,20 @@ sys.path.insert( ) # Adds the parent directory to the system path import litellm +# ``litellm.model_cost`` is loaded at import time from the URL pinned to ``main`` +# (``LITELLM_MODEL_COST_MAP_URL``). The in-tree backup ships with this branch +# and can include pricing entries that ``main`` has not yet picked up (e.g. +# Mistral now returns ``ministral-8b-2512`` from ``mistral-tiny`` and the entry +# was added on this branch). Backfill any entries that are missing from the +# remote-fetched map so cost-calculator lookups in tests succeed against the +# cassette state the branch is being tested with. +from litellm.litellm_core_utils.get_model_cost_map import GetModelCostMap + +_local_cost_map = GetModelCostMap.load_local_model_cost_map() +for _k, _v in _local_cost_map.items(): + litellm.model_cost.setdefault(_k, _v) +del _local_cost_map + from tests._vcr_conftest_common import ( # noqa: E402,F401 VerboseReporterState, _pin_multipart_boundary,