Package com.bytedesk.ai.alibaba.memory
Class JdbcChatMemoryRepository
java.lang.Object
com.bytedesk.ai.alibaba.memory.JdbcChatMemoryRepository
- All Implemented Interfaces:
org.springframework.ai.chat.memory.ChatMemoryRepository
- Direct Known Subclasses:
MysqlChatMemoryRepository
public abstract class JdbcChatMemoryRepository
extends Object
implements org.springframework.ai.chat.memory.ChatMemoryRepository
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final record
private static class
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJdbcChatMemoryRepository
(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
protected abstract String
createTableSql
(String tableName) void
deleteByConversationId
(String conversationId) List<org.springframework.ai.chat.messages.Message>
findByConversationId
(String conversationId) protected String
Get the SQL statement used to add recordsprotected String
Get the SQL statement used for querying recordsprotected abstract String
hasTableSql
(String tableName) void
-
Field Details
-
TABLE_NAME
- See Also:
-
QUERY_GET_IDS
- See Also:
-
QUERY_ADD
- See Also:
-
QUERY_GET
- See Also:
-
QUERY_CLEAR
- See Also:
-
jdbcTemplate
private final org.springframework.jdbc.core.JdbcTemplate jdbcTemplate
-
-
Constructor Details
-
JdbcChatMemoryRepository
public JdbcChatMemoryRepository(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
-
-
Method Details
-
checkAndCreateTable
private void checkAndCreateTable() -
findConversationIds
- Specified by:
findConversationIds
in interfaceorg.springframework.ai.chat.memory.ChatMemoryRepository
-
findByConversationId
public List<org.springframework.ai.chat.messages.Message> findByConversationId(String conversationId) - Specified by:
findByConversationId
in interfaceorg.springframework.ai.chat.memory.ChatMemoryRepository
-
saveAll
public void saveAll(String conversationId, List<org.springframework.ai.chat.messages.Message> messages) - Specified by:
saveAll
in interfaceorg.springframework.ai.chat.memory.ChatMemoryRepository
-
deleteByConversationId
- Specified by:
deleteByConversationId
in interfaceorg.springframework.ai.chat.memory.ChatMemoryRepository
-
getAddSql
Get the SQL statement used to add records- Returns:
- SQL
-
getGetSql
Get the SQL statement used for querying records- Returns:
- SQL
-
hasTableSql
-
createTableSql
-