|
@@ -1066,6 +1066,9 @@ func (this *AiController) GenerateAiSummary() {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
historyList, err := aimod.GetAiChatList(req.AiChatTopicId)
|
|
@@ -1074,6 +1077,7 @@ func (this *AiController) GenerateAiSummary() {
|
|
|
br.ErrMsg = "获取主题历史数据失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
historyChatList := make([]aimod.HistoryChat, 0)
|
|
|
for _, v := range historyList {
|
|
|
historyChat := new(aimod.HistoryChat)
|
|
@@ -1093,34 +1097,54 @@ func (this *AiController) GenerateAiSummary() {
|
|
|
resp.Answer = answer
|
|
|
resp.Model = req.Model
|
|
|
|
|
|
- topic := new(aimod.AiChatTopic)
|
|
|
- topic.TopicName = ask
|
|
|
- topic.SysUserId = this.SysUser.AdminId
|
|
|
- topic.SysUserRealName = this.SysUser.RealName
|
|
|
- topic.CreateTime = time.Now()
|
|
|
- topic.ModifyTime = time.Now()
|
|
|
- topicId, err := aimod.AddAiChatTopic(topic)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取数据失败!"
|
|
|
- br.ErrMsg = "生成话题失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- resp.AiChatTopicId = int(topicId)
|
|
|
- chatItem := new(aimod.AiChat)
|
|
|
- chatItem.AiChatTopicId = resp.AiChatTopicId
|
|
|
- chatItem.Ask = ask
|
|
|
- chatItem.AskUuid = utils.MD5(ask)
|
|
|
- chatItem.Answer = answer
|
|
|
- chatItem.Model = EnabledModelsForMap[req.Model]
|
|
|
- chatItem.SysUserId = this.SysUser.AdminId
|
|
|
- chatItem.SysUserRealName = this.SysUser.RealName
|
|
|
- chatItem.CreateTime = time.Now()
|
|
|
- chatItem.ModifyTime = time.Now()
|
|
|
- _, err = aimod.AddAiChat(chatItem)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取数据失败!"
|
|
|
- br.ErrMsg = "生成话题记录失败,Err:" + err.Error()
|
|
|
- return
|
|
|
+ if req.AiChatTopicId <= 0 {
|
|
|
+ topic := new(aimod.AiChatTopic)
|
|
|
+ topic.TopicName = ask
|
|
|
+ topic.SysUserId = this.SysUser.AdminId
|
|
|
+ topic.SysUserRealName = this.SysUser.RealName
|
|
|
+ topic.CreateTime = time.Now()
|
|
|
+ topic.ModifyTime = time.Now()
|
|
|
+ topicId, err := aimod.AddAiChatTopic(topic)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败!"
|
|
|
+ br.ErrMsg = "生成话题失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.AiChatTopicId = int(topicId)
|
|
|
+ chatItem := new(aimod.AiChat)
|
|
|
+ chatItem.AiChatTopicId = resp.AiChatTopicId
|
|
|
+ chatItem.Ask = ask
|
|
|
+ chatItem.AskUuid = utils.MD5(ask)
|
|
|
+ chatItem.Answer = answer
|
|
|
+ chatItem.Model = EnabledModelsForMap[req.Model]
|
|
|
+ chatItem.SysUserId = this.SysUser.AdminId
|
|
|
+ chatItem.SysUserRealName = this.SysUser.RealName
|
|
|
+ chatItem.CreateTime = time.Now()
|
|
|
+ chatItem.ModifyTime = time.Now()
|
|
|
+ _, err = aimod.AddAiChat(chatItem)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败!"
|
|
|
+ br.ErrMsg = "生成话题记录失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ resp.AiChatTopicId = req.AiChatTopicId
|
|
|
+ chatItem := new(aimod.AiChat)
|
|
|
+ chatItem.AiChatTopicId = resp.AiChatTopicId
|
|
|
+ chatItem.Ask = ask
|
|
|
+ chatItem.AskUuid = utils.MD5(ask)
|
|
|
+ chatItem.Answer = answer
|
|
|
+ chatItem.Model = EnabledModelsForMap[req.Model]
|
|
|
+ chatItem.SysUserId = this.SysUser.AdminId
|
|
|
+ chatItem.SysUserRealName = this.SysUser.RealName
|
|
|
+ chatItem.CreateTime = time.Now()
|
|
|
+ chatItem.ModifyTime = time.Now()
|
|
|
+ _, err = aimod.AddAiChat(chatItem)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败!"
|
|
|
+ br.ErrMsg = "生成话题记录失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
} else if len(req.OpenaiFileId) > 0 {
|