neo4j_native_graph_query_engine
autogen.agentchat.contrib.graph_rag.neo4j_native_graph_query_engine.Neo4jNativeGraphQueryEngine
Neo4jNativeGraphQueryEngine
A graph query engine implemented using the Neo4j GraphRAG SDK.
Provides functionality to initialize a knowledge graph,
create a vector index, and query the graph using Neo4j and LLM.
Initialize a Neo4j graph query engine.
Name | Description |
---|---|
host | Type: str Default: ‘neo4j |
port | Type: int Default: 7687 |
username | Type: str Default: ‘neo4j’ |
password | Type: str Default: ‘password’ |
embeddings | Type: ForwardRef(‘Embedder’) | None Default: None |
embedding_dimension | Type: int | None Default: 3072 |
llm | Type: ForwardRef(‘LLMInterface’) | None Default: None |
query_llm | Type: ForwardRef(‘LLMInterface’) | None Default: None |
entities | Type: List[str]Â |Â None Default: None |
relations | Type: List[str]Â |Â None Default: None |
potential_schema | Type: List[tuple[str, str, str]] | None Default: None |
Instance Methods
add_records
Add new records to the Neo4j database.
Name | Description |
---|---|
new_records | List of new Documents to be added Type: list[Document] |
Type | Description |
---|---|
bool | bool: True if records were added successfully, False otherwise. |
init_db
Initialize the Neo4j graph database using the provided input doc.
Currently this method only supports single document input (only reads the first doc).
This method supports both text and PDF documents. It performs the following steps:
1. Clears the existing database.
2. Extracts graph nodes and relationships from the input data to build a knowledge graph.
3. Creates a vector index for efficient retrieval.
Name | Description |
---|---|
input_doc | Input documents for building the graph. Type: list[Document]Â |Â None Default: None |
query
Query the Neo4j database using a natural language question.
Name | Description |
---|---|
question | The question to be answered by querying the graph. Type: str |
n_results | Type: int Default: 1 |
**kwargs | Type: Any |
Type | Description |
---|---|
GraphStoreQueryResult | GraphStoreQueryResult: The result of the query. |