Skip to content

Commit de6b08e

Browse files
committed
test_supports_tool_choice
1 parent 3fc2198 commit de6b08e

File tree

1 file changed

+0
-70
lines changed

1 file changed

+0
-70
lines changed

tests/test_litellm/test_utils.py

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -810,76 +810,6 @@ def test_check_provider_match():
810810
print("block_list", block_list)
811811

812812

813-
@pytest.mark.asyncio
814-
async def test_supports_tool_choice():
815-
"""
816-
Test that litellm.utils.supports_tool_choice() returns the correct value
817-
for all models in model_prices_and_context_window.json.
818-
819-
The test:
820-
1. Loads model pricing data
821-
2. Iterates through each model
822-
3. Checks if tool_choice support matches the model's supported parameters
823-
"""
824-
# Load model prices
825-
litellm._turn_on_debug()
826-
# path = "../../model_prices_and_context_window.json"
827-
path = "./model_prices_and_context_window.json"
828-
with open(path, "r") as f:
829-
model_prices = json.load(f)
830-
litellm.model_cost = model_prices
831-
config_manager = ProviderConfigManager()
832-
833-
for model_name, model_info in model_prices.items():
834-
print(f"testing model: {model_name}")
835-
836-
# Skip certain models
837-
if (
838-
model_name == "sample_spec"
839-
or model_info.get("mode") != "chat"
840-
or any(skip in model_name for skip in SKIP_MODELS)
841-
or any(provider in model_name for provider in OLD_PROVIDERS)
842-
or model_info["litellm_provider"] in OLD_PROVIDERS
843-
or model_name in block_list
844-
or "azure/eu" in model_name
845-
or "azure/us" in model_name
846-
or "codestral" in model_name
847-
or "o1" in model_name
848-
or "o3" in model_name
849-
or "mistral" in model_name
850-
or "oci" in model_name
851-
or "openrouter" in model_name
852-
):
853-
continue
854-
855-
try:
856-
model, provider, _, _ = get_llm_provider(model=model_name)
857-
except Exception as e:
858-
print(f"\033[91mERROR for {model_name}: {e}\033[0m")
859-
continue
860-
861-
# Get provider config and supported params
862-
print("LLM provider", provider)
863-
provider_enum = LlmProviders(provider)
864-
config = config_manager.get_provider_chat_config(model, provider_enum)
865-
print("config", config)
866-
867-
if config:
868-
supported_params = config.get_supported_openai_params(model)
869-
print("supported_params", supported_params)
870-
else:
871-
raise Exception(f"No config found for {model_name}, provider: {provider}")
872-
873-
# Check tool_choice support
874-
supports_tool_choice_result = litellm.utils.supports_tool_choice(
875-
model=model_name, custom_llm_provider=provider
876-
)
877-
tool_choice_in_params = "tool_choice" in supported_params
878-
879-
assert (
880-
supports_tool_choice_result == tool_choice_in_params
881-
), f"Tool choice support mismatch for {model_name}. supports_tool_choice() returned: {supports_tool_choice_result}, tool_choice in supported params: {tool_choice_in_params}\nConfig: {config}"
882-
883813

884814
def test_supports_computer_use_utility():
885815
"""

0 commit comments

Comments
 (0)