File size: 1,102 Bytes
e24791f
c5c5d80
e24791f
c5c5d80
c7271de
c5c5d80
e24791f
 
c7271de
e24791f
 
 
 
c5c5d80
e24791f
 
 
 
 
 
 
 
 
 
 
 
 
 
c7271de
e24791f
 
 
 
 
 
 
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
"""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))