mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-31 13:03:49 +08:00
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:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user