Go: show model and list all models (#16272)

### What problem does this PR solve?
```
RAGFlow(admin)> show model 'abc';
+------------+----------------------------------------------------------------+
| field      | value                                                          |
+------------+----------------------------------------------------------------+
| command    | get_model_by_model_name                                        |
| error      | 'get model by model name' is implemented in enterprise edition |
| model_name | abc                                                            |
+------------+----------------------------------------------------------------+

RAGFlow(admin)> list models;
+-----------------+--------------------------------------------------------+
| command         | error                                                  |
+-----------------+--------------------------------------------------------+
| list_all_models | 'list all models' is implemented in enterprise edition |
+-----------------+--------------------------------------------------------+
```

### Type of change

- [x] Refactoring

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-06-23 19:29:06 +08:00
committed by GitHub
parent 49714865c1
commit 4f02ba4cf4
6 changed files with 104 additions and 94 deletions

View File

@@ -1429,20 +1429,20 @@ func (c *CLI) CommonShowModel(cmd *Command) (ResponseIf, error) {
return nil, fmt.Errorf("model_name not provided")
}
payload := map[string]interface{}{
"model_name": modelName,
}
encodedModelName := common.EncodeToBase64(modelName)
var resp *Response
var err error
var httpClient *HTTPClient
switch c.Config.CLIMode {
case AdminMode:
baseURL := fmt.Sprintf("/admin/all-models/%s", encodedModelName)
httpClient = c.AdminServerClient
resp, err = httpClient.Request("GET", "/admin/all-models", "web", nil, payload)
resp, err = httpClient.Request("GET", baseURL, "web", nil, nil)
case APIMode:
baseURL := fmt.Sprintf("/all-models/%s", encodedModelName)
httpClient = c.APIServerClientMap[c.Config.APIClientConfig.CurrentAPIServer]
resp, err = httpClient.Request("GET", "/all-models", "web", nil, payload)
resp, err = httpClient.Request("GET", baseURL, "web", nil, nil)
default:
return nil, fmt.Errorf("invalid server type")
}