Go: new CLI command, list all models and show model (#15786)

### What problem does this PR solve?

```
RAGFlow(user)> list models;
+---------------------------+------------+-------------+--------------------+---------------------------------------------+
| alias                     | max_tokens | model_types | name               | thinking                                    |
+---------------------------+------------+-------------+--------------------+---------------------------------------------+
|                           | 1048576    | [chat]      | deepseek-v4-flash  | map[clear_thinking:true default_value:true] |
|                           | 1048576    | [chat]      | deepseek-v4-pro    | map[clear_thinking:true default_value:true] |
|                           | 1024000    | [chat]      | minimax-m3         | map[clear_thinking:true default_value:true] |
|                           | 64000      | [vision]    | glm-4.5v           | map[clear_thinking:true default_value:true] |
| [baai/bge-m3]             | 8192       | [embedding] | bge-m3             |                                             |
| [baai/bge-reranker-v2-m3] | 1024       | [rerank]    | bge-reranker-v2-m3 |                                             |
|                           |            | [tts]       | step-audio-tts-3b  |                                             |
| [qwen/qwen3-asr-1.7b]     |            | [asr]       | qwen3-asr-1.7b     |                                             |
| [paddleocr-vl-1.5]        |            | [ocr]       | paddleocr-vl-0.9b  |                                             |
+---------------------------+------------+-------------+--------------------+---------------------------------------------+
RAGFlow(user)> show model 'minimax-m3';
+--------------+---------------------------------------------+
| field        | value                                       |
+--------------+---------------------------------------------+
| name         | minimax-m3                                  |
| max_tokens   | 1024000                                     |
| model_types  | [chat]                                      |
| thinking     | map[clear_thinking:true default_value:true] |
| class        |                                             |
| alias        |                                             |
| ModelTypeMap |                                             |
+--------------+---------------------------------------------+
RAGFlow(user)> show model 'baai/bge-m3';
+--------------+---------------+
| field        | value         |
+--------------+---------------+
| model_types  | [embedding]   |
| thinking     |               |
| class        |               |
| alias        | [baai/bge-m3] |
| ModelTypeMap |               |
| name         | bge-m3        |
| max_tokens   | 8192          |
+--------------+---------------+
```

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-06-08 21:38:15 +08:00
committed by GitHub
parent 35527f6755
commit 55abf4f565
11 changed files with 455 additions and 77 deletions

View File

@@ -368,7 +368,7 @@ func (c *RAGFlowClient) ListSupportedModels(cmd *Command) (ResponseIf, error) {
return &result, nil
}
func (c *RAGFlowClient) ShowModel(cmd *Command) (ResponseIf, error) {
func (c *RAGFlowClient) ShowProviderModel(cmd *Command) (ResponseIf, error) {
providerName, ok := cmd.Params["provider_name"].(string)
if !ok {
return nil, fmt.Errorf("provider_name not provided")
@@ -509,6 +509,76 @@ func (c *RAGFlowClient) ListDefaultModels(cmd *Command) (ResponseIf, error) {
return &result, nil
}
func (c *RAGFlowClient) ListAllModels(cmd *Command) (ResponseIf, error) {
page, ok := cmd.Params["page"].(int)
if !ok {
page = 0
}
pageSize, ok := cmd.Params["page_size"].(int)
if !ok {
pageSize = 0
}
payload := map[string]interface{}{
"page": page,
"page_size": pageSize,
}
resp, err := c.HTTPClient.Request("GET", "/all-models", "web", nil, payload)
if err != nil {
return nil, fmt.Errorf("failed to list all models: %w", err)
}
if resp.StatusCode != 200 {
return nil, fmt.Errorf("failed to list all models: HTTP %d, body: %s", resp.StatusCode, string(resp.Body))
}
var result CommonResponse
if err = json.Unmarshal(resp.Body, &result); err != nil {
return nil, fmt.Errorf("failed to list all models: invalid JSON (%w)", err)
}
if result.Code != 0 {
return nil, fmt.Errorf("%s", result.Message)
}
result.Duration = resp.Duration
return &result, nil
}
func (c *RAGFlowClient) ShowModel(cmd *Command) (ResponseIf, error) {
modelName, ok := cmd.Params["model_name"].(string)
if !ok {
return nil, fmt.Errorf("model_name not provided")
}
payload := map[string]interface{}{
"model_name": modelName,
}
resp, err := c.HTTPClient.Request("GET", "/all-models", "web", nil, payload)
if err != nil {
return nil, fmt.Errorf("failed to show model: %w", err)
}
if resp.StatusCode != 200 {
return nil, fmt.Errorf("failed to show model: HTTP %d, body: %s", resp.StatusCode, string(resp.Body))
}
var result CommonDataResponse
if err = json.Unmarshal(resp.Body, &result); err != nil {
return nil, fmt.Errorf("failed to show model: invalid JSON (%w)", err)
}
if result.Code != 0 {
return nil, fmt.Errorf("%s", result.Message)
}
result.Duration = resp.Duration
return &result, nil
}
// readPassword reads password from terminal without echoing
func ReadPassword() (string, error) {
if !term.IsTerminal(int(os.Stdin.Fd())) {