Model config: add tools (#16371)

### What problem does this PR solve?

```
{
      "name": "glm-4-flash",
      "max_tokens": 128000,
      "model_types": [
        "chat"
      ],
      "tools": {
        "support": true
      }
}
```

```
RAGFlow(admin)> list provider 'zhipu-ai' models;
+------------+---------------+------------+---------------+----------------+-----------+-----------+
| dimensions | max_dimension | max_tokens | model_type    | name           | thinking  | tools     |
+------------+---------------+------------+---------------+----------------+-----------+-----------+
|            |               | 204800     | [chat]        | glm-5          | supported | supported |
|            |               | 204800     | [chat]        | glm-5-turbo    | supported | supported |
```

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-06-26 11:37:51 +08:00
committed by GitHub
parent 70250ec88c
commit 65afaa1292
3 changed files with 113 additions and 12 deletions

View File

@@ -153,12 +153,17 @@ type ModelThinking struct {
ClearThinking bool `json:"clear_thinking"`
}
type ModelTools struct {
Support bool `json:"support"`
}
// Model represents a single LLM model
type Model struct {
Name string `json:"name"`
MaxTokens *int `json:"max_tokens"`
ModelTypes []string `json:"model_types"`
Thinking *ModelThinking `json:"thinking"`
Tools *ModelTools `json:"tools"`
Class *string `json:"class"`
MaxDimension *int `json:"max_dimension"` // used by embedding models
Dimensions []int `json:"dimensions"`
@@ -406,6 +411,12 @@ func (pm *ProviderManager) ListAllModels() ([]map[string]interface{}, error) {
if len(model.Dimensions) > 0 {
modelData["dimensions"] = model.Dimensions
}
if model.Thinking != nil {
modelData["thinking"] = "supported"
}
if model.Tools != nil {
modelData["tools"] = "supported"
}
modelList = append(modelList, modelData)
}
@@ -473,6 +484,12 @@ func (pm *ProviderManager) ListModels(providerName string) ([]map[string]interfa
"max_dimension": model.MaxDimension,
"dimensions": model.Dimensions,
}
if model.Thinking != nil {
modelData["thinking"] = "supported"
}
if model.Tools != nil {
modelData["tools"] = "supported"
}
modelList = append(modelList, modelData)
}