pluto90 commited on
Commit
dd3972e
·
verified ·
1 Parent(s): bc03939

Update app/graph/nodes/evaluator.py

Browse files
Files changed (1) hide show
  1. app/graph/nodes/evaluator.py +5 -5
app/graph/nodes/evaluator.py CHANGED
@@ -25,17 +25,17 @@ def _extract_json(text: str) -> dict:
25
  if not match:
26
  raise ValueError(f"No JSON found. Raw: {text[:300]}")
27
 
28
- # raw_json = match.group(0).strip()
29
  return json.loads(raw_json)
30
 
31
 
32
- def _fallback_evaluation(route="rag"):
33
  """Explicit fallback — always returns a valid dict."""
34
  return {
35
  "relevance_score": 0.5,
36
  "context_usage": 0.5,
37
  "hallucination": True,
38
- "route": route
39
  }
40
 
41
 
@@ -65,7 +65,7 @@ def evaluator_node(state):
65
  "context": context[:600]
66
  }).strip()
67
 
68
- print(f"EVALUATOR RAW → {raw_response[:200]}") # ✅ log first 200 chars to debug
69
 
70
  parsed= _extract_json(raw_response)
71
 
@@ -73,7 +73,7 @@ def evaluator_node(state):
73
  "relevance_score": round(min(max(float(parsed.get("relevance_score", 0)), 0), 1), 3),
74
  "context_usage": round(min(max(float(parsed.get("context_usage", 0)), 0), 1), 3),
75
  "hallucination": bool(parsed.get("hallucination", True)),
76
- "route": route
77
  }
78
 
79
  print(f"EVALUATOR SUCCESS → {evaluation}")
 
25
  if not match:
26
  raise ValueError(f"No JSON found. Raw: {text[:300]}")
27
 
28
+ raw_json = match.group(0).strip()
29
  return json.loads(raw_json)
30
 
31
 
32
+ def _fallback_evaluation():
33
  """Explicit fallback — always returns a valid dict."""
34
  return {
35
  "relevance_score": 0.5,
36
  "context_usage": 0.5,
37
  "hallucination": True,
38
+ "route": "rag"
39
  }
40
 
41
 
 
65
  "context": context[:600]
66
  }).strip()
67
 
68
+ print(f"EVALUATOR RAW → {raw_response[:300]}") # ✅ log first 200 chars to debug
69
 
70
  parsed= _extract_json(raw_response)
71
 
 
73
  "relevance_score": round(min(max(float(parsed.get("relevance_score", 0)), 0), 1), 3),
74
  "context_usage": round(min(max(float(parsed.get("context_usage", 0)), 0), 1), 3),
75
  "hallucination": bool(parsed.get("hallucination", True)),
76
+ "route": "rag"
77
  }
78
 
79
  print(f"EVALUATOR SUCCESS → {evaluation}")