Update app.py
Browse files
app.py
CHANGED
@@ -51,7 +51,7 @@ def pre_query(sender, recipient, recipient_name, context, input, model_id):
|
|
51 |
if type(data) is dict:
|
52 |
return data['error']
|
53 |
else:
|
54 |
-
|
55 |
|
56 |
if model_id == "EleutherAI/gpt-neo-2.7B":
|
57 |
input_string = "Write a professional email to my " + recipient + " starting with Hello " + recipient_name + ", about the subject " + context + " and the email should be based on this draft: " + input
|
@@ -67,6 +67,11 @@ def pre_query(sender, recipient, recipient_name, context, input, model_id):
|
|
67 |
|
68 |
return
|
69 |
|
|
|
|
|
|
|
|
|
|
|
70 |
demo = gr.Blocks()
|
71 |
|
72 |
with demo:
|
@@ -79,20 +84,25 @@ with demo:
|
|
79 |
with gr.Column():
|
80 |
with gr.Group():
|
81 |
with gr.Row():
|
82 |
-
|
83 |
-
|
84 |
-
recipient = gr.Dropdown(["student", "professor", "employee", "employer", "coworker", "applicant", "recruiter"], label="I am writing to my...")
|
85 |
recipient_name = gr.Textbox(label="Recipient Name", placeholder = "Their name is...")
|
86 |
|
87 |
-
|
|
|
88 |
email = gr.Textbox(label="Input", lines=10, placeholder="Enter your Message Here!")
|
89 |
model_id = gr.Dropdown(["GPT-3", "bigscience/T0pp", "bigscience/bloom", "EleutherAI/gpt-neo-2.7B"] ,label = "model_id")
|
90 |
-
|
91 |
submit_button = gr.Button("Generate my email!")
|
92 |
text_output = gr.Textbox(lines=10, label = "Email", placeholder = "Your generated email!", interactive = True)
|
93 |
|
94 |
-
|
|
|
|
|
|
|
|
|
95 |
|
|
|
|
|
96 |
submit_button.click(pre_query, inputs = input_list, outputs=text_output)
|
97 |
-
|
98 |
demo.launch(debug=True)
|
|
|
51 |
if type(data) is dict:
|
52 |
return data['error']
|
53 |
else:
|
54 |
+
return "Hello " + recipient_name + ",\n\n" + data[0]['generated_text'].replace(input_string,'')
|
55 |
|
56 |
if model_id == "EleutherAI/gpt-neo-2.7B":
|
57 |
input_string = "Write a professional email to my " + recipient + " starting with Hello " + recipient_name + ", about the subject " + context + " and the email should be based on this draft: " + input
|
|
|
67 |
|
68 |
return
|
69 |
|
70 |
+
def set_email_link(email, recipient_address, subject):
|
71 |
+
email = email.replace(' ', '%20')
|
72 |
+
link = "mailto:" + recipient_address + "?subject=" + subject.replace(' ', '%20') + "&body=" + email.replace('\n', '%0A')
|
73 |
+
return link
|
74 |
+
|
75 |
demo = gr.Blocks()
|
76 |
|
77 |
with demo:
|
|
|
84 |
with gr.Column():
|
85 |
with gr.Group():
|
86 |
with gr.Row():
|
87 |
+
sender = gr.Dropdown(["student", "professor", "employee", "employer", "coworker", "applicant", "recruiter"], label="From", placeholder="I am a...")
|
88 |
+
recipient = gr.Dropdown(["student", "professor", "employee", "employer", "coworker", "applicant", "recruiter"], label="Recipient", placeholder="I am sending to my...")
|
|
|
89 |
recipient_name = gr.Textbox(label="Recipient Name", placeholder = "Their name is...")
|
90 |
|
91 |
+
|
92 |
+
subject = gr.Dropdown([ "Requesting a meeting", "Conflict with scheduled meeting time", "Requesting clarification", "Requesting to leave early", "Requesting a leave of absence", "Requesting a letter of recommendation", "Requesting a referral for a job application"], label= "Subject/Context")
|
93 |
email = gr.Textbox(label="Input", lines=10, placeholder="Enter your Message Here!")
|
94 |
model_id = gr.Dropdown(["GPT-3", "bigscience/T0pp", "bigscience/bloom", "EleutherAI/gpt-neo-2.7B"] ,label = "model_id")
|
|
|
95 |
submit_button = gr.Button("Generate my email!")
|
96 |
text_output = gr.Textbox(lines=10, label = "Email", placeholder = "Your generated email!", interactive = True)
|
97 |
|
98 |
+
with gr.Row():
|
99 |
+
recipient_address = gr.Textbox(label="To", placeholder ="recipient's address")
|
100 |
+
link = gr.HTML("<a href=\"https://huggingface.co/spaces/KneeKhan/DSSG_Test\">Visit W3Schools</a>")
|
101 |
+
email_link = gr.Textbox(label="Click to email", placeholder ="click after email")
|
102 |
+
send_email = gr.Button("Send email!")
|
103 |
|
104 |
+
input_list = [sender, recipient, recipient_name, subject, email, model_id]
|
105 |
+
|
106 |
submit_button.click(pre_query, inputs = input_list, outputs=text_output)
|
107 |
+
send_email.click(set_email_link, inputs = [text_output, recipient_address, subject], outputs = email_link)
|
108 |
demo.launch(debug=True)
|