updated about scoring evalution

#3
Files changed (1) hide show
  1. inference.py +4 -4
inference.py CHANGED
@@ -258,8 +258,6 @@ Guidelines:
258
 
259
  IMPORTANT: Respond ONLY with the JSON object, no additional text.
260
  """
261
-
262
-
263
  def call_llm(client: OpenAI, obs) -> Optional[dict]:
264
  """Call the LLM to get a coding decision for a clinical case."""
265
  formatted = format_observation(obs)
@@ -277,6 +275,7 @@ def call_llm(client: OpenAI, obs) -> Optional[dict]:
277
  )
278
 
279
  content = response.choices[0].message.content
 
280
  if not content:
281
  print(f" [Attempt {attempt+1}] Empty response from LLM")
282
  continue
@@ -304,7 +303,8 @@ def call_llm(client: OpenAI, obs) -> Optional[dict]:
304
  if "confidence" not in action:
305
  action["confidence"] = 0.5
306
  try:
307
- action["confidence"] = max(0.0, min(1.0, float(action["confidence"])))
 
308
  except (TypeError, ValueError):
309
  action["confidence"] = 0.5
310
  if "reasoning" not in action or len(str(action.get("reasoning", ""))) < 15:
@@ -646,4 +646,4 @@ if __name__ == "__main__":
646
  finally:
647
  sys.stdout = original_stdout
648
  sys.stderr = original_stderr
649
- log_file.close()
 
258
 
259
  IMPORTANT: Respond ONLY with the JSON object, no additional text.
260
  """
 
 
261
  def call_llm(client: OpenAI, obs) -> Optional[dict]:
262
  """Call the LLM to get a coding decision for a clinical case."""
263
  formatted = format_observation(obs)
 
275
  )
276
 
277
  content = response.choices[0].message.content
278
+
279
  if not content:
280
  print(f" [Attempt {attempt+1}] Empty response from LLM")
281
  continue
 
303
  if "confidence" not in action:
304
  action["confidence"] = 0.5
305
  try:
306
+ # Clamp to strict open interval (0.01, 0.99) to satisfy strict score validators
307
+ action["confidence"] = max(0.01, min(0.99, float(action["confidence"])))
308
  except (TypeError, ValueError):
309
  action["confidence"] = 0.5
310
  if "reasoning" not in action or len(str(action.get("reasoning", ""))) < 15:
 
646
  finally:
647
  sys.stdout = original_stdout
648
  sys.stderr = original_stderr
649
+ log_file.close()