feat(gui): implement Phases 2-5 of Comprehensive GUI UX track
- Add cost tracking with new cost_tracker.py module - Enhance Track Proposal modal with editable titles and goals - Add Conductor Setup summary and New Track creation form to MMA Dashboard - Implement Task DAG editing (add/delete tickets) and track-scoped discussion - Add visual polish: color-coded statuses, tinted progress bars, and node indicators - Support live worker streaming from AI providers to GUI panels - Fix numerous integration test regressions and stabilize headless service
This commit is contained in:
28
cost_tracker.py
Normal file
28
cost_tracker.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import re
|
||||
|
||||
# Pricing per 1M tokens in USD
|
||||
MODEL_PRICING = [
|
||||
(r"gemini-2\.5-flash-lite", {"input_per_mtok": 0.075, "output_per_mtok": 0.30}),
|
||||
(r"gemini-2\.5-flash", {"input_per_mtok": 0.15, "output_per_mtok": 0.60}),
|
||||
(r"gemini-3-flash-preview", {"input_per_mtok": 0.15, "output_per_mtok": 0.60}),
|
||||
(r"gemini-3\.1-pro-preview", {"input_per_mtok": 3.50, "output_per_mtok": 10.50}),
|
||||
(r"claude-.*-sonnet", {"input_per_mtok": 3.0, "output_per_mtok": 15.0}),
|
||||
(r"claude-.*-opus", {"input_per_mtok": 15.0, "output_per_mtok": 75.0}),
|
||||
(r"deepseek-v3", {"input_per_mtok": 0.27, "output_per_mtok": 1.10}),
|
||||
]
|
||||
|
||||
def estimate_cost(model: str, input_tokens: int, output_tokens: int) -> float:
|
||||
"""
|
||||
Estimate the cost of a model call based on input and output tokens.
|
||||
Returns the total cost in USD.
|
||||
"""
|
||||
if not model:
|
||||
return 0.0
|
||||
|
||||
for pattern, rates in MODEL_PRICING:
|
||||
if re.search(pattern, model, re.IGNORECASE):
|
||||
input_cost = (input_tokens / 1_000_000) * rates["input_per_mtok"]
|
||||
output_cost = (output_tokens / 1_000_000) * rates["output_per_mtok"]
|
||||
return input_cost + output_cost
|
||||
|
||||
return 0.0
|
||||
Reference in New Issue
Block a user