Spaces:
Sleeping
Sleeping
Nikhil Singh
commited on
Commit
·
1efe83d
1
Parent(s):
2194e9a
layout
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ def clean_email(email):
|
|
15 |
|
16 |
def present(email_content):
|
17 |
email = accept_mail(email_content)
|
18 |
-
cleaned_text = clean_email(email)
|
19 |
email_info = {
|
20 |
"Subject": email.subject,
|
21 |
"From": email.from_,
|
@@ -23,34 +23,35 @@ def present(email_content):
|
|
23 |
"Date": email.date,
|
24 |
"Message ID": email.message_id,
|
25 |
"Headers": email.headers,
|
26 |
-
"Attachments": email.attachments
|
|
|
27 |
}
|
28 |
-
return [
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
demo = gr.Interface(
|
40 |
-
fn=present,
|
41 |
-
inputs="text",
|
42 |
-
outputs=[
|
43 |
-
gr.components.Textbox(label="Subject"),
|
44 |
-
gr.components.Textbox(label="From"),
|
45 |
-
gr.components.Textbox(label="To"),
|
46 |
-
gr.components.Textbox(label="Date"),
|
47 |
-
gr.components.Textbox(label="Message ID"),
|
48 |
-
gr.components.Textbox(label="Headers"),
|
49 |
-
gr.components.Textbox(label="Attachments"),
|
50 |
-
gr.components.Textbox(label="Cleaned Text")
|
51 |
-
],
|
52 |
-
title="Email Info",
|
53 |
-
description="Enter the email content below to view its details.",
|
54 |
-
layout="horizontal" # Arrange the output components horizontally
|
55 |
-
)
|
56 |
demo.launch()
|
|
|
15 |
|
16 |
def present(email_content):
|
17 |
email = accept_mail(email_content)
|
18 |
+
cleaned_text = clean_email(email)
|
19 |
email_info = {
|
20 |
"Subject": email.subject,
|
21 |
"From": email.from_,
|
|
|
23 |
"Date": email.date,
|
24 |
"Message ID": email.message_id,
|
25 |
"Headers": email.headers,
|
26 |
+
"Attachments": email.attachments,
|
27 |
+
"Cleaned Body": cleaned_text
|
28 |
}
|
29 |
+
return [email_info[key] for key in email_info]
|
30 |
+
|
31 |
+
with gr.Blocks() as demo:
|
32 |
+
gr.Markdown("## Email Info")
|
33 |
+
gr.Markdown("Enter the email content below to view its details.")
|
34 |
+
with gr.Row():
|
35 |
+
with gr.Column():
|
36 |
+
input_text = gr.Textbox(label="Email Content")
|
37 |
+
output_texts = [
|
38 |
+
gr.Textbox(label="Subject"),
|
39 |
+
gr.Textbox(label="From"),
|
40 |
+
gr.Textbox(label="To"),
|
41 |
+
gr.Textbox(label="Date"),
|
42 |
+
gr.Textbox(label="Message ID"),
|
43 |
+
gr.Textbox(label="Headers"),
|
44 |
+
gr.Textbox(label="Attachments"),
|
45 |
+
gr.Textbox(label="Cleaned Body", visible=False) # Initially hidden
|
46 |
+
]
|
47 |
+
button = gr.Button("Process Email")
|
48 |
+
with gr.Column():
|
49 |
+
output_cleaned_text = gr.Textbox(label="Cleaned Email Body")
|
50 |
+
|
51 |
+
button.click(
|
52 |
+
present,
|
53 |
+
inputs=input_text,
|
54 |
+
outputs=output_texts + [output_cleaned_text]
|
55 |
+
)
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
demo.launch()
|