wanggenfu commited on
Commit
60032e2
·
verified ·
1 Parent(s): bd14caf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -249,7 +249,7 @@ def classify_email(json_input):
249
 
250
 
251
  # ===================== 核心处理函数(模拟邮件分析) =====================
252
- def classify_email(sender: str, subject: str, body: str) -> tuple[str, str, str]:
253
  email = {
254
  "sender": sender,
255
  "subject": subject,
@@ -264,7 +264,7 @@ def classify_email(sender: str, subject: str, body: str) -> tuple[str, str, str]
264
  "draft_response": None,
265
  "messages": []
266
  })
267
- return result.get("is_spam"), result.get("spam_reason"), result.get("email_category")
268
 
269
 
270
  # ===================== Gradio 表单界面构建 =====================
@@ -308,14 +308,13 @@ with gr.Blocks(title="邮件分析表单", theme=gr.themes.Soft()) as demo:
308
  gr.Markdown("### 📝 分析结果")
309
  with gr.Row():
310
  is_spam_output = gr.Textbox(label="是否垃圾邮件", interactive=False)
311
- category_output = gr.Textbox(label="邮件分类", interactive=False)
312
  reason_output = gr.Textbox(label="判定原因", lines=3, interactive=False)
313
 
314
  # 绑定按钮与处理函数
315
  submit_btn.click(
316
  fn=classify_email,
317
  inputs=[sender_input, subject_input, content_input], # 3个输入框
318
- outputs=[is_spam_output, reason_output, category_output] # 3个输出框
319
  )
320
 
321
  # 重置按钮(可选)
@@ -323,7 +322,7 @@ with gr.Blocks(title="邮件分析表单", theme=gr.themes.Soft()) as demo:
323
  reset_btn.click(
324
  fn=lambda: ("", "", "", "", "", ""), # 重置所有输入输出
325
  inputs=[],
326
- outputs=[sender_input, subject_input, content_input, is_spam_output, reason_output, category_output]
327
  )
328
 
329
  # ===================== 启动界面 =====================
 
249
 
250
 
251
  # ===================== 核心处理函数(模拟邮件分析) =====================
252
+ def classify_email(sender: str, subject: str, body: str) -> tuple[str, str]:
253
  email = {
254
  "sender": sender,
255
  "subject": subject,
 
264
  "draft_response": None,
265
  "messages": []
266
  })
267
+ return result.get("is_spam"), result.get("spam_reason")
268
 
269
 
270
  # ===================== Gradio 表单界面构建 =====================
 
308
  gr.Markdown("### 📝 分析结果")
309
  with gr.Row():
310
  is_spam_output = gr.Textbox(label="是否垃圾邮件", interactive=False)
 
311
  reason_output = gr.Textbox(label="判定原因", lines=3, interactive=False)
312
 
313
  # 绑定按钮与处理函数
314
  submit_btn.click(
315
  fn=classify_email,
316
  inputs=[sender_input, subject_input, content_input], # 3个输入框
317
+ outputs=[is_spam_output, reason_output] # 2个输出框
318
  )
319
 
320
  # 重置按钮(可选)
 
322
  reset_btn.click(
323
  fn=lambda: ("", "", "", "", "", ""), # 重置所有输入输出
324
  inputs=[],
325
+ outputs=[sender_input, subject_input, content_input, is_spam_output, reason_output]
326
  )
327
 
328
  # ===================== 启动界面 =====================