pub struct Eval { /* private fields */ }Expand description
Evaluation scoring statistics for workflow performance tracking.
The Eval struct represents statistical data about evaluation attempts,
typically used to track success rates, inference accuracy, or task completion
metrics in agentic workflow applications.
§Fields
score: Number of successful evaluations/attemptscount: Total number of evaluations/attempts
§Examples
use aimx::values::Eval;
// Create evaluation with 75% success rate
let eval_value = Eval::new(3, 4);
assert!(eval_value.is_eval());
// Record additional results by extracting the Eval struct
let after_pass = if let aimx::Value::Eval(eval) = &eval_value {
eval.set_pass() // Now 4/5
} else {
panic!("Expected Eval value");
};
let after_fail = if let aimx::Value::Eval(eval) = &after_pass {
eval.set_fail() // Now 4/6
} else {
panic!("Expected Eval value");
};
// Calculate current success rate
let rate = if let aimx::Value::Eval(eval) = &after_fail {
eval.score()
} else {
panic!("Expected Eval value");
};§Statistical Properties
- Success Rate:
score / countas a floating-point number - Sample Size:
countdetermines statistical significance - Confidence: Higher
countvalues provide more reliable metrics
§Integration
Eval values are wrapped in crate::value::Value::Eval variants and can
be used throughout the AIMX expression system. They implement the
crate::evaluate::ExpressionLike trait for seamless integration.
Implementations§
Source§impl Eval
impl Eval
Sourcepub fn new(score: u32, count: u32) -> Value
pub fn new(score: u32, count: u32) -> Value
Create a new evaluation value with the specified score and count.
This method constructs an Eval value wrapped in a crate::value::Value::Eval
variant. The resulting value can be used directly in AIMX expressions.
§Arguments
score- Number of successful evaluations/attemptscount- Total number of evaluations/attempts
§Returns
Returns a crate::value::Value::Eval variant containing the evaluation statistics.
§Examples
use aimx::values::Eval;
let eval_value = Eval::new(5, 10);
assert!(eval_value.is_eval());Sourcepub fn set_pass(&self) -> Value
pub fn set_pass(&self) -> Value
Record a successful evaluation attempt.
This method returns a new evaluation value with both the score and count incremented by 1, representing a successful outcome.
§Returns
Returns a new crate::value::Value::Eval with updated statistics.
§Examples
use aimx::values::Eval;
let eval_value = Eval::new(3, 5);
assert!(eval_value.is_eval());
let after_success = if let aimx::Value::Eval(eval) = &eval_value {
eval.set_pass()
} else {
panic!("Expected Eval value");
};
// Now represents 4 successes out of 6 attempts
assert!(after_success.is_eval());Sourcepub fn set_fail(&self) -> Value
pub fn set_fail(&self) -> Value
Record a failed evaluation attempt.
This method returns a new evaluation value with only the count incremented by 1, representing a failed outcome.
§Returns
Returns a new crate::value::Value::Eval with updated statistics.
§Examples
use aimx::values::Eval;
let eval_value = Eval::new(3, 5);
assert!(eval_value.is_eval());
let after_failure = if let aimx::Value::Eval(eval) = &eval_value {
eval.set_fail()
} else {
panic!("Expected Eval value");
};
// Now represents 3 successes out of 6 attempts
assert!(after_failure.is_eval());Sourcepub fn score(&self) -> Value
pub fn score(&self) -> Value
Calculate and return the success rate as a numeric value.
This method computes the success rate as score / count and returns
it as a crate::value::Value::Literal containing a floating-point number.
If count is 0, returns 0.0 to avoid division by zero.
§Returns
Returns a crate::value::Value::Literal with the calculated success rate.
§Examples
use aimx::values::Eval;
let eval_value = Eval::new(3, 4);
assert!(eval_value.is_eval());
let rate = if let aimx::Value::Eval(eval) = &eval_value {
eval.score()
} else {
panic!("Expected Eval value");
};
// rate is Value::Literal(Literal::Number(0.75))
assert!(rate.is_number());Trait Implementations§
Source§impl ExpressionLike for Eval
impl ExpressionLike for Eval
Source§fn evaluate(&self, _context: &mut dyn ContextLike) -> Result<Value>
fn evaluate(&self, _context: &mut dyn ContextLike) -> Result<Value>
Evaluate this evaluation value in the provided context.
Since Eval values are constant (they represent statistical data),
this method simply returns a clone of the current value without
performing any context-dependent computation.
§Arguments
_context- The evaluation context (unused forEvalvalues)
§Returns
Returns Ok(Value::Eval(self.clone())) containing the evaluation statistics.
Source§fn write(&self, writer: &mut Writer)
fn write(&self, writer: &mut Writer)
Write this evaluation value to the provided writer.
This method formats the evaluation statistics as "score, count"
and writes them to the writer using the appropriate formatting.
§Arguments
writer- The writer to write the formatted evaluation to
Source§fn to_sanitized(&self) -> String
fn to_sanitized(&self) -> String
Convert this evaluation value to a sanitized string representation.
This method produces a string with special characters escaped
to make it safe for various contexts. For Eval values, this
is equivalent to the standard string representation.
§Returns
A sanitized string representation of this evaluation value.
Source§fn to_formula(&self) -> String
fn to_formula(&self) -> String
Convert this evaluation value to a formula string representation.
This method produces a string with proper quoting and escaping
for use in formulas. For Eval values, this is equivalent to
the standard string representation.
§Returns
A formula string representation of this evaluation value.
impl StructuralPartialEq for Eval
Auto Trait Implementations§
impl Freeze for Eval
impl RefUnwindSafe for Eval
impl Send for Eval
impl Sync for Eval
impl Unpin for Eval
impl UnwindSafe for Eval
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.