scmlewis commited on
Commit
009f945
·
verified ·
1 Parent(s): ead863f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -4
app.py CHANGED
@@ -56,7 +56,6 @@ def email_classifier_router(raw_email):
56
  }
57
  try:
58
  output = json.loads(raw_result)
59
- # Ensure keys present, fallback if missing
60
  for key in ["Category", "Priority", "Suggested Recipient", "Draft Response", "Summary", "Action Items"]:
61
  if key not in output:
62
  output[key] = ""
@@ -85,8 +84,41 @@ def add_to_history(email, cat, pri, summ, dra):
85
  css = """
86
  body { background: linear-gradient(120deg, #10193a 0%, #175ad7 120%) !important; font-family: 'Inter', 'Segoe UI', Arial, sans-serif;}
87
  .gradio-container { background: transparent !important; }
88
- .section-header { font-size: 2em;font-weight:900;letter-spacing:.02em;color:#fff;padding:10px 36px;background:linear-gradient(90deg,#2c53e8 60%,#3ffafc 120%);border-radius:19px;box-shadow:0 8px 52px #2d82b6cc;margin-bottom:-30px;margin-top:18px;text-shadow:0 4px 34px #08dbef,0 2px 15px #2e96ff;display:inline-block;border:4px solid #30d6ff99;}
89
- .app-title {font-size: 2.4em; letter-spacing: .01em; color: #fff;font-weight:800;margin-bottom:8px;text-shadow:0 2px 24px #2ec5ff; text-align:center;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  .result-labels-row{display:flex;align-items:center;gap:18px;margin-bottom:10px;margin-top:-6px;}
91
  .result-label-text{font-size:1.08em;font-weight:700;color:#daf6ff;letter-spacing:.01em;margin-right:2px;}
92
  .badge{display:inline-block;border-radius:999px;padding:4px 16px;font-weight:600;background:linear-gradient(90deg,#2870ee 70%,#13e4fc 140%);box-shadow:0 1px 12px #0663fd29;color:#fff;margin-right:8px;font-size:1.02em;vertical-align:middle;}
@@ -103,10 +135,18 @@ body { background: linear-gradient(120deg, #10193a 0%, #175ad7 120%) !important;
103
  .btn-md {padding:10px 22px;border-radius:14px; border:none;font-size:1.03em;font-weight:700;background:#3246b8; color:#fff;}
104
  .btn-md:hover { background:#2284cc;}
105
  .clear-btn { background:#db2828!important;color:#fff!important;padding:10px 24px;font-weight:600;border-radius:13px;border:none;font-size:1.07em;margin-bottom:22px;}
 
106
  """
107
 
108
  with gr.Blocks(css=css) as demo:
109
- gr.HTML("<div class='app-title'>📧 AI Email Classifier & Router</div>")
 
 
 
 
 
 
 
110
 
111
  with gr.Row():
112
  with gr.Column(scale=6, min_width=420):
@@ -123,6 +163,7 @@ with gr.Blocks(css=css) as demo:
123
  legal_button = gr.Button("Legal Inquiry")
124
  meeting_button = gr.Button("Meeting Scheduling")
125
  email_box = gr.Textbox(lines=8, label="", placeholder="From: ...\nSubject: ...")
 
126
  classify_btn = gr.Button("Classify Email", elem_classes=["glass-btn"])
127
  with gr.Column(scale=8, min_width=430):
128
  gr.HTML("<div class='section-header'>🧮 Classification Results</div>")
@@ -157,6 +198,9 @@ with gr.Blocks(css=css) as demo:
157
  legal_button.click(lambda: examples[6], None, email_box)
158
  meeting_button.click(lambda: examples[7], None, email_box)
159
 
 
 
 
160
  def classify_and_render(email_text):
161
  result = email_classifier_router(email_text)
162
  cat = result.get("Category", "")
 
56
  }
57
  try:
58
  output = json.loads(raw_result)
 
59
  for key in ["Category", "Priority", "Suggested Recipient", "Draft Response", "Summary", "Action Items"]:
60
  if key not in output:
61
  output[key] = ""
 
84
  css = """
85
  body { background: linear-gradient(120deg, #10193a 0%, #175ad7 120%) !important; font-family: 'Inter', 'Segoe UI', Arial, sans-serif;}
86
  .gradio-container { background: transparent !important; }
87
+ .main-pill-header {
88
+ display: flex;
89
+ flex-direction: column;
90
+ align-items: center;
91
+ justify-content: center;
92
+ margin: 28px auto 23px auto;
93
+ width: fit-content;
94
+ padding: 0;
95
+ }
96
+ .main-pill {
97
+ background: linear-gradient(90deg, #3084f4 0%, #39d5ff 97%);
98
+ border-radius: 34px;
99
+ padding: 33px 66px 30px 60px;
100
+ box-shadow: 0 0 90px 20px #42e5ff3a, 0 0 0 12px #11b6ff0a;
101
+ display: flex;
102
+ flex-direction: column;
103
+ align-items: center;
104
+ border: 3.5px solid #79e8ffcc;
105
+ }
106
+ .main-pill-title {
107
+ font-size: 3.2em;
108
+ font-weight: 900;
109
+ color: #fff;
110
+ letter-spacing: .04em;
111
+ text-shadow: 0 10px 70px #1ad1f3a9, 0 3px 24px #36b0ecba;
112
+ }
113
+ .main-pill-subtitle {
114
+ color: #e7f7ff;
115
+ margin-top: 11px;
116
+ font-size: 1.17em;
117
+ font-weight: 500;
118
+ letter-spacing: .01em;
119
+ text-shadow: 0 2px 14px #99faffad;
120
+ }
121
+ .section-header { font-size: 1.55em;font-weight:800;letter-spacing:.02em;color:#fff;margin-bottom:24px;margin-top:30px;text-shadow:0 4px 34px #09dede,0 2px 8px #2989d2;display:block;}
122
  .result-labels-row{display:flex;align-items:center;gap:18px;margin-bottom:10px;margin-top:-6px;}
123
  .result-label-text{font-size:1.08em;font-weight:700;color:#daf6ff;letter-spacing:.01em;margin-right:2px;}
124
  .badge{display:inline-block;border-radius:999px;padding:4px 16px;font-weight:600;background:linear-gradient(90deg,#2870ee 70%,#13e4fc 140%);box-shadow:0 1px 12px #0663fd29;color:#fff;margin-right:8px;font-size:1.02em;vertical-align:middle;}
 
135
  .btn-md {padding:10px 22px;border-radius:14px; border:none;font-size:1.03em;font-weight:700;background:#3246b8; color:#fff;}
136
  .btn-md:hover { background:#2284cc;}
137
  .clear-btn { background:#db2828!important;color:#fff!important;padding:10px 24px;font-weight:600;border-radius:13px;border:none;font-size:1.07em;margin-bottom:22px;}
138
+ #paste-btn .wrap {font-size:1.13em;}
139
  """
140
 
141
  with gr.Blocks(css=css) as demo:
142
+ gr.HTML("""
143
+ <div class='main-pill-header'>
144
+ <div class='main-pill'>
145
+ <span class='main-pill-title'>📧 AI Email Classifier & Router</span>
146
+ <span class='main-pill-subtitle'>Instantly categorize, summarize, and draft replies to business emails.</span>
147
+ </div>
148
+ </div>
149
+ """)
150
 
151
  with gr.Row():
152
  with gr.Column(scale=6, min_width=420):
 
163
  legal_button = gr.Button("Legal Inquiry")
164
  meeting_button = gr.Button("Meeting Scheduling")
165
  email_box = gr.Textbox(lines=8, label="", placeholder="From: ...\nSubject: ...")
166
+ paste_btn = gr.Button("📋 Paste from Clipboard", elem_id="paste-btn", elem_classes=["glass-btn"])
167
  classify_btn = gr.Button("Classify Email", elem_classes=["glass-btn"])
168
  with gr.Column(scale=8, min_width=430):
169
  gr.HTML("<div class='section-header'>🧮 Classification Results</div>")
 
198
  legal_button.click(lambda: examples[6], None, email_box)
199
  meeting_button.click(lambda: examples[7], None, email_box)
200
 
201
+ # Clipboard paste to input box!
202
+ paste_btn.click(None, None, email_box, js="(inputs,outputs)=>navigator.clipboard.readText()")
203
+
204
  def classify_and_render(email_text):
205
  result = email_classifier_router(email_text)
206
  cat = result.get("Category", "")