Spaces:
Running
Running
Update visuals.py
Browse files- visuals.py +12 -6
visuals.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
# Handles all data visualization logic for MudabbirAI
|
| 3 |
import pandas as pd
|
| 4 |
import plotly.graph_objects as go
|
|
|
|
| 5 |
|
| 6 |
def create_progress_chart(log_data):
|
| 7 |
"""
|
|
@@ -20,7 +21,6 @@ def create_progress_chart(log_data):
|
|
| 20 |
|
| 21 |
for i, attempt in enumerate(attempts):
|
| 22 |
scores = attempt.get("scores", {})
|
| 23 |
-
# Handle case where scores might be missing
|
| 24 |
values = [scores.get(cat, 0) for cat in categories]
|
| 25 |
|
| 26 |
# Close the loop for radar chart
|
|
@@ -64,12 +64,11 @@ def create_calibration_table(log_data):
|
|
| 64 |
data = []
|
| 65 |
for item in details:
|
| 66 |
role = item["role"]
|
| 67 |
-
|
| 68 |
score_data = item.get("score", {})
|
| 69 |
|
| 70 |
score = 0
|
| 71 |
if isinstance(score_data, dict):
|
| 72 |
-
# Extract the specific metric score relevant to that Role
|
| 73 |
if role == "Plant":
|
| 74 |
score = score_data.get("Novelty", {}).get("score", 0)
|
| 75 |
elif role == "Implementer":
|
|
@@ -77,7 +76,15 @@ def create_calibration_table(log_data):
|
|
| 77 |
elif role == "Monitor":
|
| 78 |
score = score_data.get("Cultural_Appropriateness", {}).get("score", 0)
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
if not data: return None
|
| 83 |
|
|
@@ -89,7 +96,6 @@ def create_cost_summary(log_data):
|
|
| 89 |
"""
|
| 90 |
Creates a Markdown summary of costs based on usage data found in the log.
|
| 91 |
"""
|
| 92 |
-
# Robust check in case financial_report is missing or empty
|
| 93 |
if not log_data or "financial_report" not in log_data:
|
| 94 |
return "### ⚠️ Financial Data Unavailable\n*Could not retrieve usage statistics.*"
|
| 95 |
|
|
@@ -103,7 +109,7 @@ def create_cost_summary(log_data):
|
|
| 103 |
total_input = sum(u.get("input", 0) for u in breakdown)
|
| 104 |
total_output = sum(u.get("output", 0) for u in breakdown)
|
| 105 |
|
| 106 |
-
# Model Usage Breakdown
|
| 107 |
models_used = {}
|
| 108 |
for u in breakdown:
|
| 109 |
m = u.get("model", "Unknown")
|
|
|
|
| 2 |
# Handles all data visualization logic for MudabbirAI
|
| 3 |
import pandas as pd
|
| 4 |
import plotly.graph_objects as go
|
| 5 |
+
import config # Import config to access specific model names
|
| 6 |
|
| 7 |
def create_progress_chart(log_data):
|
| 8 |
"""
|
|
|
|
| 21 |
|
| 22 |
for i, attempt in enumerate(attempts):
|
| 23 |
scores = attempt.get("scores", {})
|
|
|
|
| 24 |
values = [scores.get(cat, 0) for cat in categories]
|
| 25 |
|
| 26 |
# Close the loop for radar chart
|
|
|
|
| 64 |
data = []
|
| 65 |
for item in details:
|
| 66 |
role = item["role"]
|
| 67 |
+
model_provider = item["llm"] # e.g., "Gemini", "Anthropic"
|
| 68 |
score_data = item.get("score", {})
|
| 69 |
|
| 70 |
score = 0
|
| 71 |
if isinstance(score_data, dict):
|
|
|
|
| 72 |
if role == "Plant":
|
| 73 |
score = score_data.get("Novelty", {}).get("score", 0)
|
| 74 |
elif role == "Implementer":
|
|
|
|
| 76 |
elif role == "Monitor":
|
| 77 |
score = score_data.get("Cultural_Appropriateness", {}).get("score", 0)
|
| 78 |
|
| 79 |
+
# --- NEW: Retrieve specific model name from config for transparency ---
|
| 80 |
+
specific_model_name = config.MODELS.get(model_provider, {}).get("default", "")
|
| 81 |
+
if specific_model_name:
|
| 82 |
+
# Format: "Anthropic\n(claude-3-5-haiku...)"
|
| 83 |
+
display_name = f"{model_provider}\n({specific_model_name})"
|
| 84 |
+
else:
|
| 85 |
+
display_name = model_provider
|
| 86 |
+
|
| 87 |
+
data.append({"Role": role, "Model": display_name, "Score": score})
|
| 88 |
|
| 89 |
if not data: return None
|
| 90 |
|
|
|
|
| 96 |
"""
|
| 97 |
Creates a Markdown summary of costs based on usage data found in the log.
|
| 98 |
"""
|
|
|
|
| 99 |
if not log_data or "financial_report" not in log_data:
|
| 100 |
return "### ⚠️ Financial Data Unavailable\n*Could not retrieve usage statistics.*"
|
| 101 |
|
|
|
|
| 109 |
total_input = sum(u.get("input", 0) for u in breakdown)
|
| 110 |
total_output = sum(u.get("output", 0) for u in breakdown)
|
| 111 |
|
| 112 |
+
# Model Usage Breakdown
|
| 113 |
models_used = {}
|
| 114 |
for u in breakdown:
|
| 115 |
m = u.get("model", "Unknown")
|