Skip to main content
DocumentQA answers caller questions against documents using retrieval-augmented generation (RAG). It operates in one of two modes:
  • Server mode (default): Documents are uploaded to the Guava server and questions are answered server-side. Intended for simple use cases with few documents.
  • Local mode: Bring your own vector store and generation model for full control over the RAG pipeline. Guava provides ready-made backends for ChromaDB, LanceDB, pgvector, and Pinecone.

Constructor

signature
namespace requirement: In server mode, namespace is required when running multiple DocumentQA instances concurrently — even across different files. Without a namespace, concurrent instances may interfere with each other’s document stores.

Methods

ask(question: str, k: int = 5) -> str — Retrieve relevant chunks and generate an answer. In server mode, k is ignored (the server uses full document context).upsert_document(key: str, text: str) -> None — Add or replace a document by key. Stale chunks from a previously longer document are deleted automatically.add_document(text: str) -> None — Add a document without specifying a key. In server mode, uses a content-derived key (SHA-256 hash).delete_document(key: str) -> None — Delete a previously upserted document by key.clear() -> None — Remove all documents from the store.

Available VectorStore Backends (Local Mode)

Embedding and generation provider extras: pip install 'guava-sdk[genai]' (Google Gemini) or pip install 'guava-sdk[openai]' (OpenAI). See the Vector Stores reference for full constructor details and backend-specific options.

Examples

document_qa_examples.py

Incremental Document Management

Use ids to assign stable keys to documents at construction time, then use upsert_document, delete_document, and clear to manage documents without re-creating the DocumentQA instance.
document_management.py