浏览代码

添加记录和创建回答返回系统时间

kobe6258 1 月之前
父节点
当前提交
70f0017973
共有 2 个文件被更改,包括 10 次插入1 次删除
  1. 4 0
      controllers/llm/llm_http/response.go
  2. 6 1
      controllers/llm/user_chat_controller.go

+ 4 - 0
controllers/llm/llm_http/response.go

@@ -10,4 +10,8 @@ type UserChatListResp struct {
 type UserChatResp struct {
 	ChatId    int
 	ChatTitle string
+	SendTime  string
+}
+type UserChatAddResp struct {
+	SendTime string
 }

+ 6 - 1
controllers/llm/user_chat_controller.go

@@ -50,6 +50,7 @@ func (ucCtrl *UserChatController) NewChat() {
 	var chatResp = new(llm_http.UserChatResp)
 	chatResp.ChatTitle = req.ChatTitle
 	chatResp.ChatId, err = session.CreateChatSession()
+	chatResp.SendTime = time.Now().Format(utils.FormatDateTime)
 	if err != nil {
 		br.Msg = "创建失败"
 		br.ErrMsg = "创建失败,Err:" + err.Error()
@@ -59,7 +60,7 @@ func (ucCtrl *UserChatController) NewChat() {
 		ChatId:       session.Id,
 		ChatUserType: "user",
 		Content:      req.ChatTitle,
-		SendTime:     time.Now().Format(utils.FormatDateTime),
+		SendTime:     chatResp.SendTime,
 	})
 	br.Data = chatResp
 	br.Ret = 200
@@ -285,6 +286,10 @@ func (ucCtrl *UserChatController) ChatRecordAdd() {
 		br.ErrMsg = "添加聊天记录失败,Err:" + err.Error()
 		return
 	}
+
+	br.Data = llm_http.UserChatAddResp{
+		SendTime: record.SendTime,
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "添加聊天记录成功"