Add MongoDB-backed ChatMemoryStore implementation#611
Draft
VasilijeJukic01 wants to merge 1 commit intolangchain4j:mainfrom
Draft
Add MongoDB-backed ChatMemoryStore implementation#611VasilijeJukic01 wants to merge 1 commit intolangchain4j:mainfrom
VasilijeJukic01 wants to merge 1 commit intolangchain4j:mainfrom
Conversation
b19d8d8 to
40ed7af
Compare
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.
Issue
Closes langchain4j/langchain4j#4830
Change
Ported from the main repository as requested by @dliubarskyi.
This PR introduces
MongoDbChatMemoryStore, providing a native MongoDB-backed implementation for chat history persistence. This allows users already utilizing MongoDB in their architecture to store chat memory without needing to introduce a relational database.Architectural & Design Decisions:
langchain4j-community-mongodb): Created a new module inside thechat-memory-storescategory. TheChatMemoryStorerelies on standard MongoDB collections and works with any MongoDB deployment (local, self-hosted, etc.). Keeping it separate ensures users don't have to pull in heavy vector search dependencies if they just want standard MongoDB chat storage.ChatMessageSerializerrather than custom BSON arrays. This guarantees out-of-the-box compatibility with all current and futureChatMessagetypes (e.g., Tool execution, System messages) without needing to maintain complex BSON codecs.expireAfterSeconds). It includes graceful error handling forMongoCommandException(Error 85) if a user updates the TTL value on an existing index.Testing:
MongoDbChatMemoryStoreITusing Testcontainers (mongo:6.0).memoryIdisolation validation.General checklist
Checklist for adding new maven module
pom.xmlandlangchain4j-community-bom/pom.xmlChecklist for adding new embedding store integration
{NameOfIntegration}EmbeddingStoreITthat extends from eitherEmbeddingStoreITorEmbeddingStoreWithFilteringIT{NameOfIntegration}EmbeddingStoreRemovalITthat extends fromEmbeddingStoreWithRemovalITChecklist for changing existing embedding store integration
{NameOfIntegration}EmbeddingStoreworks correctly with the data persisted using the latest released version of LangChain4j