Skip to main content

rag_query

Method
This is a method of the Agent class in the agent module.
Query knowledge using RAG pipeline with citations. This is the recommended way to get answers with citations from an agent’s knowledge.

Signature

def rag_query(question: str) -> 'RAGResult'

Parameters

question
str
required
The question to answer **kwargs: Additional arguments passed to RAG.query()

Returns

Returns
'RAGResult'
RAGResult with answer, citations, context_used, and metadata

Exceptions

If no knowledge sources are configured
If RAG module is not available

Usage

agent = Agent(knowledge=["doc.pdf"], rag_config={"include_citations": True})
    result = agent.rag_query("What is the main finding?")
    print(result.answer)
    for citation in result.citations:
        print(f"[{citation.id}] {citation.source}: {citation.text[:100]}")