mirror of https://github.com/hwchase17/langchain
updated to use new llm_util query (#8591)
- Description: added memgraph_graph.py which defines the MemgraphGraph class, subclassing off the existing Neo4jGraph class. This lets you query the Memgraph graph database using natural language. It leverages the Neo4j drivers and the bolt protocol. - Dependencies: since it is a subclass off of Neo4jGraph, it is dependent on it and the GraphCypherQA Chain implementations. It is dependent on the Neo4j drivers being present. It is dependent on having a running Memgraph instance to connect to. - Tag maintainer: @baskaryan - Twitter handle: @villageideate - example usage can be seen in this repo https://github.com/brettdbrewer/MemgraphGraph/ --------- Co-authored-by: Bagatur <baskaryan@gmail.com>pull/8599/head
parent
a7000ee89e
commit
2de028834f
@ -0,0 +1,26 @@
|
||||
from langchain.graphs.neo4j_graph import Neo4jGraph
|
||||
|
||||
SCHEMA_QUERY = """
|
||||
CALL llm_util.schema("prompt_ready")
|
||||
YIELD *
|
||||
RETURN *
|
||||
"""
|
||||
|
||||
|
||||
class MemgraphGraph(Neo4jGraph):
|
||||
"""Memgraph wrapper for graph operations."""
|
||||
|
||||
def __init__(
|
||||
self, url: str, username: str, password: str, *, database: str = "memgraph"
|
||||
) -> None:
|
||||
"""Create a new Memgraph graph wrapper instance."""
|
||||
super().__init__(url, username, password, database=database)
|
||||
|
||||
def refresh_schema(self) -> None:
|
||||
"""
|
||||
Refreshes the Memgraph graph schema information.
|
||||
"""
|
||||
|
||||
db_schema = self.query(SCHEMA_QUERY)[0].get("schema")
|
||||
assert db_schema is not None
|
||||
self.schema = db_schema
|
Loading…
Reference in New Issue