objectiveai_api/chat/completions/usage_handler/usage_handler.rs
1//! Usage handler trait definition.
2
3use crate::ctx;
4use std::sync::Arc;
5
6/// Trait for handling usage tracking after chat completions.
7#[async_trait::async_trait]
8pub trait UsageHandler<CTXEXT> {
9 /// Called after a chat completion finishes to record usage.
10 ///
11 /// The `request` is `None` when called from vector completions.
12 async fn handle_usage(
13 &self,
14 ctx: ctx::Context<CTXEXT>,
15 request: Option<Arc<objectiveai::chat::completions::request::ChatCompletionCreateParams>>,
16 response: objectiveai::chat::completions::response::unary::ChatCompletion,
17 );
18}