Skip to main content

DecisionEngine

Trait DecisionEngine 

Source
pub trait DecisionEngine: Send + Sync {
    // Required methods
    fn backend_id(&self) -> &str;
    fn evaluate<'life0, 'async_trait>(
        &'life0 self,
        req: SystemRequest,
    ) -> Pin<Box<dyn Future<Output = Result<SystemResponse, EngineError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn model_metadata(&self) -> ModelInfo { ... }
    fn estimate_input_tokens(&self, req: &SystemRequest) -> u32 { ... }
}
Expand description

The trait every backend implements. The engine is runtime-agnostic: it doesn’t know it’s being served over HTTP or gRPC — that’s deliberate. Callers pass SystemRequest in and get SystemResponse back.

Required Methods§

Source

fn backend_id(&self) -> &str

Identifier of this backend, e.g. "mock", "qwen-3b-candle".

Source

fn evaluate<'life0, 'async_trait>( &'life0 self, req: SystemRequest, ) -> Pin<Box<dyn Future<Output = Result<SystemResponse, EngineError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Evaluate a single request. Returns one answer per question id.

Provided Methods§

Source

fn model_metadata(&self) -> ModelInfo

Public metadata shown by GET /v1/models. The default is a minimal mock entry; real backends should override with a real description and release date.

Source

fn estimate_input_tokens(&self, req: &SystemRequest) -> u32

Estimate input tokens (cheap, before evaluation). The mock uses a rough bytes / 4 heuristic for state, instructions, and criteria; real backends will use a tokenizer.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§