mirror of
https://github.com/cloudstack-llc/mlx-knife.git
synced 2026-07-21 01:55:25 -04:00
57bf6d86be
Major Features Added: • Complete run command implementation with interactive/single-shot modes • MLXRunner core engine ported from 1.x with modular architecture • OpenAI-compatible server with SIGINT-robust supervisor mode • Experimental push feature properly isolated behind environment variable Key Improvements: - Full feature parity with 1.1.1 stable releases - Enhanced human output formatting across all commands - Clean separation of stable (184 tests) vs experimental features - Updated demo GIF showcasing improved 2.0 interface Fixes: - Pull operation cache pollution (Issue #30) with preflight access checks - Test stability improvements across all environments Architecture: - Modular runner design with focused helper modules - Thread-safe model loading and memory management - stable testing across Python 3.9-3.13 Ready for use as comprehensive 1.x alternative.
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""
|
|
Minimal server API tests to keep suite aligned with current code.
|
|
Focus: non-streaming chat completions use chat stop tokens in batch path.
|
|
"""
|
|
|
|
from unittest.mock import Mock, patch
|
|
from fastapi.testclient import TestClient
|
|
|
|
from mlxk2.core.server_base import app
|
|
|
|
|
|
def test_chat_completions_batch_uses_chat_stop_tokens_flag():
|
|
client = TestClient(app)
|
|
|
|
mock_runner = Mock()
|
|
mock_runner.generate_batch.return_value = "Assistant: Hello"
|
|
mock_runner._format_conversation.return_value = "Human: Hi\n\nAssistant:"
|
|
|
|
with patch('mlxk2.core.server_base.get_or_load_model', return_value=mock_runner):
|
|
payload = {
|
|
"model": "test/model",
|
|
"messages": [{"role": "user", "content": "Hi"}],
|
|
"stream": False,
|
|
}
|
|
resp = client.post("/v1/chat/completions", json=payload)
|
|
assert resp.status_code == 200
|
|
|
|
# Ensure server passed use_chat_stop_tokens=True to batch generator
|
|
assert mock_runner.generate_batch.called
|
|
kwargs = mock_runner.generate_batch.call_args.kwargs
|
|
assert kwargs.get("use_chat_stop_tokens") is True
|
|
|