Update deprecated Neo4jGraph import to support langchain-neo4j #2084
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.
Description
This PR addresses the following deprecation warning encountered during execution of the Graph Memory module in mem0:
LangChainDeprecationWarning: The class
Neo4jGraph
was deprecated in LangChain 0.3.8 and will be removed in 1.0. An updated version of the class exists in thelangchain-neo4j
package and should be used instead. To use it runpip install -U langchain-neo4j
and import asfrom langchain_neo4j import Neo4jGraph
.Previously, using graph_memory.py triggered this warning during initialization:
Fix Overview
The changes in \mem0\memory\graph_memory.py update the import to the new langchain-neo4j package while maintaining backward compatibility with langchain-community.
Old Import:
New Import:
This ensures compatibility with both the new langchain-neo4j package and the older langchain-community package, eliminating the deprecation warning.
BTW - building poetry also upgraded poetry.lock any available packages by itself, I'm not very familiar yet with poetry so will free to remove that if not necessary :)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
I wrote a simple script that just init mem0 calss with a local ollama llm, chromadb and neo4j, before the fix the warning popup was displayed and now it dosent
Please delete options that are not relevant.
Checklist:
Maintainer Checklist