Spaces:
Running
Running
go back to a nicer version of the old days
Browse filesSigned-off-by: peter szemraj <[email protected]>
app.py
CHANGED
@@ -71,7 +71,7 @@ def generate_text(
|
|
71 |
logging.info(rt_string)
|
72 |
|
73 |
formatted_email = postprocess(response)
|
74 |
-
return make_mailto_form(body=formatted_email),
|
75 |
|
76 |
|
77 |
def load_emailgen_model(model_tag: str):
|
@@ -198,11 +198,13 @@ if __name__ == "__main__":
|
|
198 |
gr.Markdown("---")
|
199 |
gr.Markdown("### Results")
|
200 |
# put a large HTML placeholder here
|
201 |
-
|
202 |
-
label="
|
203 |
-
placeholder="This
|
204 |
-
|
205 |
-
|
|
|
|
|
206 |
|
207 |
gr.Markdown("---")
|
208 |
gr.Markdown("## Advanced Options")
|
@@ -271,7 +273,7 @@ if __name__ == "__main__":
|
|
271 |
length_penalty,
|
272 |
num_beam_groups,
|
273 |
],
|
274 |
-
outputs=[
|
275 |
)
|
276 |
|
277 |
load_model_button.click(
|
|
|
71 |
logging.info(rt_string)
|
72 |
|
73 |
formatted_email = postprocess(response)
|
74 |
+
return make_mailto_form(body=formatted_email), formatted_email
|
75 |
|
76 |
|
77 |
def load_emailgen_model(model_tag: str):
|
|
|
198 |
gr.Markdown("---")
|
199 |
gr.Markdown("### Results")
|
200 |
# put a large HTML placeholder here
|
201 |
+
generated_email = gr.Textbox(
|
202 |
+
label="Generated Text",
|
203 |
+
placeholder="This is where the generated text will appear",
|
204 |
+
interactive=False,
|
205 |
+
|
206 |
+
)
|
207 |
+
email_mailto_button = gr.HTML("<i>a clickable email button will appear here</i>")
|
208 |
|
209 |
gr.Markdown("---")
|
210 |
gr.Markdown("## Advanced Options")
|
|
|
273 |
length_penalty,
|
274 |
num_beam_groups,
|
275 |
],
|
276 |
+
outputs=[email_mailto_button, generated_email],
|
277 |
)
|
278 |
|
279 |
load_model_button.click(
|
utils.py
CHANGED
@@ -72,7 +72,34 @@ def make_email_link(
|
|
72 |
# replace all newline chars with a whitespace
|
73 |
body = body.replace("\n", " ")
|
74 |
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
|
78 |
def make_mailto_form(body: str=None, subject: str="This email was generated by Postbot with AI!", cc_email: str="",):
|
|
|
72 |
# replace all newline chars with a whitespace
|
73 |
body = body.replace("\n", " ")
|
74 |
|
75 |
+
nice_html_button = f"""<!DOCTYPE html>
|
76 |
+
<html>
|
77 |
+
<head>
|
78 |
+
<title>Generated Email</title>
|
79 |
+
<style>
|
80 |
+
body {{
|
81 |
+
font-family: sans-serif;
|
82 |
+
font-size: 1.2em;
|
83 |
+
}}
|
84 |
+
.button {{
|
85 |
+
background-color: #6CCEC6;
|
86 |
+
border: none;
|
87 |
+
color: white;
|
88 |
+
padding: 15px 32px;
|
89 |
+
text-align: center;
|
90 |
+
text-decoration: none;
|
91 |
+
display: inline-block;
|
92 |
+
font-size: 16px;
|
93 |
+
margin: 4px 2px;
|
94 |
+
cursor: pointer;
|
95 |
+
value: "Send Email";
|
96 |
+
}}
|
97 |
+
</style>
|
98 |
+
<button class="button" onclick="window.location.href='mailto:?subject={subject}&body={body}'">{link_text} value="Open in Email client"</button>
|
99 |
+
</html>"""
|
100 |
+
|
101 |
+
# return f'<a href="mailto:%20?subject={subject}&body={body}">{link_text}</a>'
|
102 |
+
return nice_html_button
|
103 |
|
104 |
|
105 |
def make_mailto_form(body: str=None, subject: str="This email was generated by Postbot with AI!", cc_email: str="",):
|