Skip to main content

Classifier

Trait Classifier 

Source
pub trait Classifier: Send + Sync {
    // Required method
    fn score<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        state: &'life1 mut State,
        request: &'life2 mut Request,
        driver: &'life3 Driver,
    ) -> Pin<Box<dyn Future<Output = Result<(Classification, Option<Response>)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;

    // Provided methods
    fn tracks_answers(&self) -> bool { ... }
    fn observe_answer(&self, _state: &mut State, _answer: AnswerSummary) { ... }
}
Expand description

Scores targets from the current request and the composition’s state.

Required Methods§

Source

fn score<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, state: &'life1 mut State, request: &'life2 mut Request, driver: &'life3 Driver, ) -> Pin<Box<dyn Future<Output = Result<(Classification, Option<Response>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Score the classifier’s targets given the current state and request.

driver lets a classifier inspect runtime models and offload model calls.

request is borrowed mutably so a classifier may rewrite it in place — inject a system prompt, drop tools, compact history. The edit is not scoped to this call: later classifiers in the cascade score the rewritten request, and it is the rewritten request that is finally sent to the selected model. Most classifiers only read it.

Provided Methods§

Source

fn tracks_answers(&self) -> bool

Whether a stateful composition should request served-answer reports.

Source

fn observe_answer(&self, _state: &mut State, _answer: AnswerSummary)

Folds the answer the host served for this session into the composition’s state.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§