objectiveai_api/vector/completions/usage_handler/
log_usage_handler.rs1use crate::ctx;
4use std::sync::Arc;
5
6pub struct LogUsageHandler;
8
9#[async_trait::async_trait]
10impl<CTXEXT> super::UsageHandler<CTXEXT> for LogUsageHandler
11where
12 CTXEXT: Send + Sync + 'static,
13{
14 async fn handle_usage(
15 &self,
16 _ctx: ctx::Context<CTXEXT>,
17 _request: Arc<objectiveai::vector::completions::request::VectorCompletionCreateParams>,
18 response: objectiveai::vector::completions::response::unary::VectorCompletion,
19 ) {
20 println!(
21 "[{}] cost: {}",
22 response.id.as_str(),
23 response.usage.total_cost,
24 );
25 }
26}