Skip to main content

ExampleSelector

Trait ExampleSelector 

Source
pub trait ExampleSelector: Send + Sync {
    // Required methods
    fn add_example<'life0, 'async_trait>(
        &'life0 self,
        example: PromptArgs,
    ) -> Pin<Box<dyn Future<Output = Result<(), PromptError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn select_examples<'life0, 'life1, 'async_trait>(
        &'life0 self,
        input_variables: &'life1 PromptArgs,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<PromptArgs>, PromptError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Chooses the examples to put in a few-shot prompt for a given input.

Examples are PromptArgs maps, formatted with the prompt’s example template.

Required Methods§

Source

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

Adds an example to the pool the selector chooses from.

Source

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

The examples to use for input_variables (the prompt’s inputs), in the order they should appear.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§