Go: refactor model API to accept model id (#15999)

### What problem does this PR solve?

Not not only model_name@instance_name@provider_name is acceptable, but
also model_id is acceptable.

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-06-15 10:10:14 +08:00
committed by GitHub
parent 59d4203947
commit 32d5c0039b
10 changed files with 1307 additions and 1319 deletions

View File

@@ -18,6 +18,7 @@ package cli
import (
"fmt"
"ragflow/internal/common"
"strings"
)
@@ -1301,14 +1302,20 @@ func (p *Parser) parseAdminSetDefault() (*Command, error) {
}
p.nextToken()
compositeModelName, err := p.parseQuotedString()
modelNameOrID, err := p.parseQuotedString()
if err != nil {
return nil, err
}
cmd := NewCommand("set_default_model")
cmd.Params["model_type"] = modelType
cmd.Params["composite_model_name"] = compositeModelName
if common.IsCompositeModelName(modelNameOrID) {
cmd.Params["composite_model_name"] = modelNameOrID
} else if common.IsUUID(modelNameOrID) {
cmd.Params["model_id"] = modelNameOrID
} else {
return nil, fmt.Errorf("invalid format of model name or ID: %s", modelNameOrID)
}
p.nextToken()
// Semicolon is optional for UNSET TOKEN