VectorChromaQueryEngine

VectorChromaQueryEngine(
    db_path: str | None = None,
    embedding_function: Optional[EmbeddingFunction[Any]] = None,
    metadata: dict[str, Any] | None = None,
    llm: ForwardRef('LLM') | None = None,
    collection_name: str | None = None
)

This engine leverages Chromadb to persist document embeddings in a named collection and LlamaIndex’s VectorStoreIndex to efficiently index and retrieve documents, and generate an answer in response to natural language queries. The Chromadb collection serves as the storage layer, while the collection name uniquely identifies the set of documents within the persistent database.
Initializes the VectorChromaQueryEngine with db_path, metadata, and embedding function and llm.

Parameters:
NameDescription
db_pathType: str | None

Default: None
embedding_functionType: Optional[EmbeddingFunction[Any]]

Default: None
metadataType: dict[str, typing.Any] | None

Default: None
llmType: ForwardRef(‘LLM’) | None

Default: None
collection_nameType: str | None

Default: None

Instance Methods

add_docs

add_docs(
    self,
    new_doc_dir: Path | str | None = None,
    new_doc_paths: list[Path | str] | None = None
) -> None

Add additional documents to the existing vector index.
Loads new Docling-parsed Markdown files from a specified directory or a list of file paths and inserts them into the current index for future queries.

Parameters:
NameDescription
new_doc_dirThe directory path from which to load additional documents.

If provided, all eligible files in this directory are loaded.

Type: pathlib.Path | str | None

Default: None
new_doc_pathsA list of file paths specifying additional documents to load.

Each file should be a Docling-parsed Markdown file.

Type: list[pathlib.Path | str] | None

Default: None

establish_db

establish_db(self) -> None

Establish a connection to the Chromadb database and initialize the collection.


get_collection_name

get_collection_name(self) -> str

Get the name of the collection used by the query engine.
Returns:
The name of the collection.

Returns:
TypeDescription
strThe name of the collection.

query

query(self, question: str) -> str

Retrieve information from indexed documents by processing a natural language query.

Parameters:
NameDescription
questionA natural language query string used to search the indexed documents.

Type: str
Returns:
TypeDescription
strA string containing the response generated by LLM.

validate_query_index

validate_query_index(self) -> None

Ensures an index exists