|
|
|
@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.time.Instant;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@ -65,7 +66,9 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
|
// 处理完成后的事件: 保存消息记录, 缓存更改
|
|
|
|
|
ChatSession.Message message = ChatSession.Message.of(userPrompt, s);
|
|
|
|
|
HistoryCache.updateContext(sessionId, message);
|
|
|
|
|
CosmosPatchOperations options = CosmosPatchOperations.create().add("/history/-", message);
|
|
|
|
|
CosmosPatchOperations options = CosmosPatchOperations.create()
|
|
|
|
|
.replace("/updateTime", Instant.now().toEpochMilli())
|
|
|
|
|
.add("/history/-", message);
|
|
|
|
|
chatSessionRepository.save(sessionId, PK.of(PK.CHAT_SESSION), ChatSession.class, options);
|
|
|
|
|
});
|
|
|
|
|
// 错误的回调
|
|
|
|
|