rag.query() embeds a user query and returns matching chunks. rag.chat() runs retrieval and answer generation together.
Search with query()
query() returns a RetrieveResult with query, search_query, retrieved, items, failed, and errors.
Add Reranking and Query Rewriting
llm={...} on RagRails(...) or pass a rewrite LLM in the config.
Generate an Answer with chat()
chat() returns answer, sources, history, retrieval, llm, errors, retrieval_quality, answer_confidence, compacted, and intent.
Stream Chat
Choosing the SDK Call
Retrieval
Tune lower-level retrieval.
Chat
Tune grounded chat behavior.

