Jesse Liu commited on
Commit
062a773
·
1 Parent(s): 7077afc

Fix: remove admission radio usage (single admission)

Browse files
Files changed (1) hide show
  1. chatgpt.py +7 -9
chatgpt.py CHANGED
@@ -747,17 +747,15 @@ with gr.Blocks() as app:
747
 
748
  eval_data_by_patient = {}
749
 
750
- # Clean summary output by removing JSON object appendix
751
  def clean_summary_output(text):
752
- """Remove trailing JSON object from summary if present"""
753
  if not text:
754
  return text
755
- # Remove everything after "**JSON Object:**" marker
756
- if '**JSON Object:**' in text:
757
- text = text.split('**JSON Object:**')[0].strip()
758
- # Remove everything after ```json code fence
759
- if '```json' in text:
760
- text = text.split('```json')[0].strip()
761
  return text
762
 
763
  # Load from new JSONL format first (single admission per record)
@@ -1283,7 +1281,7 @@ with gr.Blocks() as app:
1283
  rec = eval_data_by_patient[pid][first_key]
1284
 
1285
  at = rec.get('admittime') or 'None'
1286
- summary_text = rec.get('summary', '') or 'No summary available'
1287
  input_text = rec.get('input_text', '') or 'No input data available'
1288
 
1289
  # Replace ICD codes and Lab IDs with descriptions
 
747
 
748
  eval_data_by_patient = {}
749
 
750
+ # Clean summary output by removing JSON/object appendix and code fences
751
  def clean_summary_output(text):
752
+ """Remove trailing JSON block or code fences from model output."""
753
  if not text:
754
  return text
755
+ cut_markers = ['**JSON Object:**', '```json', '```', '\n{']
756
+ for marker in cut_markers:
757
+ if marker in text:
758
+ text = text.split(marker)[0].strip()
 
 
759
  return text
760
 
761
  # Load from new JSONL format first (single admission per record)
 
1281
  rec = eval_data_by_patient[pid][first_key]
1282
 
1283
  at = rec.get('admittime') or 'None'
1284
+ summary_text = clean_summary_output(rec.get('summary', '') or 'No summary available')
1285
  input_text = rec.get('input_text', '') or 'No input data available'
1286
 
1287
  # Replace ICD codes and Lab IDs with descriptions