Struct Eval

Source
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/attempts
  • count: 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 / count as a floating-point number
  • Sample Size: count determines statistical significance
  • Confidence: Higher count values 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

Source

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/attempts
  • count - 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());
Source

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());
Source

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());
Source

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 Clone for Eval

Source§

fn clone(&self) -> Eval

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Eval

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Eval

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Format this evaluation value for display.

This implementation formats the evaluation statistics as "score, count" using the standard string representation.

§Arguments
  • f - The formatter to write to
§Returns

A fmt::Result indicating success or failure of the formatting operation.

Source§

impl ExpressionLike for Eval

Source§

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 for Eval values)
§Returns

Returns Ok(Value::Eval(self.clone())) containing the evaluation statistics.

Source§

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

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

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.

Source§

impl PartialEq for Eval

Source§

fn eq(&self, other: &Eval) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T> ToStringFallible for T
where T: Display,

§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,