Class UsageStatistics

java.lang.Object
org.machanism.machai.ai.manager.UsageStatistics

public class UsageStatistics extends Object
Manages and aggregates usage statistics for GenAI models.
  • Constructor Details

    • UsageStatistics

      public UsageStatistics()
  • Method Details

    • addUsage

      public static void addUsage(String modelId, Usage usage)
      Adds a single Usage record for a specific model identifier.
      Parameters:
      modelId - model identifier (e.g., "OpenAI:gpt-4o-mini")
      usage - usage to add
    • logUsage

      public static void logUsage()
      Logs a summary of the aggregated Usage records (all models).
    • logUsageForModel

      public static void logUsageForModel(String modelId)
      Logs a summary of the aggregated Usage records for a specific model.
      Parameters:
      modelId - model identifier (e.g., "OpenAI:gpt-4o-mini")
    • getUsageForModel

      public static List<Usage> getUsageForModel(String modelId)
      Returns the aggregated usage list for a specific model.
      Parameters:
      modelId - model identifier
      Returns:
      list of Usage records, or empty list if none
    • getAllModelUsages

      public static Map<String,List<Usage>> getAllModelUsages()
      Returns the aggregated usage map for all models.
      Returns:
      map of modelId to list of Usage records