pythonneo4jlangchaingraphrag

ValueError: Could not use APOC procedures. Please ensure the APOC plugin is installed in Neo4j and that 'apoc.meta.data()' is allowed in Neo4j


I'm trying to use the Neo4jGraph class from the langchain_community.graphs module in my Python project to interact with a Neo4j database. My script here:

from langchain.chains import GraphCypherQAChain
from langchain_community.graphs import Neo4jGraph
from langchain_openai import ChatOpenAI

enhanced_graph = Neo4jGraph(
    url="bolt://localhost:7687",
    username="neo4j",
    password="password",
    enhanced_schema=True,
)
print(enhanced_graph.schema)

chain = GraphCypherQAChain.from_llm(
    ChatOpenAI(temperature=0), graph=enhanced_graph, verbose=True
)

chain.invoke({"query": "Who is Bob?"})

Error here:

ValueError: Could not use APOC procedures. Please ensure the APOC plugin is installed in Neo4j and that 'apoc.meta.data()' is allowed in Neo4j configuration
neo4j.exceptions.ClientError: {code: Neo.ClientError.Procedure.ProcedureNotFound} {message: There is no procedure with the name `apoc.meta.data` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.}

How to solve the problem?


Solution

  • This is a known error:

    1. copy this file 'apoc-5.14.0-core.jar' from /var/lib/neo4j/labs/ to /var/lib/neo4j/plugins

    2. update this file /var/lib/neo4j/conf/neo4j.conf

      dbms.security.procedures.unrestricted=apoc.*

      dbms.security.procedures.allowlist=apoc.*

    Git link with solutions : https://github.com/langchain-ai/langchain/issues/12901