mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
test_update_model_cost_map_url
This commit is contained in:
parent
09dcb38b4b
commit
29513cf6a6
1 changed files with 18 additions and 5 deletions
|
|
@ -2364,14 +2364,27 @@ def register_model(model_cost: Union[str, dict]): # noqa: PLR0915
|
|||
elif isinstance(model_cost, str):
|
||||
loaded_model_cost = litellm.get_model_cost_map(url=model_cost)
|
||||
|
||||
# Providers that trigger side effects (e.g., OAuth flows) when get_model_info is called
|
||||
# Skip get_model_info for these providers during model registration
|
||||
_skip_get_model_info_providers = {
|
||||
LlmProviders.GITHUB_COPILOT.value,
|
||||
}
|
||||
|
||||
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 = {}
|
||||
provider = value.get("litellm_provider", "")
|
||||
if provider in _skip_get_model_info_providers or any(
|
||||
key.startswith(f"{p}/") for p in _skip_get_model_info_providers
|
||||
):
|
||||
existing_model = litellm.model_cost.get(key, {})
|
||||
model_cost_key = key
|
||||
else:
|
||||
try:
|
||||
existing_model = cast(dict, get_model_info(model=key))
|
||||
model_cost_key = existing_model["key"]
|
||||
except Exception:
|
||||
existing_model = {}
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue