Spaces:
Running
Running
Pulastya B
commited on
Commit
·
7f3326d
1
Parent(s):
b213e33
Fix enhanced summary crash: handle best_model dict structure and add fallback
Browse files- src/orchestrator.py +33 -13
src/orchestrator.py
CHANGED
|
@@ -913,8 +913,13 @@ You are a DOER. Complete workflows based on user intent."""
|
|
| 913 |
if "models" in nested_result:
|
| 914 |
models_data = nested_result["models"]
|
| 915 |
if models_data:
|
| 916 |
-
# Find best model
|
| 917 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 918 |
best_model_data = models_data.get(best_model_name, {})
|
| 919 |
|
| 920 |
metrics["best_model"] = {
|
|
@@ -2147,25 +2152,40 @@ You are a DOER. Complete workflows based on user intent."""
|
|
| 2147 |
# Final response
|
| 2148 |
final_summary = final_content or "Analysis completed"
|
| 2149 |
|
| 2150 |
-
# 🎯 ENHANCED SUMMARY: Extract metrics and artifacts from workflow
|
| 2151 |
-
|
| 2152 |
-
|
| 2153 |
-
|
| 2154 |
-
|
| 2155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2156 |
|
| 2157 |
# 🧠 Save conversation to session memory
|
| 2158 |
if self.session:
|
| 2159 |
-
self.session.add_conversation(task_description,
|
| 2160 |
self.session_store.save(self.session)
|
| 2161 |
print(f"\n✅ Session saved: {self.session.session_id}")
|
| 2162 |
|
| 2163 |
result = {
|
| 2164 |
"status": "success",
|
| 2165 |
-
"summary":
|
| 2166 |
-
"metrics":
|
| 2167 |
-
"artifacts":
|
| 2168 |
-
"plots":
|
| 2169 |
"workflow_history": workflow_history,
|
| 2170 |
"iterations": iteration,
|
| 2171 |
"api_calls": self.api_calls_made,
|
|
|
|
| 913 |
if "models" in nested_result:
|
| 914 |
models_data = nested_result["models"]
|
| 915 |
if models_data:
|
| 916 |
+
# Find best model (best_model is a dict with 'name', 'score', 'model_path')
|
| 917 |
+
best_model_info = nested_result.get("best_model", {})
|
| 918 |
+
if isinstance(best_model_info, dict):
|
| 919 |
+
best_model_name = best_model_info.get("name", "")
|
| 920 |
+
else:
|
| 921 |
+
best_model_name = str(best_model_info) if best_model_info else ""
|
| 922 |
+
|
| 923 |
best_model_data = models_data.get(best_model_name, {})
|
| 924 |
|
| 925 |
metrics["best_model"] = {
|
|
|
|
| 2152 |
# Final response
|
| 2153 |
final_summary = final_content or "Analysis completed"
|
| 2154 |
|
| 2155 |
+
# 🎯 ENHANCED SUMMARY: Extract metrics and artifacts from workflow (with error handling)
|
| 2156 |
+
try:
|
| 2157 |
+
enhanced_summary = self._generate_enhanced_summary(
|
| 2158 |
+
workflow_history,
|
| 2159 |
+
final_summary,
|
| 2160 |
+
task_description
|
| 2161 |
+
)
|
| 2162 |
+
summary_text = enhanced_summary["text"]
|
| 2163 |
+
metrics_data = enhanced_summary.get("metrics", {})
|
| 2164 |
+
artifacts_data = enhanced_summary.get("artifacts", {})
|
| 2165 |
+
plots_data = enhanced_summary.get("plots", [])
|
| 2166 |
+
print(f"✅ Enhanced summary generated with {len(plots_data)} plots, {len(metrics_data)} metrics")
|
| 2167 |
+
except Exception as e:
|
| 2168 |
+
print(f"⚠️ Enhanced summary generation failed: {e}")
|
| 2169 |
+
import traceback
|
| 2170 |
+
traceback.print_exc()
|
| 2171 |
+
# Fallback: use basic summary
|
| 2172 |
+
summary_text = final_summary
|
| 2173 |
+
metrics_data = {}
|
| 2174 |
+
artifacts_data = {}
|
| 2175 |
+
plots_data = []
|
| 2176 |
|
| 2177 |
# 🧠 Save conversation to session memory
|
| 2178 |
if self.session:
|
| 2179 |
+
self.session.add_conversation(task_description, summary_text)
|
| 2180 |
self.session_store.save(self.session)
|
| 2181 |
print(f"\n✅ Session saved: {self.session.session_id}")
|
| 2182 |
|
| 2183 |
result = {
|
| 2184 |
"status": "success",
|
| 2185 |
+
"summary": summary_text,
|
| 2186 |
+
"metrics": metrics_data,
|
| 2187 |
+
"artifacts": artifacts_data,
|
| 2188 |
+
"plots": plots_data,
|
| 2189 |
"workflow_history": workflow_history,
|
| 2190 |
"iterations": iteration,
|
| 2191 |
"api_calls": self.api_calls_made,
|