scmlewis commited on
Commit
b8eb391
·
verified ·
1 Parent(s): 2cbbfbe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -31
app.py CHANGED
@@ -74,58 +74,95 @@ def add_to_history(email, cat, pri, summ):
74
  classification_history.append(entry)
75
 
76
  with gr.Blocks(css="""
77
- body { background: linear-gradient(135deg, #101d42 0%, #273e7f 100%) !important; }
78
  .gradio-container { background: transparent !important; }
 
79
  .card-block {
80
- background: #222e4a;
81
- border-radius: 18px;
82
- box-shadow: 0 2px 24px #0e1b3e77;
83
- padding: 28px 26px 22px 26px;
84
- margin: 20px 0;
85
- color: #f3f8ff;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
- .badge {
88
- border-radius: 8px;
89
- padding: 2px 12px;
90
- font-weight: 600;
91
- background: #3371c1;
92
- color: #fff;
93
- margin-right: 10px;
94
- font-size: 0.98em;
 
 
95
  }
96
- .priority-high { background: #d32f2f !important; color: #fff !important;}
97
- .priority-medium { background: #ffb300 !important; color: #222 !important;}
98
- .priority-low { background: #388e3c !important; color: #fff !important;}
99
  """) as demo:
100
- gr.Markdown("<h1 style='text-align:center; margin-top:18px; color:#fff;'>📧 AI Email Classifier & Router</h1>")
101
  with gr.Row():
102
- with gr.Column(scale=5, min_width=380):
 
103
  with gr.Group(elem_id="input-card", elem_classes=["card-block"]):
104
- gr.Markdown("### Input Email")
105
- gr.Markdown("Select Example:")
106
  with gr.Row():
107
  support_button = gr.Button("Support Request")
108
  sales_button = gr.Button("Sales Inquiry")
109
  finance_button = gr.Button("Finance / Billing")
110
  urgent_button = gr.Button("Urgent Incident")
111
  spam_button = gr.Button("Spam / Marketing")
112
- email_box = gr.Textbox(lines=8, label="Paste your email (with From/Subject/etc.):", elem_id='email_box')
113
- classify_btn = gr.Button("Classify Email", elem_id='classify_btn', variant="primary")
114
 
115
- with gr.Column(scale=7, min_width=390):
 
116
  with gr.Group(elem_id="output-card", elem_classes=["card-block"]):
117
- gr.Markdown("### Classification Results")
118
  result_labels = gr.Markdown("", elem_id="result-labels")
119
  recipient = gr.Textbox(label="Suggested Recipient")
120
  draft_response = gr.Textbox(lines=5, label="Generated Response Draft")
121
  summary = gr.Textbox(label="Summary")
122
  action_items = gr.Textbox(lines=3, label="Extracted Action Items")
123
 
 
124
  with gr.Group(elem_id="history-card", elem_classes=["card-block"]):
125
- gr.Markdown("### Classification History")
126
- history_radio = gr.Radio([], label="Select record", type="index")
127
- load_btn = gr.Button("Load Selected")
128
- copy_btn = gr.Button("Copy Selected")
129
 
130
  # Example data
131
  ex1 = "From: help@company.com\nSubject: Unable to Login\nHi, I can't access my dashboard. Can you help?"
@@ -151,7 +188,7 @@ body { background: linear-gradient(135deg, #101d42 0%, #273e7f 100%) !important;
151
  add_to_history(email_text, cat, pri, summ)
152
  badge = f"<b>Category:</b> <span class='badge'>{cat}</span> <b>Priority:</b> <span class='badge priority-{pri.lower()}'>{pri}</span>"
153
  display = [
154
- f"{h['datetime']} | Category: {h['category']} | Priority: {h['priority']} | {h['summary'][:100]}"
155
  for h in classification_history
156
  ]
157
  return badge, rec, dra, summ, acts, gr.update(choices=display, value=len(display)-1)
 
74
  classification_history.append(entry)
75
 
76
  with gr.Blocks(css="""
77
+ body { background: linear-gradient(120deg, #131d47 0%, #28398f 50%, #101d42 100%) !important; font-family: 'Inter', 'Segoe UI', 'Roboto', Arial, sans-serif; }
78
  .gradio-container { background: transparent !important; }
79
+
80
  .card-block {
81
+ background: rgba(26, 35, 71, 0.93);
82
+ border-radius: 24px;
83
+ box-shadow: 0 8px 32px #17336a60;
84
+ padding: 34px 26px 28px 26px;
85
+ margin: 24px 0;
86
+ color: #ecf2ff;
87
+ border: 1.5px solid rgba(47,84,178,0.17);
88
+ backdrop-filter: blur(7px);
89
+ }
90
+ #output-card { border: 1.5px solid #3695fd66; box-shadow: 0 4px 22px #2196f380;}
91
+ #history-card { border: 1.5px solid #1f458399;}
92
+ .card-block h3 { font-size:1.25em; letter-spacing:0.02em; margin-bottom:18px;}
93
+ .badge {
94
+ display:inline-block;
95
+ border-radius:999px;
96
+ padding:4px 17px;
97
+ font-weight:600;
98
+ background:linear-gradient(90deg,#2875b5 70%,#17d8ff 120%);
99
+ box-shadow: 0 1px 12px #188ad938;
100
+ color:#fff;
101
+ margin-right:12px;
102
+ font-size:1.02em;
103
+ }
104
+ .priority-high { background:linear-gradient(90deg,#d32f2f 60%,#f73368 150%)!important; color:#fff;}
105
+ .priority-medium { background:linear-gradient(90deg,#f89e36 70%,#f7ea47 120%)!important;color:#222;}
106
+ .priority-low { background:linear-gradient(90deg,#23ac9b 60%,#17f3ad 150%)!important;color:#fff;}
107
+ .glass-btn {
108
+ border-radius: 18px !important;
109
+ box-shadow: 0 4px 18px #0e1b3e35 !important;
110
+ background:linear-gradient(90deg,#336bc0 70%,#2dbcfb 100%)!important;
111
+ color: #fff !important;
112
+ letter-spacing: .04em;
113
+ border: none !important;
114
+ font-size: 1.09em !important;
115
+ font-weight: 600;
116
+ }
117
+ .glass-btn:hover {
118
+ background:linear-gradient(90deg,#154678 50%,#0fdbee 110%)!important;
119
+ color: #fff !important;
120
  }
121
+ .card-history {
122
+ background:rgba(23,35,68,0.90);
123
+ color:#eafeff;
124
+ margin:9px 0;
125
+ border-radius:14px;
126
+ padding:16px 18px;
127
+ box-shadow:0 0 18px #174b8360;
128
+ font-size:1em;
129
+ border-left:4px solid #17aefcdd;
130
+ backdrop-filter:blur(4px);
131
  }
132
+ .card-history-header {font-weight:bold;font-size:1em;margin-bottom:7px;color:#fff;}
 
 
133
  """) as demo:
134
+ gr.Markdown("<h1 style='text-align:center; margin-top:16px; color:#fff;'>📧 AI Email Classifier & Router</h1>")
135
  with gr.Row():
136
+ # Input Card
137
+ with gr.Column(scale=5, min_width=390):
138
  with gr.Group(elem_id="input-card", elem_classes=["card-block"]):
139
+ gr.Markdown("<h3>Paste Your Email</h3>")
140
+ gr.Markdown("Choose Example:")
141
  with gr.Row():
142
  support_button = gr.Button("Support Request")
143
  sales_button = gr.Button("Sales Inquiry")
144
  finance_button = gr.Button("Finance / Billing")
145
  urgent_button = gr.Button("Urgent Incident")
146
  spam_button = gr.Button("Spam / Marketing")
147
+ email_box = gr.Textbox(lines=8, label="", placeholder="From: ...\nSubject: ...", elem_id='email_box')
148
+ classify_btn = gr.Button("Classify Email", elem_id='classify_btn', elem_classes=["glass-btn"])
149
 
150
+ # Output Card
151
+ with gr.Column(scale=7, min_width=420):
152
  with gr.Group(elem_id="output-card", elem_classes=["card-block"]):
153
+ gr.Markdown("<h3>Classification Results</h3>")
154
  result_labels = gr.Markdown("", elem_id="result-labels")
155
  recipient = gr.Textbox(label="Suggested Recipient")
156
  draft_response = gr.Textbox(lines=5, label="Generated Response Draft")
157
  summary = gr.Textbox(label="Summary")
158
  action_items = gr.Textbox(lines=3, label="Extracted Action Items")
159
 
160
+ # History Card
161
  with gr.Group(elem_id="history-card", elem_classes=["card-block"]):
162
+ gr.Markdown("<h3>Classification History</h3>")
163
+ history_radio = gr.Radio([], label="", type="index")
164
+ load_btn = gr.Button("Load Selected", elem_classes=["glass-btn"])
165
+ copy_btn = gr.Button("Copy Selected", elem_classes=["glass-btn"])
166
 
167
  # Example data
168
  ex1 = "From: help@company.com\nSubject: Unable to Login\nHi, I can't access my dashboard. Can you help?"
 
188
  add_to_history(email_text, cat, pri, summ)
189
  badge = f"<b>Category:</b> <span class='badge'>{cat}</span> <b>Priority:</b> <span class='badge priority-{pri.lower()}'>{pri}</span>"
190
  display = [
191
+ f"{h['datetime']}<div class='card-history-header'>Category: {h['category']} | Priority: {h['priority']}</div><div>{h['summary'][:90]}...</div>"
192
  for h in classification_history
193
  ]
194
  return badge, rec, dra, summ, acts, gr.update(choices=display, value=len(display)-1)