langchain_community.graphs.neo4j_graph.Neo4jGraph¶

class langchain_community.graphs.neo4j_graph.Neo4jGraph(url: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, database: str = 'neo4j', timeout: Optional[float] = None, sanitize: bool = False)[source]¶

Provides a connection to a Neo4j database for various graph operations. Parameters: url (Optional[str]): The URL of the Neo4j database server. username (Optional[str]): The username for database authentication. password (Optional[str]): The password for database authentication. database (str): The name of the database to connect to. Default is ‘neo4j’. timeout (Optional[float]): The timeout for transactions in seconds.

Useful for terminating long-running queries. By default, there is no timeout set.

sanitize (bool): A flag to indicate whether to remove lists with

more than 128 elements from results. Useful for removing embedding-like properties from database responses. Default is False.

Security note: Make sure that the database connection uses credentials

that are narrowly-scoped to only include necessary permissions. Failure to do so may result in data corruption or loss, since the calling code may attempt commands that would result in deletion, mutation of data if appropriately prompted or reading sensitive data if such data is present in the database. The best way to guard against such negative outcomes is to (as appropriate) limit the permissions granted to the credentials used with this tool.

See https://python.langchain.com/docs/security for more information.

Create a new Neo4j graph wrapper instance.

Attributes

get_schema

Returns the schema of the Graph

get_structured_schema

Returns the structured schema of the Graph

Methods

__init__([url, username, password, ...])

Create a new Neo4j graph wrapper instance.

add_graph_documents(graph_documents[, ...])

Take GraphDocument as input as uses it to construct a graph.

query(query[, params])

Query Neo4j database.

refresh_schema()

Refreshes the Neo4j graph schema information.

__init__(url: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, database: str = 'neo4j', timeout: Optional[float] = None, sanitize: bool = False) None[source]¶

Create a new Neo4j graph wrapper instance.

add_graph_documents(graph_documents: List[GraphDocument], include_source: bool = False) None[source]¶

Take GraphDocument as input as uses it to construct a graph.

query(query: str, params: dict = {}) List[Dict[str, Any]][source]¶

Query Neo4j database.

refresh_schema() None[source]¶

Refreshes the Neo4j graph schema information.

Examples using Neo4jGraph¶