Skip to main content

Retriever

Trait Retriever 

Source
pub trait Retriever: Send + Sync {
    // Required methods
    fn retrieve<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        tree: &'life1 DocumentTree,
        query: &'life2 str,
        options: &'life3 RetrieveOptions,
    ) -> Pin<Box<dyn Future<Output = RetrieverResult<RetrieveResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn name(&self) -> &str;

    // Provided methods
    fn supports_options(&self, _options: &RetrieveOptions) -> bool { ... }
    fn estimate_cost(
        &self,
        tree: &DocumentTree,
        options: &RetrieveOptions,
    ) -> CostEstimate { ... }
}
Expand description

Trait for document retrieval strategies.

Implementations provide different approaches to navigating the document tree and finding relevant content.

Required Methods§

Source

fn retrieve<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, tree: &'life1 DocumentTree, query: &'life2 str, options: &'life3 RetrieveOptions, ) -> Pin<Box<dyn Future<Output = RetrieverResult<RetrieveResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Retrieve relevant content for the given query.

§Arguments
  • tree - The document tree to search
  • query - The user’s query string
  • options - Retrieval options controlling behavior
§Returns

A RetrieveResponse containing the retrieved content and metadata.

Source

fn name(&self) -> &str

Get the name of this retriever for logging/debugging.

Provided Methods§

Source

fn supports_options(&self, _options: &RetrieveOptions) -> bool

Check if this retriever supports the given options.

Some retrievers may not support all features (e.g., sufficiency checking).

Source

fn estimate_cost( &self, tree: &DocumentTree, options: &RetrieveOptions, ) -> CostEstimate

Estimate the cost of a retrieval operation.

Returns an estimated number of LLM calls or tokens that will be used. Useful for cost-aware strategy selection.

Implementors§