Skip to main content

Completion

Trait Completion 

Source
pub trait Completion: Send + Sync {
    // Required method
    fn complete(
        &self,
        request: CompletionRequest,
        cancel: CancellationToken,
    ) -> BoxFuture<Result<ModelDecision, ActorError>>;

    // Provided method
    fn reported_prompt_tokens(&self) -> Option<u64> { ... }
}
Expand description

Model call for the infer transition.

Cancellation ownership: the harness passes the host token into Self::complete and never races the call. The implementation owns mid-flight cancellation — the interactive completion returns a ModelDecision::Text carrying the interrupted-answer sentence so the turn settles with its transcript — and must return promptly once the token fires.

Required Methods§

Provided Methods§

Source

fn reported_prompt_tokens(&self) -> Option<u64>

Provider-reported prompt tokens for the completion that just returned. None when the provider omitted usage. The infer transition copies this onto the model.turn fact so a later fold can compact from it.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§