Skip to main content

Retriever

Trait Retriever 

Source
pub trait Retriever: Send + Sync {
    // Required method
    fn retrieve<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        tree: &'life1 DocumentTree,
        query: &'life2 str,
        options: &'life3 RetrieveOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<RetrievalResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

A retriever finds relevant content in a document tree.

Implementations can use different strategies:

  • LLM-based navigation (tree traversal)
  • MCTS (Monte Carlo Tree Search)
  • Beam search
  • Vector similarity

§Example

use vectorless::core::{Retriever, DocumentTree, Result};
use vectorless::retriever::RetrieveOptions;
use async_trait::async_trait;

struct MyRetriever;

#[async_trait]
impl Retriever for MyRetriever {
    async fn retrieve(&self, tree: &DocumentTree, query: &str, options: &RetrieveOptions) -> Result<Vec<RetrievalResult>> {
        // Return relevant content
        Ok(vec![RetrievalResult::new("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 = Result<Vec<RetrievalResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Retrieve relevant content for a query.

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

A list of retrieval results with content, scores, and metadata.

Implementors§