VectorDbQueryEngine

VectorDbQueryEngine(*args, **kwargs)

An abstract base class that represents a query engine on top of an underlying vector database.
This interface defines the basic methods for RAG.

Parameters:
NameDescription
*args
**kwargs

Instance Methods

add_records

add_records(
    self,
    new_doc_dir: Path | str | None = None,
    new_doc_paths_or_urls: list[Path | str] | None = None,
    *args: Any,
    **kwargs: Any
) -> bool

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

Parameters:
NameDescription
new_doc_dirType: pathlib.Path | str | None

Default: None
new_doc_paths_or_urlsType: list[pathlib.Path | str] | None

Default: None
*argsType: Any
**kwargsType: Any

connect_db

connect_db(
    self,
    *args: Any,
    **kwargs: Any
) -> bool

Connect to the database.

Parameters:
NameDescription
*argsAny additional arguments

Type: Any
**kwargsAny additional keyword arguments

Type: Any
Returns:
TypeDescription
boolbool: True if connection is successful, False otherwise

init_db

init_db(
    self,
    new_doc_dir: Path | str | None = None,
    new_doc_paths: list[Path | str] | None = 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
  2. build indexes etc.
Parameters:
NameDescription
new_doc_dira dir of input documents that are used to create the records in database.

Type: pathlib.Path | str | None

Default: None
new_doc_pathsa 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: list[pathlib.Path | str] | None

Default: None
*argsAny additional arguments

Type: Any
**kwargsAny additional keyword arguments

Type: Any
Returns:
TypeDescription
boolbool: True if initialization is successful, False otherwise

query

query(
    self,
    question: str,
    *args: Any,
    **kwargs: Any
) -> str

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

Parameters:
NameDescription
questiona string format question

Type: str
*argsAny additional arguments

Type: Any
**kwargsAny additional keyword arguments

Type: Any