INTPYTHON-809 - Update to langchain 1.0 and langgraph 1.0 #262
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.
INTPYTHON-809 - Migrate langchain-mongodb to LangChain 1.0
Issue Key
Summary
This PR migrates the
langchain-mongodbpackage to be compatible with LangChain 1.0+. The main focus is on removing dependencies on legacy packages (langchain-classic) where possible and updating retrievers to use the modernlangchain_coreAPIs. This includes:MongoDBAtlasParentDocumentRetrieverto extendBaseRetrieverdirectly fromlangchain_coreinstead of the legacyParentDocumentRetrieveradd_documents()method discovered during migrationMongoDBAtlasSelfQueryRetrieverto explicitly uselangchain-classicfor components not yet available in LangChain 1.0langchain < 1.0version pin to allow users to upgrade to LangChain 1.0+langgraph-checkpoint>=3.0.1andaiohttp>=3.13.2Changes in this PR
1.
MongoDBAtlasParentDocumentRetrieverRefactoringFile:
libs/langchain-mongodb/langchain_mongodb/retrievers/parent_document.pylangchain-classic: Changed base class fromParentDocumentRetriever(legacy) toBaseRetrieverfromlangchain_corechild_splitterfield: Required for splitting parent documents into chunkssearch_kwargsfield: Enables passing additional search parameters to vector searchadd_documents()method: Complete implementation for adding parent documents and child chunks to the vectorstoreCritical Bug Fixes in
add_documents():docstore.add_documents()→ changed todocstore.mset()which is the correct API forMongoDBDocStorevectorstore.add_documents()anddocstore.mset()were called inside the document loop instead of after processing all documentsmset():[(id, Document), ...]Updated Docstrings:
ParentDocumentRetrieverandMultiVectorRetrieverclassesMongoDBAtlasParentDocumentRetriever2.
MongoDBAtlasSelfQueryRetrieverDependenciesFile:
libs/langchain-mongodb/langchain_mongodb/retrievers/self_querying.pylangchain-classicforAttributeInfoandSelfQueryRetrieverlangchain-classicin LangChain 1.0 as they are considered legacy componentslangchain-classicdependency requirement3. Documentation Updates
File:
libs/langchain-mongodb/CHANGELOG.md4. Dependency Updates
Files:
pyproject.toml,uv.locklangchain < 1.0langchain >= 1.0langgraph-checkpoint >= 3.0.1aiohttp >= 3.13.2Test Plan
Unit Tests
MongoDBAtlasParentDocumentRetrieverpass with the refactored implementationdoc_idfield)mset()Integration Tests
MongoDBAtlasParentDocumentRetriever.from_connection_string()correctly initializes the retrieveradd_documents()with multiple parent documentsMongoDBAtlasSelfQueryRetrieverworks withlangchain-classicinstalledManual Testing
MongoDBAtlasParentDocumentRetrieverwith LangChain 1.0Compatibility Testing
langchain==1.0.0langchain-core==1.0.0langchain-classicis correctly used only where necessaryChecklist
Checklist for Author
Checklist for Reviewer {@primary_reviewer}
Focus Areas for Reviewer
add_documents()implementation inparent_document.py: This method was completely rewritten to fix critical bugs. Please verify:docstore.mset()with key-value pairs is appropriateBreaking changes: This PR introduces breaking changes for users:
MongoDBAtlasParentDocumentRetrieverno longer requireslangchain-classicbut has a different API surfaceMongoDBAtlasSelfQueryRetrievernow requires explicit installation oflangchain-classicLangChain 1.0 compatibility:
langchain_coreare correctBackward compatibility concerns:
langchain < 1.0pin?