GraphQueryEngine

GraphQueryEngine(*args, **kwargs)
An abstract base class that represents a graph query engine on top of a underlying graph database.
This interface defines the basic methods for graph-based RAG.
Parameters:
NameDescription
*args
**kwargs

Instance Methods

add_records

add_records(self, new_records: list[Any]) -> bool
Add new records to the underlying database and add to the graph if required. Parameters:
NameDescription
new_recordsType: list[typing.Any]

init_db

init_db(self, input_doc: list[Document] | None = None) -> None
This method initializes graph database with the input documents or records.
Usually, it takes the following steps,
  1. connecting to a graph database.
    2. extract graph nodes, edges based on input data, graph schema and etc.
    3. build indexes etc.
Parameters:
NameDescription
input_doca list of input documents that are used to build the graph in database.

Type: list[Document] | None

Default: None

query

query(
    self,
    question: str,
    n_results: int = 1,
    **kwarg: Any
) -> GraphStoreQueryResult
This method transform a string format question into database query and return the result. Parameters:
NameDescription
questionType: str
n_resultsType: int

Default: 1
**kwargType: Any