winsweb commited on
Commit
6758221
·
1 Parent(s): 892b85b

fix AI model json

Browse files
Files changed (1) hide show
  1. telecom_anomaly/api.py +7 -1
telecom_anomaly/api.py CHANGED
@@ -273,9 +273,15 @@ def _run_analysis(
273
 
274
  return {
275
  "filename": original_filename,
 
 
 
 
 
 
276
  "statistics": (
277
  stats.to_dict()
278
- if run_anomaly_detection
279
  else {"total_rows": len(detector.data)}
280
  ),
281
  "results": response_records,
 
273
 
274
  return {
275
  "filename": original_filename,
276
+ # Full stats whenever ANY detection ran (rules or model). The
277
+ # stripped `{"total_rows": …}` shape is reserved for the
278
+ # clustering-only / preview pass, where there are no anomalies
279
+ # to summarise. Without this, AI-only mode silently dropped
280
+ # rows_with_anomalies / anomaly_rate / anomaly_types from the
281
+ # response.
282
  "statistics": (
283
  stats.to_dict()
284
+ if any_detection
285
  else {"total_rows": len(detector.data)}
286
  ),
287
  "results": response_records,