호환성 test harness·pythonimport httpx, json, time
def test_compat(base_url: str, model: str, label: str = ""):
print(f"\n=== {label or base_url} ===")
client_kwargs = {"timeout": 120.0}
# 1. Non-streaming
r = httpx.post(f"{base_url}/chat/completions", json={
"model": model,
"messages": [{"role": "user", "content": "Say 'ok' and nothing else."}],
"stream": False,
}, **client_kwargs)
print(f"1. non-stream: {'PASS' if r.status_code == 200 else 'FAIL'}")
# 2. Streaming
with httpx.stream("POST", f"{base_url}/chat/completions", json={
"model": model,
"messages": [{"role": "user", "content": "Count: 1 2 3"}],
"stream": True,
}, timeout=None) as r2:
got_chunks = sum(1 for line in r2.iter_lines() if line.startswith("data:"))
print(f"2. stream: {'PASS' if got_chunks > 1 else 'FAIL'} ({got_chunks} chunks)")
# 3. Tool call
tools = [{"type": "function", "function": {
"name": "say_ok", "description": "Reply with 'ok'.",
"parameters": {"type": "object", "properties": {}, "required": []},
}}]
r3 = httpx.post(f"{base_url}/chat/completions", json={
"model": model,
"messages": [{"role": "user", "content": "Use the say_ok tool."}],
"tools": tools, "stream": False,
}, **client_kwargs)
has_tools = bool(r3.json().get("choices", [{}])[0].get("message", {}).get("tool_calls"))
print(f"3. tool_call: {'PASS' if has_tools else 'FAIL'}")
# 여러 engine에 돌려
test_compat("http://localhost:11434/v1", "qwen2.5:7b", label="Ollama")
test_compat("http://localhost:8080/v1", "qwen-direct", label="llama-server")
# test_compat("http://localhost:8000/v1", "Qwen/Qwen2.5-7B-Instruct", label="vLLM")