mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-14 20:54:30 +08:00
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:
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user