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§
Sourcefn 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,
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).