Trait BaseExampleSelector

Source
pub trait BaseExampleSelector: Send + Sync {
    // Required methods
    fn add_example(&mut self, example: Example) -> Result<()>;
    fn select_examples(&self, input_variables: &Example) -> Result<Vec<Example>>;

    // Provided methods
    fn aadd_example<'life0, 'async_trait>(
        &'life0 mut self,
        example: Example,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn aselect_examples<'life0, 'life1, 'async_trait>(
        &'life0 self,
        input_variables: &'life1 Example,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Example>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Interface for selecting examples to include in prompts.

Example selectors are used to dynamically choose which examples to include in prompts based on the input variables. This is essential for few-shot learning and context-aware prompt construction.

Required Methods§

Source

fn add_example(&mut self, example: Example) -> Result<()>

Add a new example to the store.

§Arguments
  • example - A dictionary with keys as input variables and values as their values.
§Returns

Any return value (e.g., example ID for tracking).

Source

fn select_examples(&self, input_variables: &Example) -> Result<Vec<Example>>

Select which examples to use based on the inputs.

§Arguments
  • input_variables - A dictionary with keys as input variables and values as their values.
§Returns

A list of examples to include in the prompt.

Provided Methods§

Source

fn aadd_example<'life0, 'async_trait>( &'life0 mut self, example: Example, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Async add a new example to the store.

§Arguments
  • example - A dictionary with keys as input variables and values as their values.
§Returns

Any return value (e.g., example ID for tracking).

Source

fn aselect_examples<'life0, 'life1, 'async_trait>( &'life0 self, input_variables: &'life1 Example, ) -> Pin<Box<dyn Future<Output = Result<Vec<Example>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Async select which examples to use based on the inputs.

§Arguments
  • input_variables - A dictionary with keys as input variables and values as their values.
§Returns

A list of examples to include in the prompt.

Implementors§