Question-answering over documents.
Server mode (default): documents are uploaded to the Guava server, which answers questions over them. No local vector store needed.
qa = Guava.DocumentQA.new(client, documents: [policy_text, faq_text])
{:ok, answer} = Guava.DocumentQA.ask(qa, "What is the deductible?")Local mode: pass a :store (implementing Guava.RAG.VectorStore) and a
:generation_model (implementing Guava.RAG.GenerationModel), each as a
{module, state} tuple.
Summary
Functions
Add a document (content-addressed). Returns the updated DocumentQA.
Answer question over this instance's documents. Returns {:ok, answer} | {:error, _}.
Like ask/3, but returns the answer or raises Guava.Error.
Delete all documents tracked by this instance. Returns the updated DocumentQA.
Delete a document by key. Returns the updated DocumentQA.
Build a DocumentQA.
Add or replace a document by key. Returns the updated DocumentQA.
Types
Functions
Add a document (content-addressed). Returns the updated DocumentQA.
@spec ask(t(), String.t(), pos_integer()) :: {:ok, String.t()} | {:error, Guava.Error.t()}
Answer question over this instance's documents. Returns {:ok, answer} | {:error, _}.
@spec ask!(t(), String.t(), pos_integer()) :: String.t()
Like ask/3, but returns the answer or raises Guava.Error.
Delete all documents tracked by this instance. Returns the updated DocumentQA.
Delete a document by key. Returns the updated DocumentQA.
@spec new( Guava.Client.t(), keyword() ) :: t()
Build a DocumentQA.
Options
:documents— string or list of strings to index at construction.:ids— optional stable ids for the documents (enables later update).:namespace— scope this instance's documents on the server.:instructions— system instruction for answering.:store,:generation_model— switch to local mode ({module, state}).:chunk_size,:chunk_overlap— local-mode chunking.
Add or replace a document by key. Returns the updated DocumentQA.