test_update_model_cost_map_url

This commit is contained in:
Ishaan Jaffer
2025-12-22 11:51:30 +05:30
parent 46438684ca
commit c9d61fcdba
2 changed files with 6 additions and 8 deletions
+5 -7
View File
@@ -2365,13 +2365,11 @@ def register_model(model_cost: Union[str, dict]): # noqa: PLR0915
loaded_model_cost = litellm.get_model_cost_map(url=model_cost)
for key, value in loaded_model_cost.items():
## get model info ##
try:
existing_model: dict = cast(dict, get_model_info(model=key))
model_cost_key = existing_model["key"]
except Exception:
existing_model = {}
model_cost_key = key
## get existing model info from model_cost directly ##
## avoid calling get_model_info() as it triggers provider resolution
## which can cause side effects like GitHub Copilot OAuth flow
existing_model: dict = litellm.model_cost.get(key, {})
model_cost_key = key
## override / add new keys to the existing model cost dictionary
updated_dictionary = _update_dictionary(existing_model, value)
litellm.model_cost.setdefault(model_cost_key, {}).update(updated_dictionary)
+1 -1
View File
@@ -62,4 +62,4 @@ def test_update_model_cost_via_completion():
pytest.fail(f"An error occurred: {e}")
test_update_model_cost_via_completion()
# test_update_model_cost_via_completion()