Commit Graph

8 Commits

  • Refactor executor error handling and usage reporting
    - Updated the Execute methods in various executors (GeminiCLIExecutor, GeminiExecutor, IFlowExecutor, OpenAICompatExecutor, QwenExecutor) to return a response and error as named return values for improved clarity.
    - Enhanced error handling by deferring failure tracking in usage reporters, ensuring that failures are reported correctly.
    - Improved response body handling by ensuring proper closure and error logging for HTTP responses across all executors.
    - Added failure tracking and reporting in the usage reporter to capture unsuccessful requests.
    - Updated the usage logging structure to include a 'Failed' field for better tracking of request outcomes.
    - Adjusted the logic in the RequestStatistics and Record methods to accommodate the new failure tracking mechanism.
  • feat(usage): add support for tracking request source in usage records
    - Introduced `Source` field to usage-related structs for better origin tracking.
    - Updated `newUsageReporter` to resolve and populate the `Source` attribute.
    - Implemented `resolveUsageSource` to determine source from auth metadata or API key.
  • feat(config, usage): add usage-statistics-enabled option and dynamic toggling
    - Introduced `usage-statistics-enabled` configuration to control in-memory usage aggregation.
    - Updated API to include handlers for managing `usage-statistics-enabled` and `logging-to-file` options.
    - Enhanced `watcher` to log changes to both configurations dynamically.
    - Updated documentation and examples to reflect new configuration options.
  • feat(usage): add in-memory usage statistics tracking and API endpoint
    - Introduced in-memory request statistics aggregation in `LoggerPlugin`.
    - Added new structures for detailed metrics collection (e.g., token breakdown, request success/failure).
    - Implemented `/usage` management API endpoint for retrieving aggregated statistics.
    - Updated management handlers to support the new usage statistics functionality.
    - Enhanced documentation to describe the usage metrics API.
  • chore(docs): add and refine package-level comments across modules
    - Added detailed package-level comments to improve documentation coverage.
    - Clarified parameter descriptions, return types, and functionality of exported methods across packages.
    - Enhanced overall code readability and API documentation consistency.
  • feat(usage): implement usage tracking infrastructure across executors
    - Added `LoggerPlugin` to log usage metrics for observability.
    - Introduced a new `Manager` to handle usage record queuing and plugin registration.
    - Integrated new usage reporter and detailed metrics parsing into executors, covering providers like OpenAI, Codex, Claude, and Gemini.
    - Improved token usage breakdown across streaming and non-streaming responses.