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

@@ -57,6 +57,36 @@ func (r *CommonResponse) PrintOut() {
}
}
type ModelsResponse struct {
Code int `json:"code"`
Data map[string][]map[string]interface{} `json:"data"`
Message string `json:"message"`
Duration float64
OutputFormat OutputFormat
}
func (r *ModelsResponse) Type() string {
return "models"
}
func (r *ModelsResponse) TimeCost() float64 {
return r.Duration
}
func (r *ModelsResponse) SetOutputFormat(format OutputFormat) {
r.OutputFormat = format
}
func (r *ModelsResponse) PrintOut() {
if r.Code == 0 {
models := r.Data["models"]
PrintTableSimpleByFormat(models, r.OutputFormat)
} else {
fmt.Println("ERROR")
fmt.Printf("%d, %s\n", r.Code, r.Message)
}
}
type CommonDataResponse struct {
Code int `json:"code"`
Data map[string]interface{} `json:"data"`