Skip to main content

Predictor

Trait Predictor 

Source
pub trait Predictor: Send + Sync {
    // Required method
    fn predict<'life0, 'life1, 'async_trait>(
        &'life0 self,
        input: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<String, EvalError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn report_token_usage<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Option<TokenUsage>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn begin_run<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _run_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Predictor trait (the object under evaluation: LLMChain / Agent, etc.)

Required Methods§

Source

fn predict<'life0, 'life1, 'async_trait>( &'life0 self, input: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<String, EvalError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Predicts on a single input, returning the text result.

Provided Methods§

Source

fn report_token_usage<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<TokenUsage>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reports the token usage of the most recent predict call, if the predictor meters it (E1). Defaults to None — evaluators with no token metering keep the report’s cost ledger at zero (zero behavior change).

Source

fn begin_run<'life0, 'life1, 'async_trait>( &'life0 self, _run_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called once before the dataset loop with the evaluation run id (B9).

Default no-op. A system under test that runs chains/agents can store the id and put it into RunnableConfig.metadata["trace_id"]; the agent executor then propagates it to callback/OTel spans, making the eval report’s run id the join key to traces.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§