youssefleb commited on
Commit
887afa5
·
verified ·
1 Parent(s): d824005

Update visuals.py

Browse files
Files changed (1) hide show
  1. visuals.py +14 -8
visuals.py CHANGED
@@ -22,6 +22,7 @@ def create_progress_chart(log_data):
22
  scores = attempt.get("scores", {})
23
  values = [scores.get(cat, 0) for cat in categories]
24
 
 
25
  values += [values[0]]
26
  radar_categories = categories + [categories[0]]
27
 
@@ -67,6 +68,7 @@ def create_calibration_table(log_data):
67
 
68
  score = 0
69
  if isinstance(score_data, dict):
 
70
  if role == "Plant":
71
  score = score_data.get("Novelty", {}).get("score", 0)
72
  elif role == "Implementer":
@@ -87,24 +89,28 @@ def create_cost_summary(log_data):
87
  Creates a Markdown summary of costs based on usage data found in the log.
88
  """
89
  if not log_data or "financial_report" not in log_data:
90
- return "**No Financial Data Available**"
91
 
92
  fin = log_data["financial_report"]
93
- total = fin.get("total_cost", 0)
94
- calib = fin.get("calibration_cost", 0)
95
- gen = fin.get("generation_cost", 0)
96
 
97
  # Calculate Total Tokens
98
- total_input = sum(u.get("input", 0) for u in fin.get("usage_breakdown", []))
99
- total_output = sum(u.get("output", 0) for u in fin.get("usage_breakdown", []))
 
100
 
101
  # Model Usage Breakdown
102
  models_used = {}
103
- for u in fin.get("usage_breakdown", []):
104
  m = u.get("model", "Unknown")
105
  models_used[m] = models_used.get(m, 0) + 1
106
 
107
- model_str = ", ".join([f"{k} ({v} calls)" for k,v in models_used.items()])
 
 
 
108
 
109
  md = f"""
110
  ### 💰 Financial Intelligence Report
 
22
  scores = attempt.get("scores", {})
23
  values = [scores.get(cat, 0) for cat in categories]
24
 
25
+ # Close the loop for radar chart
26
  values += [values[0]]
27
  radar_categories = categories + [categories[0]]
28
 
 
68
 
69
  score = 0
70
  if isinstance(score_data, dict):
71
+ # Extract the specific metric score relevant to that Role
72
  if role == "Plant":
73
  score = score_data.get("Novelty", {}).get("score", 0)
74
  elif role == "Implementer":
 
89
  Creates a Markdown summary of costs based on usage data found in the log.
90
  """
91
  if not log_data or "financial_report" not in log_data:
92
+ return "### ⚠️ Financial Data Unavailable\n*Could not retrieve usage statistics.*"
93
 
94
  fin = log_data["financial_report"]
95
+ total = fin.get("total_cost", 0.0)
96
+ calib = fin.get("calibration_cost", 0.0)
97
+ gen = fin.get("generation_cost", 0.0)
98
 
99
  # Calculate Total Tokens
100
+ breakdown = fin.get("usage_breakdown", [])
101
+ total_input = sum(u.get("input", 0) for u in breakdown)
102
+ total_output = sum(u.get("output", 0) for u in breakdown)
103
 
104
  # Model Usage Breakdown
105
  models_used = {}
106
+ for u in breakdown:
107
  m = u.get("model", "Unknown")
108
  models_used[m] = models_used.get(m, 0) + 1
109
 
110
+ if not models_used:
111
+ model_str = "None recorded"
112
+ else:
113
+ model_str = ", ".join([f"{k} ({v} calls)" for k,v in models_used.items()])
114
 
115
  md = f"""
116
  ### 💰 Financial Intelligence Report