RAG Query • AI Agent SDK
rag_query: Query knowledge using RAG pipeline with citations.
rag_query
Method
</div>
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
ParamField
strThe question to answer **kwargs: Additional arguments passed to RAG.query()
Returns
ResponseField
'RAGResult'RAGResult with answer, citations, context_used, and metadata
Exceptions
ValueError
If no knowledge sources are configured
ImportError
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]}")Uses
ValueErrorImportErrorkwargs.setdefaultquery
Source
View on GitHubpraisonaiagents/agent/agent.py at line 6895