Skip to content

VectorDbQueryEngine

autogen.agentchat.contrib.rag.VectorDbQueryEngine #

Bases: Protocol

An abstract base class that represents a query engine on top of an underlying vector database.

This interface defines the basic methods for RAG.

init_db #

init_db(new_doc_dir=None, new_doc_paths=None, *args, **kwargs)

Initialize the database with the input documents or records.

This method initializes database with the input documents or records. Usually, it takes the following steps, 1. connecting to a database. 2. insert records 3. build indexes etc.

PARAMETER DESCRIPTION
new_doc_dir

a dir of input documents that are used to create the records in database.

TYPE: Optional[Union[Path, str]] DEFAULT: None

new_doc_paths

a list of input documents that are used to create the records in database. a document can be a path to a file or a url.

TYPE: Optional[list[Union[Path, str]]] DEFAULT: None

*args

Any additional arguments

TYPE: Any DEFAULT: ()

**kwargs

Any additional keyword arguments

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
bool

True if initialization is successful, False otherwise

TYPE: bool

Source code in autogen/agentchat/contrib/rag/query_engine.py
def init_db(
    self,
    new_doc_dir: Optional[Union[Path, str]] = None,
    new_doc_paths: Optional[list[Union[Path, str]]] = None,
    *args: Any,
    **kwargs: Any,
) -> bool:
    """Initialize the database with the input documents or records.

    This method initializes database with the input documents or records.
    Usually, it takes the following steps,
    1. connecting to a database.
    2. insert records
    3. build indexes etc.

    Args:
        new_doc_dir: a dir of input documents that are used to create the records in database.
        new_doc_paths:
            a list of input documents that are used to create the records in database.
            a document can be a path to a file or a url.
        *args: Any additional arguments
        **kwargs: Any additional keyword arguments

    Returns:
        bool: True if initialization is successful, False otherwise
    """
    ...

add_records #

add_records(new_doc_dir=None, new_doc_paths_or_urls=None, *args, **kwargs)

Add new documents to the underlying database and add to the index.

Source code in autogen/agentchat/contrib/rag/query_engine.py
def add_records(
    self,
    new_doc_dir: Optional[Union[Path, str]] = None,
    new_doc_paths_or_urls: Optional[list[Union[Path, str]]] = None,
    *args: Any,
    **kwargs: Any,
) -> bool:
    """Add new documents to the underlying database and add to the index."""
    ...

connect_db #

connect_db(*args, **kwargs)

Connect to the database.

PARAMETER DESCRIPTION
*args

Any additional arguments

TYPE: Any DEFAULT: ()

**kwargs

Any additional keyword arguments

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
bool

True if connection is successful, False otherwise

TYPE: bool

Source code in autogen/agentchat/contrib/rag/query_engine.py
def connect_db(self, *args: Any, **kwargs: Any) -> bool:
    """Connect to the database.

    Args:
        *args: Any additional arguments
        **kwargs: Any additional keyword arguments

    Returns:
        bool: True if connection is successful, False otherwise
    """
    ...

query #

query(question, *args, **kwargs)

Transform a string format question into database query and return the result.

PARAMETER DESCRIPTION
question

a string format question

TYPE: str

*args

Any additional arguments

TYPE: Any DEFAULT: ()

**kwargs

Any additional keyword arguments

TYPE: Any DEFAULT: {}

Source code in autogen/agentchat/contrib/rag/query_engine.py
def query(self, question: str, *args: Any, **kwargs: Any) -> str:
    """Transform a string format question into database query and return the result.

    Args:
        question: a string format question
        *args: Any additional arguments
        **kwargs: Any additional keyword arguments
    """
    ...