fix: 模型列表仅显示已启用渠道中的模型
This commit is contained in:
@@ -207,10 +207,15 @@ func (g *Gateway) Handle(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// models GET /v1/models:返回启用的全局模型(OpenAI 风格)。
|
||||
// models GET /v1/models:返回对外可见的模型(启用且至少绑定到一个启用且健康的渠道;OpenAI 风格)。
|
||||
func (g *Gateway) models(c *gin.Context) {
|
||||
ids := g.ch.AvailableModelIDs()
|
||||
if len(ids) == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"object": "list", "data": []gin.H{}})
|
||||
return
|
||||
}
|
||||
var ms []store.Model
|
||||
if err := g.db.Where("enabled = ?", true).Order("sort ASC, id ASC").Find(&ms).Error; err != nil {
|
||||
if err := g.db.Where("id IN ? AND enabled = ?", ids, true).Order("sort ASC, id ASC").Find(&ms).Error; err != nil {
|
||||
apiError(c, http.StatusInternalServerError, "internal_error", "failed to load models")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user