From 791b52cc8e0cef8ce1436b0bf1206d926cced254 Mon Sep 17 00:00:00 2001 From: HamaWhite Date: Sat, 22 Jul 2023 00:50:27 +0800 Subject: [PATCH] optimize --- .../chains/query/constructor/JsonUtils.java | 3 +++ .../database/ChatMessageRepository.java | 17 ++++++++++++++--- .../redis/RedisChatMessageRepository.java | 2 +- pom.xml | 1 - 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/langchain-core/src/main/java/com/hw/langchain/chains/query/constructor/JsonUtils.java b/langchain-core/src/main/java/com/hw/langchain/chains/query/constructor/JsonUtils.java index f560e6644..81e99cc59 100644 --- a/langchain-core/src/main/java/com/hw/langchain/chains/query/constructor/JsonUtils.java +++ b/langchain-core/src/main/java/com/hw/langchain/chains/query/constructor/JsonUtils.java @@ -32,6 +32,9 @@ */ public class JsonUtils { + private JsonUtils() { + } + private static final ObjectMapper OBJECT_MAPPER = createObjectMapper(); private static ObjectMapper createObjectMapper() { diff --git a/langchain-core/src/main/java/com/hw/langchain/memory/chat/message/histories/database/ChatMessageRepository.java b/langchain-core/src/main/java/com/hw/langchain/memory/chat/message/histories/database/ChatMessageRepository.java index 97b66e6e0..73028a929 100644 --- a/langchain-core/src/main/java/com/hw/langchain/memory/chat/message/histories/database/ChatMessageRepository.java +++ b/langchain-core/src/main/java/com/hw/langchain/memory/chat/message/histories/database/ChatMessageRepository.java @@ -31,14 +31,25 @@ public interface ChatMessageRepository { /** - * load all history chat message of given sessionId + * Loads all historical chat messages for the given sessionId. * - * @param sessionId - * @return + * @param sessionId The unique identifier of the chat session. + * @return A List of BaseMessage containing the chat message history for the session. */ List loadMessage(String sessionId); + /** + * Saves a chat message to the specified sessionId. + * + * @param sessionId The unique identifier of the chat session. + * @param baseMessage The BaseMessage to be saved. + */ void saveMessage(String sessionId, BaseMessage baseMessage); + /** + * Clears all chat messages for the specified sessionId. + * + * @param sessionId The unique identifier of the chat session. + */ void clearSessionChatMessage(String sessionId); } diff --git a/langchain-core/src/main/java/com/hw/langchain/memory/chat/message/histories/database/redis/RedisChatMessageRepository.java b/langchain-core/src/main/java/com/hw/langchain/memory/chat/message/histories/database/redis/RedisChatMessageRepository.java index c4f0f463a..d5a695aeb 100644 --- a/langchain-core/src/main/java/com/hw/langchain/memory/chat/message/histories/database/redis/RedisChatMessageRepository.java +++ b/langchain-core/src/main/java/com/hw/langchain/memory/chat/message/histories/database/redis/RedisChatMessageRepository.java @@ -59,7 +59,7 @@ public RedisChatMessageRepository(RedissonClient redissonClient, int ttlSeconds) /** * Construct the record key to use * - * @return + * @return key */ private String key(String sessionId) { if (this.keyPrefix == null) { diff --git a/pom.xml b/pom.xml index 22149e361..2179c36ca 100644 --- a/pom.xml +++ b/pom.xml @@ -232,7 +232,6 @@ ${netty-resolver.version} -