Interface ChatMemoryStore
- All Known Implementing Classes:
AzureCosmosDBNoSqlMemoryStore, CassandraChatMemoryStore, CoherenceChatMemoryStore, InMemoryChatMemoryStore, OracleChatMemoryStore, TablestoreChatMemoryStore
public interface ChatMemoryStore
Represents a store for the
Currently, the only implementation available is
More documentation can be found here.
ChatMemory state.
Allows for flexibility in terms of where and how chat memory is stored.
Currently, the only implementation available is
InMemoryChatMemoryStore.
Over time, out-of-the-box implementations will be added for popular stores like SQL databases, document stores, etc.
In the meantime, you can implement this interface to connect to any storage of your choice.
More documentation can be found here.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteMessages(Object memoryId) Deletes all messages for a specified chat memory.default CompletableFuture<Void> deleteMessagesAsync(Object memoryId) Non-blocking counterpart ofdeleteMessages(Object), used by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service APIs.getMessages(Object memoryId) Retrieves messages for a specified chat memory.default CompletableFuture<List<ChatMessage>> getMessagesAsync(Object memoryId) Non-blocking counterpart ofgetMessages(Object), used by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service APIs.voidupdateMessages(Object memoryId, List<ChatMessage> messages) Updates messages for a specified chat memory.default CompletableFuture<Void> updateMessagesAsync(Object memoryId, List<ChatMessage> messages) Non-blocking counterpart ofupdateMessages(Object, List), used by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service APIs.
-
Method Details
-
getMessages
Retrieves messages for a specified chat memory.- Parameters:
memoryId- The ID of the chat memory.- Returns:
- List of messages for the specified chat memory. Must not be null. Can be deserialized from JSON using
ChatMessageDeserializer.
-
updateMessages
Updates messages for a specified chat memory.- Parameters:
memoryId- The ID of the chat memory.messages- List of messages for the specified chat memory, that represent the current state of theChatMemory. Can be serialized to JSON usingChatMessageSerializer.
-
deleteMessages
Deletes all messages for a specified chat memory.- Parameters:
memoryId- The ID of the chat memory.
-
getMessagesAsync
Non-blocking counterpart ofgetMessages(Object), used by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service APIs.The default implementation returns a failed future carrying
AsyncNotSupportedException: a store backed by blocking I/O is not silently offloaded to a worker thread, because that would hide the fact that it is not truly non-blocking. Implement this method to return the messages without blocking the calling thread (e.g. using a reactive client), or, if the underlying client is blocking, offload it to an executor explicitly.- Parameters:
memoryId- The ID of the chat memory.- Returns:
- A future that completes with the list of messages for the specified chat memory. Must not be null.
- Since:
- 1.20.0
-
updateMessagesAsync
@Experimental default CompletableFuture<Void> updateMessagesAsync(Object memoryId, List<ChatMessage> messages) Non-blocking counterpart ofupdateMessages(Object, List), used by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service APIs.The default implementation returns a failed future carrying
AsyncNotSupportedException; seegetMessagesAsync(Object)for the rationale.- Parameters:
memoryId- The ID of the chat memory.messages- List of messages for the specified chat memory, that represent the current state of theChatMemory.- Returns:
- A future that completes when the messages have been stored.
- Since:
- 1.20.0
-
deleteMessagesAsync
Non-blocking counterpart ofdeleteMessages(Object), used by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service APIs.The default implementation returns a failed future carrying
AsyncNotSupportedException; seegetMessagesAsync(Object)for the rationale.- Parameters:
memoryId- The ID of the chat memory.- Returns:
- A future that completes when the messages have been deleted.
- Since:
- 1.20.0
-