mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
test_get_valid_models_with_cli_pattern
This commit is contained in:
parent
fc1c39645a
commit
eb72990aa6
2 changed files with 41 additions and 16 deletions
|
|
@ -21189,6 +21189,30 @@
|
|||
"/v1/audio/transcriptions"
|
||||
]
|
||||
},
|
||||
"vertex_ai/qwen/qwen3-next-80b-a3b-instruct-maas": {
|
||||
"input_cost_per_token": 1.5e-07,
|
||||
"litellm_provider": "vertex_ai-qwen_models",
|
||||
"max_input_tokens": 262144,
|
||||
"max_output_tokens": 262144,
|
||||
"max_tokens": 262144,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 1.2e-06,
|
||||
"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_tool_choice": true
|
||||
},
|
||||
"vertex_ai/qwen/qwen3-next-80b-a3b-thinking-maas": {
|
||||
"input_cost_per_token": 1.5e-07,
|
||||
"litellm_provider": "vertex_ai-qwen_models",
|
||||
"max_input_tokens": 262144,
|
||||
"max_output_tokens": 262144,
|
||||
"max_tokens": 262144,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 1.2e-06,
|
||||
"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_tool_choice": true
|
||||
},
|
||||
"xai/grok-2": {
|
||||
"input_cost_per_token": 2e-06,
|
||||
"litellm_provider": "xai",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from jsonschema import validate
|
||||
|
|
@ -2435,8 +2435,8 @@ class TestGetValidModelsWithCLI:
|
|||
{"id": "claude-3-sonnet", "object": "model"}
|
||||
]
|
||||
}
|
||||
|
||||
with patch('requests.get', return_value=mock_response) as mock_get:
|
||||
|
||||
with patch.object(litellm.module_level_client, "get", return_value=mock_response) as mock_get:
|
||||
# Test the exact pattern used in cli_token_usage.py
|
||||
result = litellm.get_valid_models(
|
||||
check_provider_endpoint=True,
|
||||
|
|
@ -2448,21 +2448,22 @@ class TestGetValidModelsWithCLI:
|
|||
# Verify the function returns a list of model names
|
||||
assert isinstance(result, list)
|
||||
assert len(result) == 4
|
||||
assert "gpt-3.5-turbo" in result
|
||||
assert "gpt-4" in result
|
||||
assert "litellm_proxy/gemini/gemini-2.5-flash" in result
|
||||
assert "claude-3-sonnet" in result
|
||||
# All models get prefixed with "litellm_proxy/" by the get_models method
|
||||
assert "litellm_proxy/gpt-3.5-turbo" in result
|
||||
assert "litellm_proxy/gpt-4" in result
|
||||
# Note: This model already had the prefix, so it gets double-prefixed
|
||||
assert "litellm_proxy/litellm_proxy/gemini/gemini-2.5-flash" in result
|
||||
assert "litellm_proxy/claude-3-sonnet" in result
|
||||
|
||||
# Verify the HTTP request was made with correct parameters
|
||||
mock_get.assert_called_once()
|
||||
call_args = mock_get.call_args
|
||||
|
||||
_, call_kwargs = mock_get.call_args
|
||||
|
||||
# Check that the request was made to the correct endpoint
|
||||
assert "http://localhost:4000/" in call_args[0][0]
|
||||
assert "/v1/models" in call_args[0][0]
|
||||
|
||||
assert call_kwargs["url"].startswith("http://localhost:4000/")
|
||||
assert call_kwargs["url"].endswith("/v1/models")
|
||||
|
||||
# Check that the API key was included in headers
|
||||
assert "headers" in call_args.kwargs
|
||||
headers = call_args.kwargs["headers"]
|
||||
assert "Authorization" in headers
|
||||
assert "Bearer sk-test-cli-key-123" == headers["Authorization"]
|
||||
assert "headers" in call_kwargs
|
||||
headers = call_kwargs["headers"]
|
||||
assert headers.get("Authorization") == "Bearer sk-test-cli-key-123"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue