mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-25 01:02:15 +00:00
Merge pull request #42117 from BerriAI/litellm_migrate_tests_p9
test: migrate phase 9 legacy llm provider tests to tests/unit
This commit is contained in:
commit
9e39c751ed
29 changed files with 0 additions and 204 deletions
0
tests/unit/llms/manus/__init__.py
Normal file
0
tests/unit/llms/manus/__init__.py
Normal file
0
tests/unit/llms/manus/responses/__init__.py
Normal file
0
tests/unit/llms/manus/responses/__init__.py
Normal file
0
tests/unit/llms/minimax/__init__.py
Normal file
0
tests/unit/llms/minimax/__init__.py
Normal file
0
tests/unit/llms/minimax/chat/__init__.py
Normal file
0
tests/unit/llms/minimax/chat/__init__.py
Normal file
|
|
@ -2,14 +2,9 @@
|
|||
Test MiniMax OpenAI-compatible API support
|
||||
"""
|
||||
|
||||
import os
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
import litellm
|
||||
from litellm import completion
|
||||
from litellm.llms.minimax.chat.transformation import MinimaxChatConfig
|
||||
|
||||
|
||||
|
|
@ -107,97 +102,6 @@ def test_minimax_provider_config_manager():
|
|||
assert isinstance(config, MinimaxChatConfig)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Requires actual MiniMax API key")
|
||||
def test_minimax_chat_completion_basic():
|
||||
"""Test basic chat completion with MiniMax OpenAI-compatible API"""
|
||||
response = completion(
|
||||
model="minimax/MiniMax-M2.1",
|
||||
messages=[
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
{"role": "user", "content": "Hello, how are you?"},
|
||||
],
|
||||
api_key=os.getenv("MINIMAX_API_KEY"),
|
||||
api_base="https://api.minimax.io/v1",
|
||||
)
|
||||
|
||||
assert response is not None
|
||||
assert hasattr(response, "choices")
|
||||
assert len(response.choices) > 0
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Requires actual MiniMax API key")
|
||||
def test_minimax_chat_completion_with_reasoning_split():
|
||||
"""Test completion with reasoning_split parameter (MiniMax M2.1 feature)"""
|
||||
response = completion(
|
||||
model="minimax/MiniMax-M2.1",
|
||||
messages=[
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
{"role": "user", "content": "Solve this problem: 2+2=?"},
|
||||
],
|
||||
api_key=os.getenv("MINIMAX_API_KEY"),
|
||||
api_base="https://api.minimax.io/v1",
|
||||
extra_body={"reasoning_split": True},
|
||||
)
|
||||
|
||||
assert response is not None
|
||||
# Check if reasoning_details is present in response
|
||||
if hasattr(response.choices[0].message, "reasoning_details"):
|
||||
assert response.choices[0].message.reasoning_details is not None
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Requires actual MiniMax API key")
|
||||
def test_minimax_chat_completion_with_tools():
|
||||
"""Test completion with tool calling (function calling)"""
|
||||
tools = [
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"description": "Get the current weather in a location",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "string",
|
||||
"description": "The city and state, e.g. San Francisco, CA",
|
||||
}
|
||||
},
|
||||
"required": ["location"],
|
||||
},
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
response = completion(
|
||||
model="minimax/MiniMax-M2.1",
|
||||
messages=[{"role": "user", "content": "What's the weather in San Francisco?"}],
|
||||
tools=tools,
|
||||
api_key=os.getenv("MINIMAX_API_KEY"),
|
||||
api_base="https://api.minimax.io/v1",
|
||||
)
|
||||
|
||||
assert response is not None
|
||||
assert hasattr(response, "choices")
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Requires actual MiniMax API key")
|
||||
def test_minimax_chat_completion_streaming():
|
||||
"""Test streaming completion"""
|
||||
response = completion(
|
||||
model="minimax/MiniMax-M2.1",
|
||||
messages=[{"role": "user", "content": "Count to 5"}],
|
||||
stream=True,
|
||||
api_key=os.getenv("MINIMAX_API_KEY"),
|
||||
api_base="https://api.minimax.io/v1",
|
||||
)
|
||||
|
||||
chunks = []
|
||||
for chunk in response:
|
||||
chunks.append(chunk)
|
||||
|
||||
assert len(chunks) > 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Run basic tests that don't require API key
|
||||
print("Testing MiniMax Chat Config...")
|
||||
0
tests/unit/llms/minimax/messages/__init__.py
Normal file
0
tests/unit/llms/minimax/messages/__init__.py
Normal file
|
|
@ -2,14 +2,9 @@
|
|||
Test MiniMax Anthropic-compatible API support
|
||||
"""
|
||||
|
||||
import os
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
import litellm
|
||||
from litellm import completion
|
||||
from litellm.llms.minimax.messages.transformation import MinimaxMessagesConfig
|
||||
|
||||
|
||||
|
|
@ -58,75 +53,6 @@ def test_minimax_provider_config_manager():
|
|||
assert config.custom_llm_provider == "minimax"
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Requires actual MiniMax API key")
|
||||
def test_minimax_completion_basic():
|
||||
"""Test basic completion with MiniMax Anthropic-compatible API"""
|
||||
response = completion(
|
||||
model="minimax/MiniMax-M2.1",
|
||||
messages=[{"role": "user", "content": "Hello, how are you?"}],
|
||||
api_key=os.getenv("MINIMAX_API_KEY"),
|
||||
api_base="https://api.minimax.io/anthropic/v1/messages",
|
||||
)
|
||||
|
||||
assert response is not None
|
||||
assert hasattr(response, "choices")
|
||||
assert len(response.choices) > 0
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Requires actual MiniMax API key")
|
||||
def test_minimax_completion_with_thinking():
|
||||
"""Test completion with thinking parameter (MiniMax M2.1 feature)"""
|
||||
response = completion(
|
||||
model="minimax/MiniMax-M2.1",
|
||||
messages=[{"role": "user", "content": "Solve this problem: 2+2=?"}],
|
||||
api_key=os.getenv("MINIMAX_API_KEY"),
|
||||
api_base="https://api.minimax.io/anthropic/v1/messages",
|
||||
thinking={"type": "enabled", "budget_tokens": 1000},
|
||||
)
|
||||
|
||||
assert response is not None
|
||||
# Check if thinking content is present in response
|
||||
for choice in response.choices:
|
||||
if hasattr(choice.message, "content"):
|
||||
# MiniMax returns thinking blocks similar to Anthropic
|
||||
assert choice.message.content is not None
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Requires actual MiniMax API key")
|
||||
def test_minimax_completion_with_tools():
|
||||
"""Test completion with tool calling (function calling)"""
|
||||
tools = [
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"description": "Get the current weather in a location",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "string",
|
||||
"description": "The city and state, e.g. San Francisco, CA",
|
||||
}
|
||||
},
|
||||
"required": ["location"],
|
||||
},
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
response = completion(
|
||||
model="minimax/MiniMax-M2.1",
|
||||
messages=[{"role": "user", "content": "What's the weather in San Francisco?"}],
|
||||
tools=tools,
|
||||
api_key=os.getenv("MINIMAX_API_KEY"),
|
||||
api_base="https://api.minimax.io/anthropic/v1/messages",
|
||||
)
|
||||
|
||||
assert response is not None
|
||||
assert hasattr(response, "choices")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Run basic tests that don't require API key
|
||||
print("Testing MiniMax Anthropic Config...")
|
||||
0
tests/unit/llms/mistral/__init__.py
Normal file
0
tests/unit/llms/mistral/__init__.py
Normal file
0
tests/unit/llms/mistral/batches/__init__.py
Normal file
0
tests/unit/llms/mistral/batches/__init__.py
Normal file
0
tests/unit/llms/mistral/files/__init__.py
Normal file
0
tests/unit/llms/mistral/files/__init__.py
Normal file
0
tests/unit/llms/mistral/ocr/__init__.py
Normal file
0
tests/unit/llms/mistral/ocr/__init__.py
Normal file
|
|
@ -19,31 +19,6 @@ from litellm.llms.moonshot.chat.transformation import MoonshotChatConfig
|
|||
class TestMoonshotConfig:
|
||||
"""Test class for Moonshot AI functionality"""
|
||||
|
||||
def test_default_api_base(self):
|
||||
"""Test that default API base is used when none is provided"""
|
||||
config = MoonshotChatConfig()
|
||||
headers = {}
|
||||
api_key = "fake-moonshot-key"
|
||||
|
||||
# Call validate_environment without specifying api_base
|
||||
result = config.validate_environment(
|
||||
headers=headers,
|
||||
model="moonshot-v1-8k",
|
||||
messages=[{"role": "user", "content": "Hey"}],
|
||||
optional_params={},
|
||||
litellm_params={},
|
||||
api_key=api_key,
|
||||
api_base=None, # Not providing api_base
|
||||
)
|
||||
|
||||
# Verify headers are still set correctly
|
||||
assert result["Authorization"] == f"Bearer {api_key}"
|
||||
assert result["Content-Type"] == "application/json"
|
||||
|
||||
# We can't directly test the api_base value here since validate_environment
|
||||
# only returns the headers, but we can verify it doesn't raise an exception
|
||||
# which would happen if api_base handling was incorrect
|
||||
|
||||
def test_get_supported_openai_params(self):
|
||||
"""Test that get_supported_openai_params returns correct params"""
|
||||
config = MoonshotChatConfig()
|
||||
|
|
@ -54,12 +54,3 @@ class TestNovitaConfig:
|
|||
)
|
||||
|
||||
assert "Missing Novita AI API Key" in str(excinfo.value)
|
||||
|
||||
def test_inheritance(self):
|
||||
"""Test proper inheritance from OpenAIGPTConfig"""
|
||||
config = NovitaConfig()
|
||||
|
||||
from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig
|
||||
|
||||
assert isinstance(config, OpenAIGPTConfig)
|
||||
assert hasattr(config, "get_supported_openai_params")
|
||||
Loading…
Add table
Reference in a new issue