mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
refactor: derive model_list from models_by_provider to prevent drift
This commit is contained in:
parent
3dcc787347
commit
8534a7c7b4
2 changed files with 6 additions and 131 deletions
|
|
@ -951,114 +951,6 @@ ollama_models = ["llama2"]
|
|||
|
||||
maritalk_models = ["maritalk"]
|
||||
|
||||
model_list = list(
|
||||
open_ai_chat_completion_models
|
||||
| open_ai_text_completion_models
|
||||
| cohere_models
|
||||
| cohere_chat_models
|
||||
| anthropic_models
|
||||
| set(replicate_models)
|
||||
| openrouter_models
|
||||
| datarobot_models
|
||||
| set(huggingface_models)
|
||||
| vertex_chat_models
|
||||
| vertex_text_models
|
||||
| ai21_models
|
||||
| ai21_chat_models
|
||||
| set(together_ai_models)
|
||||
| set(baseten_models)
|
||||
| aleph_alpha_models
|
||||
| nlp_cloud_models
|
||||
| set(ollama_models)
|
||||
| bedrock_models
|
||||
| deepinfra_models
|
||||
| perplexity_models
|
||||
| set(maritalk_models)
|
||||
| runwayml_models
|
||||
| vertex_language_models
|
||||
| watsonx_models
|
||||
| gemini_models
|
||||
| text_completion_codestral_models
|
||||
| xai_models
|
||||
| zai_models
|
||||
| fal_ai_models
|
||||
| deepseek_models
|
||||
| azure_ai_models
|
||||
| voyage_models
|
||||
| infinity_models
|
||||
| databricks_models
|
||||
| cloudflare_models
|
||||
| codestral_models
|
||||
| friendliai_models
|
||||
| palm_models
|
||||
| groq_models
|
||||
| azure_models
|
||||
| azure_anthropic_models
|
||||
| anyscale_models
|
||||
| cerebras_models
|
||||
| galadriel_models
|
||||
| nvidia_nim_models
|
||||
| nvidia_riva_models
|
||||
| sambanova_models
|
||||
| azure_text_models
|
||||
| novita_models
|
||||
| assemblyai_models
|
||||
| jina_ai_models
|
||||
| snowflake_models
|
||||
| gradient_ai_models
|
||||
| llama_models
|
||||
| featherless_ai_models
|
||||
| nscale_models
|
||||
| deepgram_models
|
||||
| elevenlabs_models
|
||||
| dashscope_models
|
||||
| moonshot_models
|
||||
| publicai_models
|
||||
| v0_models
|
||||
| morph_models
|
||||
| lambda_ai_models
|
||||
| black_forest_labs_models
|
||||
| recraft_models
|
||||
| cometapi_models
|
||||
| oci_models
|
||||
| heroku_models
|
||||
| vercel_ai_gateway_models
|
||||
| volcengine_models
|
||||
| wandb_models
|
||||
| ovhcloud_models
|
||||
| lemonade_models
|
||||
| docker_model_runner_models
|
||||
| reducto_models
|
||||
| bedrock_mantle_models
|
||||
| set(clarifai_models)
|
||||
| set(petals_models)
|
||||
| bedrock_converse_models
|
||||
| vertex_anthropic_models
|
||||
| vertex_vision_models
|
||||
| vertex_deepseek_models
|
||||
| vertex_minimax_models
|
||||
| vertex_moonshot_models
|
||||
| vertex_zai_models
|
||||
| fireworks_ai_models
|
||||
| fireworks_ai_embedding_models
|
||||
| mistral_chat_models
|
||||
| sambanova_embedding_models
|
||||
| nebius_models
|
||||
| nebius_embedding_models
|
||||
| aiml_models
|
||||
| hyperbolic_models
|
||||
| amazon_nova_models
|
||||
| stability_models
|
||||
| github_copilot_models
|
||||
| chatgpt_models
|
||||
| minimax_models
|
||||
| aws_polly_models
|
||||
| gigachat_models
|
||||
| llamagate_models
|
||||
| ovhcloud_embedding_models
|
||||
)
|
||||
|
||||
model_list_set = set(model_list)
|
||||
|
||||
# provider_list is lazy-loaded via __getattr__ to avoid importing LlmProviders at import time
|
||||
|
||||
|
|
@ -1165,6 +1057,9 @@ models_by_provider: dict = {
|
|||
"docker_model_runner": docker_model_runner_models,
|
||||
}
|
||||
|
||||
model_list = list({m for v in models_by_provider.values() for m in v})
|
||||
model_list_set = set(model_list)
|
||||
|
||||
# mapping for those models which have larger equivalents
|
||||
longer_context_model_fallback_dict: dict = {
|
||||
# openai chat completion models
|
||||
|
|
|
|||
|
|
@ -2519,26 +2519,6 @@ def test_get_base_model_from_metadata():
|
|||
|
||||
|
||||
def test_model_list_models_by_provider_in_sync():
|
||||
model_list_set = set(litellm.model_list)
|
||||
all_provider_models: set = set()
|
||||
|
||||
missing_from_model_list = []
|
||||
for provider, models in litellm.models_by_provider.items():
|
||||
model_set = set(models) if isinstance(models, list) else models
|
||||
all_provider_models |= model_set
|
||||
for model in model_set:
|
||||
if model not in model_list_set:
|
||||
missing_from_model_list.append(f"{provider}: {model}")
|
||||
|
||||
assert not missing_from_model_list, (
|
||||
f"{len(missing_from_model_list)} models in models_by_provider are missing from model_list:\n"
|
||||
+ "\n".join(missing_from_model_list[:20])
|
||||
)
|
||||
|
||||
missing_from_providers = [
|
||||
m for m in model_list_set if m not in all_provider_models
|
||||
]
|
||||
assert not missing_from_providers, (
|
||||
f"{len(missing_from_providers)} models in model_list are missing from models_by_provider:\n"
|
||||
+ "\n".join(missing_from_providers[:20])
|
||||
)
|
||||
assert set(litellm.model_list) == {
|
||||
m for v in litellm.models_by_provider.values() for m in v
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue