RAGQueryEngine

RAGQueryEngine(*args, **kwargs)

A protocol class that represents a document ingestation and query engine on top of an underlying database.
This interface defines the basic methods for RAG.

Parameters:
NameDescription
*args
**kwargs

Instance Methods

add_docs

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

Add new documents to the underlying data store.

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

Default: None
new_doc_paths_or_urlsType: Sequence[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_or_urls: Sequence[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 3. build indexes etc.

Parameters:
NameDescription
new_doc_dirA directory containing documents to be ingested.

Type: pathlib.Path | str | None

Default: None
new_doc_paths_or_urlsA list of paths or URLs to documents to be ingested.

Type: Sequence[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