Skip to main content
The query side has two SDK entry points. 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

Query rewriting needs an LLM. Configure 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

The final event contains the complete chat result as a dictionary.

Choosing the SDK Call

Retrieval

Tune lower-level retrieval.

Chat

Tune grounded chat behavior.