Skip to main content

ModelExecutor

Trait ModelExecutor 

Source
pub trait ModelExecutor: Send + Sync {
    // Required methods
    fn execute<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        inputs: &'life1 [Input],
        model_params: Option<&'life2 ModelParameters>,
        context: &'life3 ExecutionContext,
        config: &'life4 ExecutionConfig,
    ) -> Pin<Box<dyn Future<Output = Result<ExecutionResult, ReplayError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn supports_model(&self, model_name: &str) -> bool;
    fn executor_name(&self) -> &str;

    // Provided method
    fn compare_outputs(
        &self,
        original: &[Output],
        replayed: &[Output],
        tolerance: f64,
    ) -> ComparisonResult { ... }
}
Expand description

Async trait for model re-execution during replay.

Implementors provide the bridge between the replay engine and actual model inference (OpenAI, Anthropic, local models, etc.).

§Example

struct OpenAIExecutor { client: OpenAIClient }

#[async_trait]
impl ModelExecutor for OpenAIExecutor {
    async fn execute(
        &self, inputs: &[Input], model_params: Option<&ModelParameters>,
        context: &ExecutionContext, config: &ExecutionConfig,
    ) -> Result<ExecutionResult, ReplayError> {
        let response = self.client.chat(inputs, model_params).await?;
        Ok(ExecutionResult { outputs: vec![...], ... })
    }
}

Required Methods§

Source

fn execute<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, inputs: &'life1 [Input], model_params: Option<&'life2 ModelParameters>, context: &'life3 ExecutionContext, config: &'life4 ExecutionConfig, ) -> Pin<Box<dyn Future<Output = Result<ExecutionResult, ReplayError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Execute a model with the given inputs and parameters

Source

fn supports_model(&self, model_name: &str) -> bool

Check if this executor supports the given model

Source

fn executor_name(&self) -> &str

Get executor name for logging/auditing

Provided Methods§

Source

fn compare_outputs( &self, original: &[Output], replayed: &[Output], tolerance: f64, ) -> ComparisonResult

Compare original outputs with replayed outputs

Implementors§