objectiveai-api 2.0.5

ObjectiveAI API Server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Usage handler trait definition.

use crate::ctx;
use std::sync::Arc;

/// Trait for handling usage tracking after chat completions.
pub trait UsageHandler<CTXEXT> {
    /// Called after a chat completion finishes to record usage.
    ///
    /// The `request` is `None` when called from vector completions.
    fn handle_usage(
        &self,
        ctx: ctx::Context<CTXEXT, impl crate::ctx::persistent_cache::PersistentCacheClient>,
        request: Arc<objectiveai_sdk::agent::completions::request::AgentCompletionCreateParams>,
        response: objectiveai_sdk::agent::completions::response::unary::AgentCompletion,
    ) -> impl std::future::Future<Output = ()> + Send + 'static;
}