Skip to main content

PredictHandler

Trait PredictHandler 

Source
pub trait PredictHandler:
    Send
    + Sync
    + 'static {
    // Required methods
    fn setup<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), SetupError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn predict<'life0, 'async_trait>(
        &'life0 self,
        slot: SlotId,
        id: String,
        input: Value,
        slot_sender: Arc<SlotSender>,
        context: HashMap<String, String>,
    ) -> Pin<Box<dyn Future<Output = PredictResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn cancel(&self, slot: SlotId);

    // Provided method
    fn healthcheck<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = HealthcheckResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Trait for the prediction handler - abstracts the Python integration.

Required Methods§

Source

fn setup<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), SetupError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initialize the predictor (load model, run setup).

Source

fn predict<'life0, 'async_trait>( &'life0 self, slot: SlotId, id: String, input: Value, slot_sender: Arc<SlotSender>, context: HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = PredictResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Run a prediction.

Source

fn cancel(&self, slot: SlotId)

Request cancellation of prediction on a slot.

Provided Methods§

Source

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

Run user-defined healthcheck. Default: healthy.

Implementors§