Files
mlx-knife/tests_2.0/test_server_api_minimal.py
The BROKE Cluster Team 57bf6d86be 2.0.0-beta.3: Feature Complete - Full 1.1.1 Parity Achieved
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.
2025-09-14 18:04:18 +02:00

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