scmlewis commited on
Commit
ecb1f7e
·
verified ·
1 Parent(s): 2c3b426

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -1
app.py CHANGED
@@ -81,4 +81,44 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
81
 
82
  with gr.Column():
83
  gr.Markdown("### ✅ Classification Results")
84
- category = gr.Textbox(label="Category", elem_id='category
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  with gr.Column():
83
  gr.Markdown("### ✅ Classification Results")
84
+ category = gr.Textbox(label="Category", elem_id='category')
85
+ priority = gr.Textbox(label="Priority", elem_id='priority')
86
+ recipient = gr.Textbox(label="Suggested Recipient", elem_id='recipient')
87
+
88
+ with gr.Column():
89
+ gr.Markdown("### ✨ Generated Response Draft")
90
+ draft_response = gr.Textbox(lines=8, label="Generated Draft", elem_id='draft_response')
91
+
92
+ with gr.Column():
93
+ gr.Markdown("#### Summary")
94
+ summary = gr.Textbox(label="Summary", elem_id='summary')
95
+
96
+ with gr.Column():
97
+ gr.Markdown("#### 🟣 Extracted Action Items")
98
+ action_items = gr.Textbox(lines=4, label="Extracted Action Items", elem_id='actions')
99
+
100
+ support_button.click(lambda: ex1, None, email_box)
101
+ sales_button.click(lambda: ex2, None, email_box)
102
+ finance_button.click(lambda: ex3, None, email_box)
103
+ urgent_button.click(lambda: ex4, None, email_box)
104
+ spam_button.click(lambda: ex5, None, email_box)
105
+
106
+ def classify_and_render(email_text):
107
+ result = email_classifier_router(email_text)
108
+ cat = result.get("Category", "")
109
+ pri = result.get("Priority", "")
110
+ rec = result.get("Suggested Recipient", "")
111
+ dra = result.get("Draft Response", "")
112
+ summ = result.get("Summary", "")
113
+ acts = result.get("Action Items", [])
114
+ acts = "\n".join(acts) if isinstance(acts, list) else acts
115
+ return cat, pri, rec, dra, summ, acts
116
+
117
+ classify_btn.click(
118
+ classify_and_render,
119
+ inputs=[email_box],
120
+ outputs=[category, priority, recipient, draft_response, summary, action_items]
121
+ )
122
+
123
+ if __name__ == "__main__":
124
+ demo.launch()