Myric commited on
Commit
82a9b4b
·
verified ·
1 Parent(s): 14f43e7

Upload TOOL_CALLING.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. TOOL_CALLING.md +152 -0
TOOL_CALLING.md ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Tool calling with these APEX quants (reproducible)
2
+
3
+ Captured against the `IQ3_XXS` quant. Turn 2 depends on turn 1's result (a chained call, not a one-off), and a distractor tool (`search_web`) is offered but correctly never called.
4
+
5
+ ## Server
6
+
7
+ ```bash
8
+ llama-server --jinja --ctx-size 8192 -fa on --temp 0.6 --top-p 0.9 --repeat-penalty 1.05 --model <this-quant>.gguf --host 127.0.0.1 --port 8092
9
+ ```
10
+
11
+ (this GGUF carries its own chat template, so `--jinja` alone is enough — no `--chat-template-file` needed.)
12
+
13
+ ## System prompt
14
+
15
+ ```
16
+ You are a helpful assistant with access to tools. When a tool is needed, call it; when it returns a result, answer the user directly using that result.
17
+ ```
18
+
19
+ ## Tools offered
20
+
21
+ ```json
22
+ [
23
+ {
24
+ "type": "function",
25
+ "function": {
26
+ "name": "get_user_location",
27
+ "description": "Get the user's current city.",
28
+ "parameters": {
29
+ "type": "object",
30
+ "properties": {}
31
+ }
32
+ }
33
+ },
34
+ {
35
+ "type": "function",
36
+ "function": {
37
+ "name": "get_weather",
38
+ "description": "Get the current weather for a location.",
39
+ "parameters": {
40
+ "type": "object",
41
+ "properties": {
42
+ "location": {
43
+ "type": "string",
44
+ "description": "City name"
45
+ },
46
+ "unit": {
47
+ "type": "string",
48
+ "enum": [
49
+ "celsius",
50
+ "fahrenheit"
51
+ ]
52
+ }
53
+ },
54
+ "required": [
55
+ "location"
56
+ ]
57
+ }
58
+ }
59
+ },
60
+ {
61
+ "type": "function",
62
+ "function": {
63
+ "name": "search_web",
64
+ "description": "Search the web for a query.",
65
+ "parameters": {
66
+ "type": "object",
67
+ "properties": {
68
+ "query": {
69
+ "type": "string"
70
+ }
71
+ },
72
+ "required": [
73
+ "query"
74
+ ]
75
+ }
76
+ }
77
+ }
78
+ ]
79
+ ```
80
+
81
+ ## Conversation
82
+
83
+ **User:** What is the weather at my current location? Use celsius.
84
+
85
+ **Turn 1:** LLM sent properly formatted JSON to the test server
86
+
87
+ <details><summary>raw response JSON</summary>
88
+
89
+ ```json
90
+ {
91
+ "role": "assistant",
92
+ "content": "",
93
+ "reasoning_content": "I need to get the user's current location first, and then get the weather for that location in celsius. Let me start by getting the user's location.\n",
94
+ "tool_calls": [
95
+ {
96
+ "type": "function",
97
+ "function": {
98
+ "name": "get_user_location",
99
+ "arguments": "{}"
100
+ },
101
+ "id": "ubllaF0cqjmv496J8GurXOhRxQ1X0VDw"
102
+ }
103
+ ]
104
+ }
105
+ ```
106
+
107
+ </details>
108
+
109
+ **Tool result (`get_user_location`):** `{"city": "Tokyo"}`
110
+
111
+ **Turn 2:** LLM sent properly formatted JSON to the test server
112
+
113
+ <details><summary>raw response JSON</summary>
114
+
115
+ ```json
116
+ {
117
+ "role": "assistant",
118
+ "content": "",
119
+ "reasoning_content": "Now I have the user's location: Tokyo. Let me get the weather for Tokyo in celsius.\n",
120
+ "tool_calls": [
121
+ {
122
+ "type": "function",
123
+ "function": {
124
+ "name": "get_weather",
125
+ "arguments": "{\"location\":\"Tokyo\",\"unit\":\"celsius\"}"
126
+ },
127
+ "id": "9LZjmuRGczb44iPrUACoU9LIqQDdK4Op"
128
+ }
129
+ ]
130
+ }
131
+ ```
132
+
133
+ </details>
134
+
135
+ **Tool result (`get_weather`):** `{"temp_c": 18, "conditions": "cloudy"}`
136
+
137
+ **Turn 3:** LLM correctly gave a plain-language final answer, no further tool call
138
+
139
+ > The weather at your current location (Tokyo) is **18°C** and **cloudy**.
140
+
141
+ <details><summary>raw response JSON</summary>
142
+
143
+ ```json
144
+ {
145
+ "role": "assistant",
146
+ "content": "The weather at your current location (Tokyo) is **18\u00b0C** and **cloudy**.",
147
+ "reasoning_content": "I got the weather for Tokyo. The temperature is 18\u00b0C and it's cloudy. Let me provide this information to the user.\n"
148
+ }
149
+ ```
150
+
151
+ </details>
152
+