asusf15 commited on
Commit
3991281
·
verified ·
1 Parent(s): 6b91224

Fix: Use HF_TOKEN from environment for Inference API authentication

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -1,10 +1,13 @@
1
  """
2
  DeepMed-R1: Medical Reasoning AI Demo
3
  """
 
4
  import gradio as gr
5
  from huggingface_hub import InferenceClient
6
 
7
- client = InferenceClient("Qwen/Qwen3-4B")
 
 
8
 
9
  SYSTEM_PROMPT = """You are DeepMed-R1, a medical reasoning AI trained with GRPO and multi-objective clinical rewards.
10
 
@@ -23,7 +26,7 @@ EXAMPLES = [
23
  ["A 65-year-old male with hypertension presents with sudden 'worst headache of my life,' neck stiffness, photophobia. BP 180/100. Most likely diagnosis?\nA. Migraine\nB. Subarachnoid hemorrhage\nC. Meningitis\nD. Tension headache"],
24
  ["A 28-year-old woman: fatigue, weight gain, cold intolerance. TSH 12 mIU/L, Free T4 0.5 ng/dL. Initial treatment?\nA. Levothyroxine\nB. Liothyronine\nC. Methimazole\nD. Radioactive iodine"],
25
  ["3-month-old with projectile non-bilious vomiting, olive-shaped RUQ mass, metabolic alkalosis. Diagnosis?\nA. Pyloric stenosis\nB. Intussusception\nC. Malrotation\nD. Hirschsprung disease"],
26
- ["55-year-old diabetic: RUQ pain, fever 39.2°C, jaundice (Charcot's triad). WBC 18K, bilirubin 5.2, CBD stone on US. Next step?\nA. Cholecystectomy\nB. ERCP with sphincterotomy\nC. MRCP\nD. PTC"],
27
  ["22-year-old post-MVC: left chest pain, absent breath sounds left, trachea deviated right, JVD, BP 80/50. Immediate management?\nA. Chest X-ray\nB. CT chest\nC. Needle decompression left chest\nD. Intubation"],
28
  ]
29
 
 
1
  """
2
  DeepMed-R1: Medical Reasoning AI Demo
3
  """
4
+ import os
5
  import gradio as gr
6
  from huggingface_hub import InferenceClient
7
 
8
+ # Use HF_TOKEN from Space secrets for authenticated inference
9
+ HF_TOKEN = os.environ.get("HF_TOKEN")
10
+ client = InferenceClient("Qwen/Qwen3-4B", token=HF_TOKEN)
11
 
12
  SYSTEM_PROMPT = """You are DeepMed-R1, a medical reasoning AI trained with GRPO and multi-objective clinical rewards.
13
 
 
26
  ["A 65-year-old male with hypertension presents with sudden 'worst headache of my life,' neck stiffness, photophobia. BP 180/100. Most likely diagnosis?\nA. Migraine\nB. Subarachnoid hemorrhage\nC. Meningitis\nD. Tension headache"],
27
  ["A 28-year-old woman: fatigue, weight gain, cold intolerance. TSH 12 mIU/L, Free T4 0.5 ng/dL. Initial treatment?\nA. Levothyroxine\nB. Liothyronine\nC. Methimazole\nD. Radioactive iodine"],
28
  ["3-month-old with projectile non-bilious vomiting, olive-shaped RUQ mass, metabolic alkalosis. Diagnosis?\nA. Pyloric stenosis\nB. Intussusception\nC. Malrotation\nD. Hirschsprung disease"],
29
+ ["55-year-old diabetic: RUQ pain, fever 39.2C, jaundice (Charcot's triad). WBC 18K, bilirubin 5.2, CBD stone on US. Next step?\nA. Cholecystectomy\nB. ERCP with sphincterotomy\nC. MRCP\nD. PTC"],
30
  ["22-year-old post-MVC: left chest pain, absent breath sounds left, trachea deviated right, JVD, BP 80/50. Immediate management?\nA. Chest X-ray\nB. CT chest\nC. Needle decompression left chest\nD. Intubation"],
31
  ]
32