kobe6258 1 month ago
parent
commit
aa29b7af12
1 changed files with 13 additions and 12 deletions
  1. 13 12
      services/llm/chat_service.go

+ 13 - 12
services/llm/chat_service.go

@@ -129,19 +129,20 @@ func SaveChatRecordsToDB(chatId int) error {
 	}
 	var newRecords []*llm.UserChatRecord
 	for _, record := range list {
-		//if record.Id == 0 {
-		sendTime, parseErr := time.Parse(utils.FormatDateTime, record.SendTime)
-		if parseErr != nil {
-			sendTime = time.Now()
+		if record.Id == 0 {
+			sendTime, parseErr := time.Parse(utils.FormatDateTime, record.SendTime)
+			if parseErr != nil {
+				sendTime = time.Now()
+			}
+			newRecords = append(newRecords, &llm.UserChatRecord{
+				Id:           record.Id,
+				ChatId:       record.ChatId,
+				ChatUserType: record.ChatUserType,
+				Content:      record.Content,
+				SendTime:     sendTime,
+				CreatedTime:  time.Now(),
+			})
 		}
-		newRecords = append(newRecords, &llm.UserChatRecord{
-			ChatId:       record.ChatId,
-			ChatUserType: record.ChatUserType,
-			Content:      record.Content,
-			SendTime:     sendTime,
-			CreatedTime:  time.Now(),
-		})
-		//}
 	}
 	key := fmt.Sprintf("%s%d", redisChatPrefix, chatId)
 	holder, _ := uuid.NewRandom()