wensjheng commited on
Commit
0002766
·
verified ·
1 Parent(s): da5a031

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -11
app.py CHANGED
@@ -117,24 +117,37 @@ ________________________________________
117
  else:
118
  return f"【API 錯誤 {resp.status_code}】{resp.text[:300]}"
119
 
120
- # === 回呼 ===
121
- def collect_and_score(summary):
122
  try:
123
- raw = call_gemini(summary)
 
 
 
 
 
 
 
 
124
  total = parse_scores(raw)
125
  md = render_score_card(total, raw)
126
- return summary, md
127
  except Exception as e:
128
- return summary, f"【系統錯誤】{e}"
129
 
130
  def do_clear():
131
- return "", "(已清空)"
132
 
133
  # === Gradio 介面 ===
134
  with gr.Blocks(title="One-Minute Summary 評分") as demo:
135
  gr.HTML(INTRO_TEXT)
136
 
137
- summary_box = gr.Textbox(label="請貼上你的 One-Minute Summary", lines=10)
 
 
 
 
 
 
138
 
139
  with gr.Row():
140
  submit_btn = gr.Button("送出評分", variant="primary")
@@ -144,13 +157,13 @@ with gr.Blocks(title="One-Minute Summary 評分") as demo:
144
 
145
  submit_btn.click(
146
  collect_and_score,
147
- [summary_box],
148
- [summary_box, result]
149
  )
150
 
151
  clear_btn.click(
152
  do_clear,
153
- outputs=[summary_box, result]
154
  )
155
 
156
- demo.launch()
 
117
  else:
118
  return f"【API 錯誤 {resp.status_code}】{resp.text[:300]}"
119
 
120
+ def collect_and_score(p1, p2, p3, p4, p5, p6, p7):
 
121
  try:
122
+ combined = f"""1. 年齡/性別/主訴: {p1}
123
+ 2. 個人病史: {p2}
124
+ 3. 家族史: {p3}
125
+ 4. 身體檢查: {p4}
126
+ 5. 實驗室與影像: {p5}
127
+ 6. 鑑別診斷: {p6}
128
+ 7. 處置與治療: {p7}
129
+ """
130
+ raw = call_gemini(combined)
131
  total = parse_scores(raw)
132
  md = render_score_card(total, raw)
133
+ return p1, p2, p3, p4, p5, p6, p7, md
134
  except Exception as e:
135
+ return p1, p2, p3, p4, p5, p6, p7, f"【系統錯誤】{e}"
136
 
137
  def do_clear():
138
+ return "", "", "", "", "", "", "", "(已清空)"
139
 
140
  # === Gradio 介面 ===
141
  with gr.Blocks(title="One-Minute Summary 評分") as demo:
142
  gr.HTML(INTRO_TEXT)
143
 
144
+ p1 = gr.Textbox(label="1. 年齡、性別、Chief Complaint (10分)", lines=2)
145
+ p2 = gr.Textbox(label="2. 個人病史 (10分)", lines=2)
146
+ p3 = gr.Textbox(label="3. 家族史 (10分)", lines=2)
147
+ p4 = gr.Textbox(label="4. 身體檢查陽性發現 (10分)", lines=2)
148
+ p5 = gr.Textbox(label="5. 實驗室與影像結果 (10分)", lines=2)
149
+ p6 = gr.Textbox(label="6. 鑑別診斷 (10分)", lines=2)
150
+ p7 = gr.Textbox(label="7. 處置與治療 (40分)", lines=2)
151
 
152
  with gr.Row():
153
  submit_btn = gr.Button("送出評分", variant="primary")
 
157
 
158
  submit_btn.click(
159
  collect_and_score,
160
+ [p1, p2, p3, p4, p5, p6, p7],
161
+ [p1, p2, p3, p4, p5, p6, p7, result]
162
  )
163
 
164
  clear_btn.click(
165
  do_clear,
166
+ outputs=[p1, p2, p3, p4, p5, p6, p7, result]
167
  )
168
 
169
+ demo.launch()