remove platform field for api key and chat model

This commit is contained in:
RockYang
2024-07-30 17:24:21 +08:00
parent 5622f94fc8
commit 4eaa518cf3
12 changed files with 896 additions and 28 deletions

View File

@@ -31,7 +31,6 @@ func NewApiKeyHandler(app *core.AppServer, db *gorm.DB) *ApiKeyHandler {
func (h *ApiKeyHandler) Save(c *gin.Context) {
var data struct {
Id uint `json:"id"`
Platform string `json:"platform"`
Name string `json:"name"`
Type string `json:"type"`
Value string `json:"value"`
@@ -48,7 +47,6 @@ func (h *ApiKeyHandler) Save(c *gin.Context) {
if data.Id > 0 {
h.DB.Find(&apiKey, data.Id)
}
apiKey.Platform = data.Platform
apiKey.Value = data.Value
apiKey.Type = data.Type
apiKey.ApiURL = data.ApiURL

View File

@@ -60,7 +60,6 @@ func (h *ChatModelHandler) Save(c *gin.Context) {
item.Enabled = data.Enabled
item.SortNum = data.SortNum
item.Open = data.Open
item.Platform = data.Platform
item.Power = data.Power
item.MaxTokens = data.MaxTokens
item.MaxContext = data.MaxContext
@@ -69,7 +68,7 @@ func (h *ChatModelHandler) Save(c *gin.Context) {
var res *gorm.DB
if data.Id > 0 {
res = h.DB.Updates(&item)
res = h.DB.Save(&item)
} else {
res = h.DB.Create(&item)
}
@@ -94,12 +93,12 @@ func (h *ChatModelHandler) Save(c *gin.Context) {
func (h *ChatModelHandler) List(c *gin.Context) {
session := h.DB.Session(&gorm.Session{})
enable := h.GetBool(c, "enable")
platform := h.GetTrim(c, "platform")
name := h.GetTrim(c, "name")
if enable {
session = session.Where("enabled", enable)
}
if platform != "" {
session = session.Where("platform", platform)
if name != "" {
session = session.Where("name LIKE ?", name+"%")
}
var items []model.ChatModel
var cms = make([]vo.ChatModel, 0)