From c9d61fcdbac4e3c9c6adbeef22e67f07a2895bbe Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Mon, 22 Dec 2025 11:51:30 +0530 Subject: [PATCH] test_update_model_cost_map_url --- litellm/utils.py | 12 +++++------- tests/local_testing/test_register_model.py | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index ce6b2aa9c6..4e4a9747e7 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -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) diff --git a/tests/local_testing/test_register_model.py b/tests/local_testing/test_register_model.py index 6b17079887..028bdc0abc 100644 --- a/tests/local_testing/test_register_model.py +++ b/tests/local_testing/test_register_model.py @@ -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()