Add extra field to model instance (#14203)

### What problem does this PR solve?

Now each model support region with different URL

### 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-04-20 15:31:12 +08:00
committed by GitHub
parent 939933649a
commit af2ed416a7
22 changed files with 398 additions and 550 deletions

View File

@@ -1187,35 +1187,36 @@ func (p *Parser) parseAdminSetVariable() (*Command, error) {
func (p *Parser) parseAdminSetDefault() (*Command, error) {
p.nextToken() // consume DEFAULT
var modelType, modelID string
var modelType string
switch p.curToken.Type {
case TokenLLM:
modelType = "llm_id"
case TokenVLM:
modelType = "img2txt_id"
case TokenChat:
modelType = "chat"
case TokenVision:
modelType = "vision"
case TokenEmbedding:
modelType = "embd_id"
case TokenReranker:
modelType = "reranker_id"
modelType = "embedding"
case TokenRerank:
modelType = "rerank"
case TokenASR:
modelType = "asr_id"
modelType = "asr"
case TokenTTS:
modelType = "tts_id"
modelType = "tts"
case TokenOCR:
modelType = "ocr"
default:
return nil, fmt.Errorf("unknown model type: %s", p.curToken.Value)
}
p.nextToken()
id, err := p.parseQuotedString()
compositeModelName, err := p.parseQuotedString()
if err != nil {
return nil, err
}
modelID = id
cmd := NewCommand("set_default_model")
cmd.Params["model_type"] = modelType
cmd.Params["model_id"] = modelID
cmd.Params["composite_model_name"] = compositeModelName
p.nextToken()
// Semicolon is optional for UNSET TOKEN
@@ -1254,18 +1255,20 @@ func (p *Parser) parseAdminResetCommand() (*Command, error) {
var modelType string
switch p.curToken.Type {
case TokenLLM:
modelType = "llm_id"
case TokenVLM:
modelType = "img2txt_id"
case TokenChat:
modelType = "chat"
case TokenVision:
modelType = "vision"
case TokenEmbedding:
modelType = "embd_id"
case TokenReranker:
modelType = "reranker_id"
modelType = "embedding"
case TokenRerank:
modelType = "rerank"
case TokenASR:
modelType = "asr_id"
modelType = "asr"
case TokenTTS:
modelType = "tts_id"
modelType = "tts"
case TokenOCR:
modelType = "ocr"
default:
return nil, fmt.Errorf("unknown model type: %s", p.curToken.Value)
}