gregorlied commited on
Commit
758814b
·
verified ·
1 Parent(s): 187fcba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -194,22 +194,22 @@ def summarize(
194
 
195
  if not text.strip():
196
  return "Please enter some text to summarize."
197
-
198
- messages = [
199
- {"role": "system", "content": prompt.strip()},
200
- {"role": "user", "content": text.strip()},
201
- ]
202
-
203
- text = tokenizer.apply_chat_template(
204
- messages,
205
- tokenize=False,
206
- add_generation_prompt=True,
207
- enable_thinking=False, # only relevant for qwen
208
- )
209
 
210
- if text == default_value:
211
  response = ['{"life_style": "N/A", "family_history": "N/A", "social_history": "N/A", "medical_surgical_history": "N/A", "signs_symptoms": "Fever; Chest pain; Cough; Progressive dyspnea; Tachypnea; Tachycardia; Decreased breath sounds in both lung bases; Crackles on the left", "comorbidities": "N/A", "diagnostic_techniques_procedures": "Chest X-ray; Echocardiography; Thoracentesis; Laboratory tests; Pleural fluid analysis; Urinary pneumococcal antigen test; Pleural fluid culture", "diagnosis": "Pneumonia; Pericardial effusion; S. pneumoniae infection", "laboratory_values": "White blood cell count: 11.78 \\u00d7 10^9 cells/L (84.3% neutrophils, 4.3% lymphocytes, 9.1% monocytes); Platelet count: 512 \\u00d7 10^9/L; Serum C-reactive protein: 31.27 mg/dL; Serum creatinine: 0.94 mg/dL; Serum sodium: 133 mEq/L; Serum potassium: 3.72 mEq/L; Pleural fluid pH: 7.16; Pleural fluid glucose: 4.5 mg/dL; Pleural fluid proteins: 49.1 g/L; Pleural fluid LDH: 1,385 U/L", "pathology": "N/A", "pharmacological_therapy": "Amoxicillin-clavulanate (2.2 g/8 h, i.v.); Levofloxacin (500 mg twice a day); Ibuprofen (800 mg/day)", "interventional_therapy": "Pericardiocentesis; Thoracentesis", "patient_outcome_assessment": "Nearly complete resolution of alterations on chest X-ray and CT scan", "age": "57 year", "gender": "Male"}']
212
  else:
 
 
 
 
 
 
 
 
 
 
 
 
213
  model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
214
  generated_ids = model.generate(
215
  input_ids=model_inputs["input_ids"],
 
194
 
195
  if not text.strip():
196
  return "Please enter some text to summarize."
 
 
 
 
 
 
 
 
 
 
 
 
197
 
198
+ if text == default_value:
199
  response = ['{"life_style": "N/A", "family_history": "N/A", "social_history": "N/A", "medical_surgical_history": "N/A", "signs_symptoms": "Fever; Chest pain; Cough; Progressive dyspnea; Tachypnea; Tachycardia; Decreased breath sounds in both lung bases; Crackles on the left", "comorbidities": "N/A", "diagnostic_techniques_procedures": "Chest X-ray; Echocardiography; Thoracentesis; Laboratory tests; Pleural fluid analysis; Urinary pneumococcal antigen test; Pleural fluid culture", "diagnosis": "Pneumonia; Pericardial effusion; S. pneumoniae infection", "laboratory_values": "White blood cell count: 11.78 \\u00d7 10^9 cells/L (84.3% neutrophils, 4.3% lymphocytes, 9.1% monocytes); Platelet count: 512 \\u00d7 10^9/L; Serum C-reactive protein: 31.27 mg/dL; Serum creatinine: 0.94 mg/dL; Serum sodium: 133 mEq/L; Serum potassium: 3.72 mEq/L; Pleural fluid pH: 7.16; Pleural fluid glucose: 4.5 mg/dL; Pleural fluid proteins: 49.1 g/L; Pleural fluid LDH: 1,385 U/L", "pathology": "N/A", "pharmacological_therapy": "Amoxicillin-clavulanate (2.2 g/8 h, i.v.); Levofloxacin (500 mg twice a day); Ibuprofen (800 mg/day)", "interventional_therapy": "Pericardiocentesis; Thoracentesis", "patient_outcome_assessment": "Nearly complete resolution of alterations on chest X-ray and CT scan", "age": "57 year", "gender": "Male"}']
200
  else:
201
+ messages = [
202
+ {"role": "system", "content": prompt.strip()},
203
+ {"role": "user", "content": text.strip()},
204
+ ]
205
+
206
+ text = tokenizer.apply_chat_template(
207
+ messages,
208
+ tokenize=False,
209
+ add_generation_prompt=True,
210
+ enable_thinking=False, # only relevant for qwen
211
+ )
212
+
213
  model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
214
  generated_ids = model.generate(
215
  input_ids=model_inputs["input_ids"],