Nikhil Singh commited on
Commit
2194e9a
·
1 Parent(s): 01fa41d

fixed text issue

Browse files
Files changed (1) hide show
  1. app.py +21 -31
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) # Call clean_email to get cleaned text
19
  email_info = {
20
  "Subject": email.subject,
21
  "From": email.from_,
@@ -25,42 +25,32 @@ def present(email_content):
25
  "Headers": email.headers,
26
  "Attachments": email.attachments
27
  }
28
- # Outputs are now organized as a list to match the structure for grouped outputs
29
  return [
30
- [
31
- email_info["Subject"],
32
- str(email_info["From"]), # Convert list to string for display
33
- str(email_info["To"]), # Convert list to string for display
34
- email_info["Date"],
35
- email_info["Message ID"],
36
- str(email_info["Headers"]), # Convert dictionary to string for display
37
- str(email_info["Attachments"]) # Convert list to string for display
38
- ],
39
- cleaned_text # Cleaned text is the second major block
40
  ]
41
 
42
- outputs = [
43
- gr.components.Group(
44
- components=[
45
- gr.components.Textbox(label="Subject"),
46
- gr.components.Textbox(label="From"),
47
- gr.components.Textbox(label="To"),
48
- gr.components.Textbox(label="Date"),
49
- gr.components.Textbox(label="Message ID"),
50
- gr.components.Textbox(label="Headers"),
51
- gr.components.Textbox(label="Attachments")
52
- ],
53
- label="Email Details"
54
- ),
55
- gr.components.Textbox(label="Cleaned Text")
56
- ]
57
-
58
  demo = gr.Interface(
59
  fn=present,
60
  inputs="text",
61
- outputs=outputs,
62
- title="Email Info",
 
 
 
 
 
 
 
 
 
63
  description="Enter the email content below to view its details.",
64
- layout="horizontal" # Arrange the major output groups horizontally
65
  )
66
  demo.launch()
 
15
 
16
  def present(email_content):
17
  email = accept_mail(email_content)
18
+ cleaned_text = clean_email(email) # Get the cleaned text of the email
19
  email_info = {
20
  "Subject": email.subject,
21
  "From": email.from_,
 
25
  "Headers": email.headers,
26
  "Attachments": email.attachments
27
  }
 
28
  return [
29
+ email_info["Subject"],
30
+ str(email_info["From"]),
31
+ str(email_info["To"]),
32
+ email_info["Date"],
33
+ email_info["Message ID"],
34
+ str(email_info["Headers"]),
35
+ str(email_info["Attachments"]),
36
+ cleaned_text
 
 
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()