Hello again,
I'm following the course on GraphAcademy called Neo4j&LLm Fundamentals, right now I'm at The Cypher QA Chain lesson. If I just copy and paste the code shared in there:
from langchain_openai import ChatOpenAI
from langchain_community.graphs import Neo4jGraph
from langchain.chains import GraphCypherQAChain
from langchain.prompts import PromptTemplate
llm = Chat...
The script works but at the beginning I get back a deprecation warning like this:
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 the :class:~langchain-neo4j package and should be used instead. To use it run
pip install -U :class:~langchain-neo4j
and import asfrom :class:
~langchain_neo4j import Neo4jGraph``.
graph = Neo4jGraph(
So I tried installing langchain-neo4j
package and using from langchain_neo4j import Neo4jGraph
as suggested, but then the script doesn't work and I get the following error:
cypher_chain = GraphCypherQAChain.from_llm(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\PATH_TO\.venv\Lib\site-packages\langchain_community\chains\graph_qa\cypher.py", line 347, in from_llm
return cls(
^^^^
File "C:\PATH_TO\.venv\Lib\site-packages\langchain_core_api\deprecation.py", line 216, in warn_if_direct_instance
return wrapped(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\PATH_TO\.venv\Lib\site-packages\langchain_community\chains\graph_qa\cypher.py", line 221, in init
super().init(**kwargs)
File "C:\PATH_TO\.venv\Lib\site-packages\langchain_core\load\serializable.py", line 125, in init
super().init(*args, **kwargs)
File "C:\PATH_TO\.venv\Lib\site-packages\pydantic\main.py", line 214, in init
validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for GraphCypherQAChain
graph
Input should be an instance of GraphStore [type=is_instance_of, input_value=<langchain_neo4j.graphs.n...t at 0x000001317F398230>, input_type=Neo4jGraph]
For further information visithttps://errors.pydantic.dev/2.10/v/is_instance_of
Should I stay with the deprecated library or is there any solution for this error?
Thanks in advance,
Boris
PS: I'm using the following libraries:
langchain 0.3.12
langchain-community 0.3.12
langchain-core 0.3.25
langchain-neo4j 0.1.1
langchain-ollama 0.2.1
pydantic 2.10.3
pydantic_core 2.27.1
pydantic-settings 2.7.0