GH-3183: Add file-based ChatMemoryRepository implementation#5154
Open
ranjitm2001 wants to merge 1 commit into
Open
GH-3183: Add file-based ChatMemoryRepository implementation#5154ranjitm2001 wants to merge 1 commit into
ranjitm2001 wants to merge 1 commit into
Conversation
…ation
This commit adds FileChatMemoryRepository, a file-based implementation
of ChatMemoryRepository that stores chat messages as JSON files on the
local filesystem. Each conversation is stored in a separate file named
{conversationId}.json.
This implementation is useful for:
- Local development without database setup
- Testing with persistent memory across restarts
- Simple applications that need chat memory persistence
Features:
- Stores one JSON file per conversation
- Configurable storage directory (default: chat-memory)
- Uses Jackson for JSON serialization
- Thread-safe file operations
- Full support for UserMessage, AssistantMessage, SystemMessage types
Closes spring-projectsgh-3183
Signed-off-by: Ranjith Muniyappa <rmuniyappa@tekion.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds
FileChatMemoryRepository, a file-based implementation ofChatMemoryRepositorythat stores chat messages as JSON files on the local filesystem. Each conversation is stored in a separate file named{conversationId}.json.Motivation
As requested in #3183, there was a gap in the available ChatMemoryRepository implementations. While there are options for in-memory, JDBC, MongoDB, Redis, Neo4j, Cassandra, and CosmosDB, there was no simple file-based option for:
Changes
New Files
FileChatMemoryRepository.java- Main implementationFileChatMemoryRepositoryTests.java- Unit tests (11 tests, all passing)Features
chat-memory/)UserMessage,AssistantMessage,SystemMessagetypesTesting
All 11 unit tests pass.
Closes #3183