Commit 8dc11ce
authored
API Usage Tracking (#45)
- Add Usage, TokenUsage data classes and UsageTrackableMixin for recording resource consumption
- Track token usage automatically in ModelAdapter after each chat() call
- Add CostCalculator protocol with StaticPricingCalculator and LiteLLMCostCalculator implementations
- Support cost_calculator and model_id on AgentAdapter with auto-detection for smolagents, CAMEL, and LlamaIndex
- Expose live totals via benchmark.usage and benchmark.usage_by_component
- Add UsageReporter for post-hoc analysis by task, component, or model
- Add usage tracking guide and API reference docs
- Update 5-A-Day benchmark example with usage tracking1 parent acffbbb commit 8dc11ce
36 files changed
Lines changed: 4732 additions & 173 deletions
File tree
- docs
- guides
- reference
- examples/five_a_day_benchmark
- maseval
- core
- interface
- agents
- inference
- tests
- test_core
- test_benchmark
- test_interface
- test_agent_integration
- test_model_integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
274 | 273 | | |
275 | 274 | | |
276 | 275 | | |
| |||
301 | 300 | | |
302 | 301 | | |
303 | 302 | | |
304 | | - | |
305 | | - | |
| 303 | + | |
| 304 | + | |
306 | 305 | | |
307 | | - | |
308 | | - | |
| 306 | + | |
| 307 | + | |
309 | 308 | | |
310 | 309 | | |
311 | 310 | | |
312 | 311 | | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | 312 | | |
317 | 313 | | |
318 | 314 | | |
319 | 315 | | |
320 | 316 | | |
321 | 317 | | |
322 | 318 | | |
| 319 | + | |
| 320 | + | |
323 | 321 | | |
324 | 322 | | |
325 | 323 | | |
| |||
540 | 538 | | |
541 | 539 | | |
542 | 540 | | |
543 | | - | |
| 541 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| 46 | + | |
| 47 | + | |
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
45 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
46 | 56 | | |
47 | 57 | | |
48 | 58 | | |
| |||
108 | 118 | | |
109 | 119 | | |
110 | 120 | | |
111 | | - | |
112 | | - | |
113 | 121 | | |
114 | 122 | | |
115 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
0 commit comments