Skip to main content

retrieve

Method
This is a method of the Agent class in the agent module.
Retrieve context from knowledge without LLM generation. Returns a ContextPack that can be passed to chat_with_context(). This enables conditional retrieval - only retrieve when needed.

Signature

def retrieve(query: str) -> 'ContextPack'

Parameters

query
str
required
Search query **kwargs: Additional arguments (top_k, rerank, etc.)

Returns

Returns
'ContextPack'
ContextPack with context string and citations (no LLM call)

Exceptions

If no knowledge is configured
If RAG module is not available

Usage

agent = Agent(knowledge=["docs/"], retrieval_config={"citations": True})
    context = agent.retrieve("What are the key findings?")
    print(f"Found {len(context.citations)} sources")
    response = agent.chat_with_context("Summarize", context)