feat: add model usage statistics with input/output token breakdown to stats command
Summary
This PR enhances the stats command to provide granular visibility into model usage. It introduces a new "MODEL USAGE" section that displays message counts, a breakdown of input vs. output tokens, and historical accumulated costs for each model used across sessions.
Changes
- Interface Update: Extended
SessionStatsto include amodelUsagerecord. - Aggregation Logic: Updated
aggregateSessionStatsto collect and sum usage metrics (messages, tokens, cost) per provider/model from assistant messages. - New Flag: Added
--models X, when given will show the models and the top X, if X is not given will show them all, sorted by total messages - UI Enhancement: Modified
displayStatsto render a sorted table of model usage, showing:- Message count
- Input Token count
- Output Token count
- Total Cost
Example Output
/review
should prolly require a flag to output this btw, and maybe a flag to limit # of models cause mine is huge
should prolly require a flag to output this btw, and maybe a flag to limit # of models cause mine is huge
that sounds fair! yeah sure, perhaps
stats --days X --models Y
just to follow the convention about days followed by the number of models we want to display? and if so, what sorting would we need? top Y in terms of usage?
@rekram1-node I pushed a change, so it is a flag now, with the option to also limit the amount of models sorted by top messages
/review
@rekram1-node do you think we could go with this? thanks!