Spaces:
Running
Running
Commit ·
1e144a5
1
Parent(s): 836f1d8
add
Browse files
backend/routers/graph_comparison.py
CHANGED
|
@@ -120,6 +120,20 @@ def _format_graph_data(graph: KnowledgeGraph) -> Dict[str, Any]:
|
|
| 120 |
"processing_run_id": graph.processing_run_id
|
| 121 |
}
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
# Add trace information if available
|
| 124 |
if graph.trace:
|
| 125 |
graph_data["trace_title"] = graph.trace.title
|
|
@@ -210,14 +224,16 @@ async def compare_graphs(
|
|
| 210 |
"filename": graph1.filename,
|
| 211 |
"creation_timestamp": graph1.creation_timestamp.isoformat() if graph1.creation_timestamp else None,
|
| 212 |
"trace_id": graph1.trace_id,
|
| 213 |
-
"trace_title": graph1.trace.title if graph1.trace else None
|
|
|
|
| 214 |
},
|
| 215 |
"graph2": {
|
| 216 |
"id": graph2.id,
|
| 217 |
"filename": graph2.filename,
|
| 218 |
"creation_timestamp": graph2.creation_timestamp.isoformat() if graph2.creation_timestamp else None,
|
| 219 |
"trace_id": graph2.trace_id,
|
| 220 |
-
"trace_title": graph2.trace.title if graph2.trace else None
|
|
|
|
| 221 |
},
|
| 222 |
"comparison_timestamp": metrics.graph1_stats.get('name', 'Unknown'), # Will be set properly
|
| 223 |
"similarity_threshold": general_threshold,
|
|
@@ -392,4 +408,4 @@ async def clear_cache():
|
|
| 392 |
raise
|
| 393 |
except Exception as e:
|
| 394 |
logger.error(f"Error clearing cache: {str(e)}")
|
| 395 |
-
raise HTTPException(status_code=500, detail=f"Failed to clear cache: {str(e)}")
|
|
|
|
| 120 |
"processing_run_id": graph.processing_run_id
|
| 121 |
}
|
| 122 |
|
| 123 |
+
# Surface human-friendly system_name and summary when available in stored graph_data
|
| 124 |
+
try:
|
| 125 |
+
gd = graph.graph_data or {}
|
| 126 |
+
if isinstance(gd, dict):
|
| 127 |
+
sys_name = gd.get("system_name")
|
| 128 |
+
sys_summary = gd.get("system_summary")
|
| 129 |
+
if sys_name:
|
| 130 |
+
graph_data["system_name"] = sys_name
|
| 131 |
+
if sys_summary:
|
| 132 |
+
graph_data["system_summary"] = sys_summary
|
| 133 |
+
except Exception:
|
| 134 |
+
# Non-fatal: ignore extraction issues
|
| 135 |
+
pass
|
| 136 |
+
|
| 137 |
# Add trace information if available
|
| 138 |
if graph.trace:
|
| 139 |
graph_data["trace_title"] = graph.trace.title
|
|
|
|
| 224 |
"filename": graph1.filename,
|
| 225 |
"creation_timestamp": graph1.creation_timestamp.isoformat() if graph1.creation_timestamp else None,
|
| 226 |
"trace_id": graph1.trace_id,
|
| 227 |
+
"trace_title": graph1.trace.title if graph1.trace else None,
|
| 228 |
+
"system_name": (graph1.graph_data or {}).get("system_name") if isinstance(graph1.graph_data, dict) else None,
|
| 229 |
},
|
| 230 |
"graph2": {
|
| 231 |
"id": graph2.id,
|
| 232 |
"filename": graph2.filename,
|
| 233 |
"creation_timestamp": graph2.creation_timestamp.isoformat() if graph2.creation_timestamp else None,
|
| 234 |
"trace_id": graph2.trace_id,
|
| 235 |
+
"trace_title": graph2.trace.title if graph2.trace else None,
|
| 236 |
+
"system_name": (graph2.graph_data or {}).get("system_name") if isinstance(graph2.graph_data, dict) else None,
|
| 237 |
},
|
| 238 |
"comparison_timestamp": metrics.graph1_stats.get('name', 'Unknown'), # Will be set properly
|
| 239 |
"similarity_threshold": general_threshold,
|
|
|
|
| 408 |
raise
|
| 409 |
except Exception as e:
|
| 410 |
logger.error(f"Error clearing cache: {str(e)}")
|
| 411 |
+
raise HTTPException(status_code=500, detail=f"Failed to clear cache: {str(e)}")
|