"""Quick smoke test: plain chat + native tool-calling against the Space.""" import json import requests BASE = "https://Leon4gr45-fable5-inference.hf.space" # 1) plain chat r = requests.post(f"{BASE}/v1/chat/completions", json={ "model": "qwythos-9b", "messages": [{"role": "user", "content": "Hello, how are you?"}], "max_tokens": 64, }) print("CHAT:", json.dumps(r.json(), indent=2)[:600]) # 2) native function/tool calling tools = [{ "type": "function", "function": { "name": "get_weather", "description": "Get current weather for a city", "parameters": { "type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"], }, }, }] r = requests.post(f"{BASE}/v1/chat/completions", json={ "model": "qwythos-9b", "messages": [{"role": "user", "content": "What's the weather in Paris? Use the tool."}], "tools": tools, "tool_choice": "auto", "max_tokens": 128, }) msg = r.json()["choices"][0]["message"] print("TOOL_CALLS:", json.dumps(msg.get("tool_calls"), indent=2))