This commit is contained in:
Liang Ding 2023-03-06 14:07:32 +08:00
parent dd3c011736
commit 3446462184
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
4 changed files with 11 additions and 138 deletions

View file

@ -38,7 +38,7 @@ func chatGPT(c *gin.Context) {
ret.Data = model.ChatGPT(msg)
}
func chatGPTContinueWriteBlocks(c *gin.Context) {
func chatGPTWithAction(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
@ -52,74 +52,6 @@ func chatGPTContinueWriteBlocks(c *gin.Context) {
for _, id := range idsArg {
ids = append(ids, id.(string))
}
ret.Data = model.ChatGPTContinueWriteBlocks(ids)
}
func chatGPTTranslate(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
idsArg := arg["ids"].([]interface{})
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
}
lang := arg["lang"].(string)
ret.Data = model.ChatGPTTranslate(ids, lang)
}
func chatGPTSummary(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
idsArg := arg["ids"].([]interface{})
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
}
ret.Data = model.ChatGPTSummary(ids)
}
func chatGPTBrainStorm(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
idsArg := arg["ids"].([]interface{})
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
}
ret.Data = model.ChatGPTBrainStorm(ids)
}
func chatGPTFixGrammarSpell(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
idsArg := arg["ids"].([]interface{})
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
}
ret.Data = model.ChatGPTFixGrammarSpell(ids)
action := arg["action"].(string)
ret.Data = model.ChatGPTWithAction(ids, action)
}

View file

@ -329,9 +329,5 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/av/renderAttributeView", model.CheckAuth, renderAttributeView)
ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, chatGPT)
ginServer.Handle("POST", "/api/ai/chatGPTContinueWriteBlocks", model.CheckAuth, chatGPTContinueWriteBlocks)
ginServer.Handle("POST", "/api/ai/chatGPTTranslate", model.CheckAuth, chatGPTTranslate)
ginServer.Handle("POST", "/api/ai/chatGPTSummary", model.CheckAuth, chatGPTSummary)
ginServer.Handle("POST", "/api/ai/chatGPTBrainStorm", model.CheckAuth, chatGPTBrainStorm)
ginServer.Handle("POST", "/api/ai/chatGPTFixGrammarSpell", model.CheckAuth, chatGPTFixGrammarSpell)
ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, chatGPTWithAction)
}