File size: 1,393 Bytes
0dad616 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | """End-to-end check: call the merged GGUF through llama-server's OpenAI endpoint."""
import json
import sys
import requests
URL = sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:8080/v1/chat/completions"
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"},
"units": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
},
}
]
cases = [
("What's the weather in Paris in celsius?", True),
("What is the capital of France?", False),
]
for q, expect in cases:
r = requests.post(
URL,
json={
"messages": [{"role": "user", "content": q}],
"tools": tools,
"tool_choice": "auto",
"temperature": 0,
"max_tokens": 192,
},
timeout=300,
)
r.raise_for_status()
msg = r.json()["choices"][0]["message"]
calls = msg.get("tool_calls") or []
print(f"\nQ: {q}")
print("expect call:", expect, "| got:", len(calls))
print(json.dumps(calls or msg.get("content", "")[:300], ensure_ascii=False, indent=2))
|