Spaces:
Runtime error
Runtime error
peter szemraj
commited on
Commit
·
7659e10
1
Parent(s):
fb1c532
:zap: add clear fn
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import gradio as gr
|
|
| 5 |
import torch
|
| 6 |
from transformers import pipeline
|
| 7 |
|
| 8 |
-
from utils import postprocess
|
| 9 |
|
| 10 |
logging.basicConfig(
|
| 11 |
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
|
|
@@ -136,13 +136,18 @@ if __name__ == "__main__":
|
|
| 136 |
label="Email Prompt",
|
| 137 |
value=default_prompt,
|
| 138 |
)
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
generated_email = gr.Textbox(
|
| 148 |
label="Generated Result",
|
|
@@ -155,7 +160,7 @@ if __name__ == "__main__":
|
|
| 155 |
|
| 156 |
gr.Markdown("## Advanced Options")
|
| 157 |
gr.Markdown(
|
| 158 |
-
"See details about these parameters [here](https://huggingface.co/blog/how-to-generate), otherwise they should be fine as-is."
|
| 159 |
)
|
| 160 |
|
| 161 |
num_beams = gr.Radio(
|
|
@@ -183,7 +188,11 @@ if __name__ == "__main__":
|
|
| 183 |
"The intended use of this model is to provide suggestions to _auto-complete_ the rest of your email. Said another way, it should serve as a **tool to write predictable emails faster**. It is not intended to write entire emails from scratch; at least **some input** is required to guide the direction of the model.\n\nPlease verify any suggestions by the model for A) False claims and B) negation statements **before** accepting/sending something."
|
| 184 |
)
|
| 185 |
gr.Markdown("---")
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
generate_button.click(
|
| 188 |
fn=generate_text,
|
| 189 |
inputs=[
|
|
|
|
| 5 |
import torch
|
| 6 |
from transformers import pipeline
|
| 7 |
|
| 8 |
+
from utils import postprocess, clear
|
| 9 |
|
| 10 |
logging.basicConfig(
|
| 11 |
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
|
|
|
|
| 136 |
label="Email Prompt",
|
| 137 |
value=default_prompt,
|
| 138 |
)
|
| 139 |
+
|
| 140 |
+
with gr.Row():
|
| 141 |
+
clear_button = gr.Button(
|
| 142 |
+
value="Clear Prompt",
|
| 143 |
+
)
|
| 144 |
+
num_gen_tokens = gr.Slider(
|
| 145 |
+
label="Generation Tokens",
|
| 146 |
+
value=64,
|
| 147 |
+
maximum=128,
|
| 148 |
+
minimum=32,
|
| 149 |
+
step=16,
|
| 150 |
+
)
|
| 151 |
|
| 152 |
generated_email = gr.Textbox(
|
| 153 |
label="Generated Result",
|
|
|
|
| 160 |
|
| 161 |
gr.Markdown("## Advanced Options")
|
| 162 |
gr.Markdown(
|
| 163 |
+
"This demo generates text via beam search. See details about these parameters [here](https://huggingface.co/blog/how-to-generate), otherwise they should be fine as-is."
|
| 164 |
)
|
| 165 |
|
| 166 |
num_beams = gr.Radio(
|
|
|
|
| 188 |
"The intended use of this model is to provide suggestions to _auto-complete_ the rest of your email. Said another way, it should serve as a **tool to write predictable emails faster**. It is not intended to write entire emails from scratch; at least **some input** is required to guide the direction of the model.\n\nPlease verify any suggestions by the model for A) False claims and B) negation statements **before** accepting/sending something."
|
| 189 |
)
|
| 190 |
gr.Markdown("---")
|
| 191 |
+
clear_button.on_click(
|
| 192 |
+
fn=clear,
|
| 193 |
+
input_text=[prompt_text],
|
| 194 |
+
output_text=[prompt_text],
|
| 195 |
+
)
|
| 196 |
generate_button.click(
|
| 197 |
fn=generate_text,
|
| 198 |
inputs=[
|