mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-11 11:43:43 +08:00
后台管理功能已完成
This commit is contained in:
@@ -18,25 +18,27 @@ func (s *Server) TestHandle(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func (s *Server) ConfigGetHandle(c *gin.Context) {
|
||||
func (s *Server) ConfigGetHandle(c *gin.Context) {
|
||||
data := struct {
|
||||
Title string `json:"title"`
|
||||
ConsoleTitle string `json:"console_title"`
|
||||
ProxyURL string `json:"proxy_url"`
|
||||
Model string `json:"model"`
|
||||
Temperature float32 `json:"temperature"`
|
||||
MaxTokens int `json:"max_tokens"`
|
||||
ChatContextExpireTime int `json:"chat_context_expire_time"`
|
||||
EnableContext bool `json:"enable_context"`
|
||||
Title string `json:"title"`
|
||||
ConsoleTitle string `json:"console_title"`
|
||||
ProxyURL string `json:"proxy_url"`
|
||||
Model string `json:"model"`
|
||||
Temperature float32 `json:"temperature"`
|
||||
MaxTokens int `json:"max_tokens"`
|
||||
ChatContextExpireTime int `json:"chat_context_expire_time"`
|
||||
EnableContext bool `json:"enable_context"`
|
||||
ImgURL types.ImgURL `json:"img_url"`
|
||||
}{
|
||||
Title: s.Config.Title,
|
||||
ConsoleTitle: s.Config.ConsoleTitle,
|
||||
ProxyURL: strings.Join(s.Config.ProxyURL, ","),
|
||||
Model: s.Config.Chat.Model,
|
||||
Temperature: s.Config.Chat.Temperature,
|
||||
MaxTokens: s.Config.Chat.MaxTokens,
|
||||
EnableContext: s.Config.Chat.EnableContext,
|
||||
Title: s.Config.Title,
|
||||
ConsoleTitle: s.Config.ConsoleTitle,
|
||||
ProxyURL: strings.Join(s.Config.ProxyURL, ","),
|
||||
Model: s.Config.Chat.Model,
|
||||
Temperature: s.Config.Chat.Temperature,
|
||||
MaxTokens: s.Config.Chat.MaxTokens,
|
||||
EnableContext: s.Config.Chat.EnableContext,
|
||||
ChatContextExpireTime: s.Config.Chat.ChatContextExpireTime,
|
||||
ImgURL: s.Config.ImgURL,
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, types.BizVo{Code: types.Success, Data: data})
|
||||
@@ -45,14 +47,15 @@ func (s *Server) ConfigGetHandle(c *gin.Context) {
|
||||
// ConfigSetHandle set configs
|
||||
func (s *Server) ConfigSetHandle(c *gin.Context) {
|
||||
var data struct {
|
||||
Title string `json:"title"`
|
||||
ConsoleTitle string `json:"console_title"`
|
||||
ProxyURL string `json:"proxy_url"`
|
||||
Model string `json:"model"`
|
||||
Temperature float32 `json:"temperature"`
|
||||
MaxTokens int `json:"max_tokens"`
|
||||
ChatContextExpireTime int `json:"chat_context_expire_time"`
|
||||
EnableContext bool `json:"enable_context"`
|
||||
Title string `json:"title"`
|
||||
ConsoleTitle string `json:"console_title"`
|
||||
ProxyURL string `json:"proxy_url"`
|
||||
Model string `json:"model"`
|
||||
Temperature float32 `json:"temperature"`
|
||||
MaxTokens int `json:"max_tokens"`
|
||||
ChatContextExpireTime int `json:"chat_context_expire_time"`
|
||||
EnableContext bool `json:"enable_context"`
|
||||
ImgURL types.ImgURL `json:"img_url"`
|
||||
}
|
||||
err := json.NewDecoder(c.Request.Body).Decode(&data)
|
||||
if err != nil {
|
||||
@@ -63,12 +66,17 @@ func (s *Server) ConfigSetHandle(c *gin.Context) {
|
||||
|
||||
s.Config.Title = data.Title
|
||||
s.Config.ConsoleTitle = data.ConsoleTitle
|
||||
s.Config.ProxyURL = strings.Split(data.ProxyURL, ",")
|
||||
urls := strings.Split(data.ProxyURL, ",")
|
||||
for k, v := range urls {
|
||||
urls[k] = strings.TrimSpace(v)
|
||||
}
|
||||
s.Config.ProxyURL = urls
|
||||
s.Config.Chat.Model = data.Model
|
||||
s.Config.Chat.Temperature = data.Temperature
|
||||
s.Config.Chat.MaxTokens = data.MaxTokens
|
||||
s.Config.Chat.EnableContext = data.EnableContext
|
||||
s.Config.Chat.ChatContextExpireTime = data.ChatContextExpireTime
|
||||
s.Config.ImgURL = data.ImgURL
|
||||
|
||||
// 保存配置文件
|
||||
err = utils.SaveConfig(s.Config, s.ConfigPath)
|
||||
|
||||
Reference in New Issue
Block a user