"""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))