修复模型添加报数据库字段不存在的 bug

This commit is contained in:
GeekMaster
2025-05-08 09:29:31 +08:00
parent 26c18fcd5a
commit 347b640614
5 changed files with 31 additions and 28 deletions

View File

@@ -40,8 +40,8 @@ func (h *ChatModelHandler) Save(c *gin.Context) {
Power int `json:"power"`
MaxTokens int `json:"max_tokens"` // 最大响应长度
MaxContext int `json:"max_context"` // 最大上下文长度
Description string `json:"description"` //模型描述
Category string `json:"category"` //模型类别
Desc string `json:"desc"` //模型描述
Tag string `json:"tag"` //模型标签
Temperature float32 `json:"temperature"` // 模型温度
KeyId int `json:"key_id,omitempty"`
CreatedAt int64 `json:"created_at"`
@@ -66,8 +66,8 @@ func (h *ChatModelHandler) Save(c *gin.Context) {
item.Power = data.Power
item.MaxTokens = data.MaxTokens
item.MaxContext = data.MaxContext
item.Description = data.Description
item.Category = data.Category
item.Desc = data.Desc
item.Tag = data.Tag
item.Temperature = data.Temperature
item.KeyId = uint(data.KeyId)
item.Type = data.Type
@@ -100,12 +100,16 @@ func (h *ChatModelHandler) List(c *gin.Context) {
session := h.DB.Session(&gorm.Session{})
enable := h.GetBool(c, "enable")
name := h.GetTrim(c, "name")
modelType := h.GetTrim(c, "type")
if enable {
session = session.Where("enabled", enable)
}
if name != "" {
session = session.Where("name LIKE ?", name+"%")
}
if modelType != "" {
session = session.Where("type", modelType)
}
var items []model.ChatModel
var cms = make([]vo.ChatModel, 0)
res := session.Order("sort_num ASC").Find(&items)