Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -252,12 +252,15 @@ def classify_email(json_input):
|
|
| 252 |
|
| 253 |
# ===================== 核心处理函数(模拟邮件分析) =====================
|
| 254 |
def classify_email(sender: str, subject: str, body: str) -> tuple[str, str]:
|
|
|
|
|
|
|
|
|
|
| 255 |
email = {
|
| 256 |
"sender": sender,
|
| 257 |
"subject": subject,
|
| 258 |
"body": body
|
| 259 |
}
|
| 260 |
-
|
| 261 |
result = compiled_graph.invoke({
|
| 262 |
"email": email,
|
| 263 |
"is_spam": None,
|
|
@@ -280,14 +283,14 @@ with gr.Blocks(title="邮件分析表单", theme=gr.themes.Soft()) as demo:
|
|
| 280 |
with gr.Column(scale=1):
|
| 281 |
sender_input = gr.Textbox(
|
| 282 |
label="1. 发件人邮箱地址",
|
| 283 |
-
placeholder="
|
| 284 |
lines=1,
|
| 285 |
max_lines=1
|
| 286 |
)
|
| 287 |
with gr.Column(scale=2):
|
| 288 |
subject_input = gr.Textbox(
|
| 289 |
label="2. 邮件主题",
|
| 290 |
-
placeholder="
|
| 291 |
lines=1,
|
| 292 |
max_lines=1
|
| 293 |
)
|
|
@@ -295,7 +298,7 @@ with gr.Blocks(title="邮件分析表单", theme=gr.themes.Soft()) as demo:
|
|
| 295 |
# 第三个文本框:多行输入(邮件内容)
|
| 296 |
content_input = gr.Textbox(
|
| 297 |
label="3. 邮件内容",
|
| 298 |
-
placeholder="
|
| 299 |
lines=5,
|
| 300 |
max_lines=10
|
| 301 |
)
|
|
|
|
| 252 |
|
| 253 |
# ===================== 核心处理函数(模拟邮件分析) =====================
|
| 254 |
def classify_email(sender: str, subject: str, body: str) -> tuple[str, str]:
|
| 255 |
+
if sender.strip() == "" or subject.strip() == "" or body.strip() == "" :
|
| 256 |
+
return return "true", "sender、subject、subject为空"
|
| 257 |
+
|
| 258 |
email = {
|
| 259 |
"sender": sender,
|
| 260 |
"subject": subject,
|
| 261 |
"body": body
|
| 262 |
}
|
| 263 |
+
|
| 264 |
result = compiled_graph.invoke({
|
| 265 |
"email": email,
|
| 266 |
"is_spam": None,
|
|
|
|
| 283 |
with gr.Column(scale=1):
|
| 284 |
sender_input = gr.Textbox(
|
| 285 |
label="1. 发件人邮箱地址",
|
| 286 |
+
placeholder="john.smith@gmail.com",
|
| 287 |
lines=1,
|
| 288 |
max_lines=1
|
| 289 |
)
|
| 290 |
with gr.Column(scale=2):
|
| 291 |
subject_input = gr.Textbox(
|
| 292 |
label="2. 邮件主题",
|
| 293 |
+
placeholder="预约会议",
|
| 294 |
lines=1,
|
| 295 |
max_lines=1
|
| 296 |
)
|
|
|
|
| 298 |
# 第三个文本框:多行输入(邮件内容)
|
| 299 |
content_input = gr.Textbox(
|
| 300 |
label="3. 邮件内容",
|
| 301 |
+
placeholder="我想预约下周二的咨询会议",
|
| 302 |
lines=5,
|
| 303 |
max_lines=10
|
| 304 |
)
|