mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-12 06:42:11 +02:00
feat: add MiniMax as LLM text completion provider
- Add MiniMax chat model provider using OpenAI-compatible API - Support MiniMax-M2.7 and MiniMax-M2.7-highspeed models - Temperature clamping to MiniMax valid range (0.0, 1.0] - Streaming support with token usage tracking - MINIMAX_API_KEY environment variable support - Add text-completion-minimax entry point - Add 15 unit tests and 3 integration tests - Update README with MiniMax in LLM APIs list
This commit is contained in:
parent
d30857b5c3
commit
50f24b8e2a
8 changed files with 960 additions and 4 deletions
86
tests/integration/test_minimax_integration.py
Normal file
86
tests/integration/test_minimax_integration.py
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
"""
|
||||
Integration tests for MiniMax text completion provider.
|
||||
Tests actual API calls to MiniMax when MINIMAX_API_KEY is available.
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
from openai import OpenAI
|
||||
|
||||
MINIMAX_API_KEY = os.getenv("MINIMAX_API_KEY")
|
||||
MINIMAX_BASE_URL = "https://api.minimax.io/v1"
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not MINIMAX_API_KEY,
|
||||
reason="MINIMAX_API_KEY not set"
|
||||
)
|
||||
class TestMiniMaxIntegration:
|
||||
"""Integration tests that call the real MiniMax API"""
|
||||
|
||||
def get_client(self):
|
||||
return OpenAI(api_key=MINIMAX_API_KEY, base_url=MINIMAX_BASE_URL)
|
||||
|
||||
def test_basic_chat_completion(self):
|
||||
"""Test basic chat completion with MiniMax-M2.7"""
|
||||
client = self.get_client()
|
||||
|
||||
resp = client.chat.completions.create(
|
||||
model="MiniMax-M2.7",
|
||||
messages=[{
|
||||
"role": "user",
|
||||
"content": 'Say "test passed" and nothing else.'
|
||||
}],
|
||||
temperature=1.0,
|
||||
max_tokens=64,
|
||||
)
|
||||
|
||||
assert resp.choices[0].message.content is not None
|
||||
assert len(resp.choices[0].message.content) > 0
|
||||
assert resp.usage.prompt_tokens > 0
|
||||
assert resp.usage.completion_tokens > 0
|
||||
|
||||
def test_highspeed_model(self):
|
||||
"""Test chat completion with MiniMax-M2.7-highspeed"""
|
||||
client = self.get_client()
|
||||
|
||||
resp = client.chat.completions.create(
|
||||
model="MiniMax-M2.7-highspeed",
|
||||
messages=[{
|
||||
"role": "user",
|
||||
"content": 'Say "highspeed test passed" and nothing else.'
|
||||
}],
|
||||
temperature=1.0,
|
||||
max_tokens=64,
|
||||
)
|
||||
|
||||
assert resp.choices[0].message.content is not None
|
||||
assert len(resp.choices[0].message.content) > 0
|
||||
|
||||
def test_streaming_completion(self):
|
||||
"""Test streaming chat completion"""
|
||||
client = self.get_client()
|
||||
|
||||
response = client.chat.completions.create(
|
||||
model="MiniMax-M2.7",
|
||||
messages=[{
|
||||
"role": "user",
|
||||
"content": 'Say "stream test passed" and nothing else.'
|
||||
}],
|
||||
temperature=1.0,
|
||||
max_tokens=64,
|
||||
stream=True,
|
||||
stream_options={"include_usage": True}
|
||||
)
|
||||
|
||||
chunks = list(response)
|
||||
assert len(chunks) > 0
|
||||
|
||||
# Collect text from chunks
|
||||
texts = []
|
||||
for chunk in chunks:
|
||||
if chunk.choices and chunk.choices[0].delta.content:
|
||||
texts.append(chunk.choices[0].delta.content)
|
||||
|
||||
full_text = "".join(texts)
|
||||
assert len(full_text) > 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue