anky2002 commited on
Commit
6ea04f9
·
verified ·
1 Parent(s): 15d0ba2

Upload agents/utils.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. agents/utils.py +17 -2
agents/utils.py CHANGED
@@ -50,10 +50,11 @@ def compute_failure_prob(n_ran: int, n_total: int, n_insufficient: int = 0) -> f
50
  return max(0.0, 1.0 - n_effective / max(n_total, 1))
51
 
52
 
53
- def run_agent_tests(tests, img, agent_name):
54
  """
55
  Shared test runner for all signal-processing agents.
56
  Handles: running tests, tagging insufficient-data, computing confidence properly.
 
57
  """
58
  findings, scores = [], []
59
  n_insufficient = 0
@@ -65,15 +66,29 @@ def run_agent_tests(tests, img, agent_name):
65
 
66
  sc = r.get("score", 0)
67
  note = r.get("note", "")
 
68
 
69
  # P7: Detect insufficient-data results — tag as not_applicable
70
  is_insufficient = (sc == 0.0 and any(kw in note.lower() for kw in
71
- ["insufficient", "too small", "no data", "not available", "few ", "no "]))
 
72
 
73
  if is_insufficient:
74
  r["not_applicable"] = True
75
  n_insufficient += 1
76
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  scores.append(sc)
78
  except Exception as e:
79
  findings.append({"test": fn.__name__, "error": str(e), "score": 0})
 
50
  return max(0.0, 1.0 - n_effective / max(n_total, 1))
51
 
52
 
53
+ def run_agent_tests(tests, img, agent_name, modality_adjustments=None):
54
  """
55
  Shared test runner for all signal-processing agents.
56
  Handles: running tests, tagging insufficient-data, computing confidence properly.
57
+ Applies modality-aware score reweighting when modality_adjustments is provided.
58
  """
59
  findings, scores = [], []
60
  n_insufficient = 0
 
66
 
67
  sc = r.get("score", 0)
68
  note = r.get("note", "")
69
+ test_name = r.get("test", fn.__name__)
70
 
71
  # P7: Detect insufficient-data results — tag as not_applicable
72
  is_insufficient = (sc == 0.0 and any(kw in note.lower() for kw in
73
+ ["insufficient", "too small", "no data", "not available", "few ", "no ",
74
+ "not meaningful", "cannot read", "parse error"]))
75
 
76
  if is_insufficient:
77
  r["not_applicable"] = True
78
  n_insufficient += 1
79
 
80
+ # Apply modality adjustment if present
81
+ if modality_adjustments and test_name in modality_adjustments:
82
+ multiplier = modality_adjustments[test_name]
83
+ original_score = sc
84
+ sc = sc * multiplier
85
+ r["score"] = sc
86
+ r["modality_adjusted"] = True
87
+ r["original_score"] = original_score
88
+ r["adjustment_multiplier"] = multiplier
89
+ if multiplier < 0.5:
90
+ r["note"] = f"[Modality-suppressed ×{multiplier}] {note}"
91
+
92
  scores.append(sc)
93
  except Exception as e:
94
  findings.append({"test": fn.__name__, "error": str(e), "score": 0})