mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-05 02:41:56 +00:00
123 lines
3.7 KiB
Python
123 lines
3.7 KiB
Python
"""
|
|
Test MiniMax OpenAI-compatible API support
|
|
"""
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import litellm
|
|
from litellm.llms.minimax.chat.transformation import MinimaxChatConfig
|
|
|
|
|
|
def test_minimax_chat_config():
|
|
"""Test that MinimaxChatConfig is properly configured"""
|
|
config = MinimaxChatConfig()
|
|
|
|
# Test get_api_base default
|
|
api_base = config.get_api_base()
|
|
assert api_base == "https://api.minimax.io/v1"
|
|
|
|
# Test get_api_base with custom value
|
|
custom_base = config.get_api_base(api_base="https://api.minimaxi.com/v1")
|
|
assert custom_base == "https://api.minimaxi.com/v1"
|
|
|
|
# Test get_complete_url
|
|
complete_url = config.get_complete_url(
|
|
api_base="https://api.minimax.io/v1",
|
|
api_key=None,
|
|
model="MiniMax-M2.1",
|
|
optional_params={},
|
|
litellm_params={},
|
|
stream=False,
|
|
)
|
|
assert complete_url == "https://api.minimax.io/v1/chat/completions"
|
|
|
|
|
|
def test_minimax_chat_config_url_variations():
|
|
"""Test URL handling with different base URL formats"""
|
|
config = MinimaxChatConfig()
|
|
|
|
# Test with /v1 ending
|
|
url1 = config.get_complete_url(
|
|
api_base="https://api.minimax.io/v1",
|
|
api_key=None,
|
|
model="MiniMax-M2.1",
|
|
optional_params={},
|
|
litellm_params={},
|
|
)
|
|
assert url1 == "https://api.minimax.io/v1/chat/completions"
|
|
|
|
# Test with trailing slash
|
|
url2 = config.get_complete_url(
|
|
api_base="https://api.minimax.io/",
|
|
api_key=None,
|
|
model="MiniMax-M2.1",
|
|
optional_params={},
|
|
litellm_params={},
|
|
)
|
|
assert url2 == "https://api.minimax.io/v1/chat/completions"
|
|
|
|
# Test without trailing slash
|
|
url3 = config.get_complete_url(
|
|
api_base="https://api.minimax.io",
|
|
api_key=None,
|
|
model="MiniMax-M2.1",
|
|
optional_params={},
|
|
litellm_params={},
|
|
)
|
|
assert url3 == "https://api.minimax.io/v1/chat/completions"
|
|
|
|
# Test with full path already
|
|
url4 = config.get_complete_url(
|
|
api_base="https://api.minimax.io/v1/chat/completions",
|
|
api_key=None,
|
|
model="MiniMax-M2.1",
|
|
optional_params={},
|
|
litellm_params={},
|
|
)
|
|
assert url4 == "https://api.minimax.io/v1/chat/completions"
|
|
|
|
|
|
def test_minimax_provider_routing():
|
|
"""Test that minimax provider is properly routed"""
|
|
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
|
|
|
# Test with minimax/ prefix
|
|
model, provider, api_key, api_base = get_llm_provider(
|
|
model="minimax/MiniMax-M2.1", api_base="https://api.minimax.io/v1"
|
|
)
|
|
assert provider == "minimax"
|
|
assert model == "MiniMax-M2.1"
|
|
|
|
|
|
def test_minimax_provider_config_manager():
|
|
"""Test that ProviderConfigManager returns MinimaxChatConfig"""
|
|
from litellm.types.utils import LlmProviders
|
|
from litellm.utils import ProviderConfigManager
|
|
|
|
config = ProviderConfigManager.get_provider_chat_config(
|
|
model="MiniMax-M2.1", provider=LlmProviders.MINIMAX
|
|
)
|
|
|
|
assert config is not None
|
|
assert isinstance(config, MinimaxChatConfig)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# Run basic tests that don't require API key
|
|
print("Testing MiniMax Chat Config...")
|
|
test_minimax_chat_config()
|
|
print("✓ Config test passed")
|
|
|
|
print("\nTesting MiniMax Chat Config URL Variations...")
|
|
test_minimax_chat_config_url_variations()
|
|
print("✓ URL variations test passed")
|
|
|
|
print("\nTesting MiniMax Provider Routing...")
|
|
test_minimax_provider_routing()
|
|
print("✓ Routing test passed")
|
|
|
|
print("\nTesting MiniMax Provider Config Manager...")
|
|
test_minimax_provider_config_manager()
|
|
print("✓ Provider config manager test passed")
|
|
|
|
print("\n✅ All basic tests passed!")
|