Khriis commited on
Commit
f22e9cb
verified
1 Parent(s): fa2d7ee

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +8 -2
handler.py CHANGED
@@ -147,10 +147,16 @@ class EndpointHandler:
147
  if isinstance(current_preds, dict):
148
  current_preds = [current_preds]
149
 
 
 
 
 
 
 
 
150
  # Extract the answer strings
151
- raw_answers = [p.get('answer', '') for p in current_preds]
152
 
153
- # Clean spans using your original logic
154
  triggers = self._clean_spans(raw_answers, utterance)
155
 
156
  results.append({
 
147
  if isinstance(current_preds, dict):
148
  current_preds = [current_preds]
149
 
150
+ MIN_SPAN_SCORE = 0.5 # tune this
151
+
152
+ filtered_preds = [
153
+ p for p in current_preds
154
+ if p.get("score", 0.0) >= MIN_SPAN_SCORE
155
+ ]
156
+
157
  # Extract the answer strings
158
+ raw_answers = [p["answer"] for p in filtered_preds]
159
 
 
160
  triggers = self._clean_spans(raw_answers, utterance)
161
 
162
  results.append({