use std::sync::Arc;
use crate::eval::scoring::Scorer;
use crate::model::{SharedEmbeddingModel, SharedModel};
#[derive(Debug, Clone)]
pub struct EvalScenario {
pub input: String,
pub scorers: Vec<Scorer>,
pub max_iterations: Option<usize>,
pub max_cost: Option<f64>,
}
impl EvalScenario {
pub fn new(input: impl Into<String>) -> Self {
Self {
input: input.into(),
scorers: Vec::new(),
max_iterations: None,
max_cost: None,
}
}
pub fn expect_contains(mut self, substring: impl Into<String>) -> Self {
self.scorers.push(Scorer::Contains(substring.into()));
self
}
pub fn expect_exact(mut self, expected: impl Into<String>) -> Self {
self.scorers.push(Scorer::ExactMatch(expected.into()));
self
}
pub fn expect_regex(mut self, pattern: impl Into<String>) -> Self {
self.scorers.push(Scorer::Regex(pattern.into()));
self
}
pub fn expect_custom<F>(mut self, scorer: F) -> Self
where
F: Fn(&str) -> bool + Send + Sync + 'static,
{
self.scorers.push(Scorer::Custom(Arc::new(scorer)));
self
}
pub fn expect_semantic(
mut self,
expected: impl Into<String>,
embedding_model: SharedEmbeddingModel,
threshold: f64,
) -> Self {
self.scorers
.push(Scorer::semantic(expected, embedding_model, threshold));
self
}
pub fn expect_llm_judge(
mut self,
rubric: impl Into<String>,
model: SharedModel,
) -> Self {
self.scorers.push(Scorer::llm_judge(rubric, model));
self
}
pub fn with_max_iterations(mut self, max: usize) -> Self {
self.max_iterations = Some(max);
self
}
pub fn with_max_cost(mut self, max: f64) -> Self {
self.max_cost = Some(max);
self
}
}