Skip to main content

AsyncMetric

Trait AsyncMetric 

Source
pub trait AsyncMetric:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &'static str;
    fn score<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        input: &'life1 str,
        actual_output: &'life2 str,
        expected_keywords: &'life3 [&'life4 str],
    ) -> Pin<Box<dyn Future<Output = f64> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
}
Expand description

Async trait for evaluation metrics.

Implement this to add custom scoring logic.

Required Methods§

Source

fn name(&self) -> &'static str

Metric name — used as the key in TestResult.scores.

Source

fn score<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, input: &'life1 str, actual_output: &'life2 str, expected_keywords: &'life3 [&'life4 str], ) -> Pin<Box<dyn Future<Output = f64> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Score the actual output.

Returns a score from 0.0 (worst) to 1.0 (best).

Implementors§