Skip to content

GraphQueryEngine

autogen.agentchat.contrib.graph_rag.graph_query_engine.GraphQueryEngine #

Bases: 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-based RAG.

init_db #

init_db(input_doc=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.

Args: input_doc: a list of input documents that are used to build the graph in database.

Source code in autogen/agentchat/contrib/graph_rag/graph_query_engine.py
def init_db(self, input_doc: Optional[list[Document]] = 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.

    Args:
    input_doc: a list of input documents that are used to build the graph in database.

    """
    pass

add_records #

add_records(new_records)

Add new records to the underlying database and add to the graph if required.

Source code in autogen/agentchat/contrib/graph_rag/graph_query_engine.py
def add_records(self, new_records: list[Any]) -> bool:
    """Add new records to the underlying database and add to the graph if required."""
    pass

query #

query(question, n_results=1, **kwarg)

This method transform a string format question into database query and return the result.

Source code in autogen/agentchat/contrib/graph_rag/graph_query_engine.py
def 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."""
    pass