display_ai_usage

Function display_ai_usage 

Source
pub fn display_ai_usage(usage: &AiUsageStats)
Expand description

Display comprehensive AI API usage statistics and cost information.

Presents detailed information about AI API calls including token usage, model information, and cost implications. This helps users understand their AI service consumption and manage usage costs effectively.

§Information Displayed

  • Model Name: The specific AI model used for processing
  • Token Breakdown: Detailed token usage by category
    • Prompt tokens: Input text sent to the AI
    • Completion tokens: AI-generated response text
    • Total tokens: Sum of prompt and completion tokens
  • Cost Implications: Helps users understand billing impact

§Format Example

🤖 AI API Call Details:
   Model: gpt-4-turbo-preview
   Prompt tokens: 1,247
   Completion tokens: 892
   Total tokens: 2,139

§Arguments

  • usage - AI usage statistics containing token counts and model information

§Examples

use subx_cli::cli::ui::display_ai_usage;
use subx_cli::services::ai::AiUsageStats;

let usage = AiUsageStats {
    model: "gpt-4-turbo-preview".to_string(),
    prompt_tokens: 1247,
    completion_tokens: 892,
    total_tokens: 2139,
};

display_ai_usage(&usage);

§Use Cases

  • Cost monitoring: Track API usage for billing awareness
  • Performance analysis: Understand token efficiency
  • Debugging: Verify expected model usage
  • Optimization: Identify opportunities to reduce token consumption