feat(tools): implement universal tool calling and multi-turn resolution for generic Gradio spaces

This commit is contained in:
Luxferre
2026-09-07 08:24:07 +03:00
parent d3be7d4e80
commit de19bab4eb
3 changed files with 825 additions and 182 deletions
+71 -1
View File
@@ -171,7 +171,7 @@ curl -N http://localhost:8080/v1/chat/completions \
}'
```
### Tool calling
### Tool calling (turn 1)
```bash
curl http://localhost:8080/v1/chat/completions \
@@ -233,6 +233,76 @@ Response:
}
```
### Tool response submission (turn 2)
```bash
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-oss-120b",
"messages": [
{"role": "user", "content": "What is the weather in Tokyo?"},
{
"role": "assistant",
"tool_calls": [
{
"id": "call_3d4c016a",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\":\"Tokyo\"}"
}
}
]
},
{
"role": "tool",
"tool_call_id": "call_3d4c016a",
"content": "{\"temperature\": 20, \"condition\": \"sunny\"}"
}
],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather in a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
}
}
}]
}'
```
Response:
```json
{
"id": "chatcmpl-4903ba12-f12b-4cd3-a801-7290bc91a421",
"object": "chat.completion",
"created": 1788756335,
"model": "openai/gpt-oss-120b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The current weather in Tokyo is sunny with a temperature of 20 °C."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
```
### Dynamic target space override
Override the target space per request without restarting the server: