mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
Add MiniMax AI as a built-in LLM supplier alongside existing providers (OpenAI, DeepSeek, Gemini, Kimi, etc.) via OpenAI-compatible API. Changes: - Add MiniMax supplier entry (id=13) in supplier.ts with M2.7, M2.5, M2.5-highspeed models and temperature range [0, 1] - Add MiniMax icon (96x96 PNG) to frontend assets - Add i18n translations for MiniMax in en, zh-CN, ko-KR locales - Add supported LLM providers table to both README files - Add 24 unit tests + 3 integration tests
92 lines
2.9 KiB
Python
92 lines
2.9 KiB
Python
"""
|
|
Integration tests for MiniMax LLM provider in SQLBot.
|
|
|
|
These tests validate that the MiniMax API is reachable and functioning
|
|
correctly via the OpenAI-compatible protocol.
|
|
|
|
Requires MINIMAX_API_KEY environment variable to be set.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import unittest
|
|
|
|
import requests
|
|
|
|
MINIMAX_API_KEY = os.environ.get("MINIMAX_API_KEY", "")
|
|
MINIMAX_BASE_URL = "https://api.minimax.io/v1"
|
|
|
|
|
|
def skip_without_api_key(func):
|
|
"""Skip test if MINIMAX_API_KEY is not set."""
|
|
return unittest.skipUnless(MINIMAX_API_KEY, "MINIMAX_API_KEY not set")(func)
|
|
|
|
|
|
class TestMiniMaxAPIConnectivity(unittest.TestCase):
|
|
"""Test MiniMax API endpoint reachability."""
|
|
|
|
@skip_without_api_key
|
|
def test_api_endpoint_reachable(self):
|
|
"""MiniMax API endpoint should be reachable (chat completions)."""
|
|
resp = requests.post(
|
|
f"{MINIMAX_BASE_URL}/chat/completions",
|
|
headers={
|
|
"Authorization": f"Bearer {MINIMAX_API_KEY}",
|
|
"Content-Type": "application/json",
|
|
},
|
|
json={
|
|
"model": "MiniMax-M2.5-highspeed",
|
|
"messages": [{"role": "user", "content": "Hi"}],
|
|
"max_tokens": 1,
|
|
},
|
|
timeout=15,
|
|
)
|
|
self.assertEqual(resp.status_code, 200)
|
|
|
|
@skip_without_api_key
|
|
def test_chat_completions_basic(self):
|
|
"""MiniMax chat completions should return a valid response."""
|
|
resp = requests.post(
|
|
f"{MINIMAX_BASE_URL}/chat/completions",
|
|
headers={
|
|
"Authorization": f"Bearer {MINIMAX_API_KEY}",
|
|
"Content-Type": "application/json",
|
|
},
|
|
json={
|
|
"model": "MiniMax-M2.5-highspeed",
|
|
"messages": [{"role": "user", "content": "Say hello in one word."}],
|
|
"temperature": 0.7,
|
|
"max_tokens": 10,
|
|
},
|
|
timeout=30,
|
|
)
|
|
self.assertEqual(resp.status_code, 200)
|
|
data = resp.json()
|
|
self.assertIn("choices", data)
|
|
self.assertGreater(len(data["choices"]), 0)
|
|
content = data["choices"][0]["message"]["content"]
|
|
self.assertTrue(len(content) > 0, "Response content should not be empty")
|
|
|
|
@skip_without_api_key
|
|
def test_temperature_zero_accepted(self):
|
|
"""MiniMax API should accept temperature=0."""
|
|
resp = requests.post(
|
|
f"{MINIMAX_BASE_URL}/chat/completions",
|
|
headers={
|
|
"Authorization": f"Bearer {MINIMAX_API_KEY}",
|
|
"Content-Type": "application/json",
|
|
},
|
|
json={
|
|
"model": "MiniMax-M2.5-highspeed",
|
|
"messages": [{"role": "user", "content": "Reply with OK."}],
|
|
"temperature": 0,
|
|
"max_tokens": 5,
|
|
},
|
|
timeout=30,
|
|
)
|
|
self.assertEqual(resp.status_code, 200)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|