agentchat.contrib.graph_rag.graph_query_engine
GraphStoreQueryResult
@dataclass
class GraphStoreQueryResult()
A wrapper of graph store query results.
answer: human readable answer to question/query. results: intermediate results to question/query, e.g. node entities.
GraphQueryEngine
class GraphQueryEngine(Protocol)
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 rag.
init_db
def init_db(input_doc: List[Document] | None = None)
This method initializes graph database with the input documents or records. Usually, it takes the following steps,
- connecting to a graph database.
- extract graph nodes, edges based on input data, graph schema and etc.
- build indexes etc.
Arguments:
-
input_doc
- a list of input documents that are used to build the graph in database. -
Returns
- GraphStore
add_records
def add_records(new_records: List) -> bool
Add new records to the underlying database and add to the graph if required.
query
def query(question: str,
n_results: int = 1,
**kwargs) -> GraphStoreQueryResult
This method transform a string format question into database query and return the result.