Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,48 +4,35 @@ def respond(system_message, max_length, min_length, max_new_tokens, num_beams, t
|
|
| 4 |
# Your response generation logic here
|
| 5 |
#response = correct_text(message, max_length, max_new_tokens, min_length, num_beams, temperature, top_p)
|
| 6 |
#yield response
|
| 7 |
-
return f"System message: {system_message}, Max Length: {max_length}, Min Length: {min_length}, Max new tokens: {max_new_tokens}, Num Beams: {num_beams}, Temperature: {temperature}, Top-p: {top_p}"
|
|
|
|
| 8 |
|
| 9 |
-
def set_prompt(prompt_text):
|
| 10 |
-
return gr.update(value=prompt_text)
|
| 11 |
|
| 12 |
# Create the Gradio interface
|
| 13 |
with gr.Blocks() as demo:
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
| 15 |
prompt_box = gr.Textbox(lines=2, placeholder="Enter your prompt here...")
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
show_top_p = gr.Checkbox(value=True, label="Show Top-p Slider")
|
| 34 |
-
top_p_slider = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)", visible=True)
|
| 35 |
-
show_top_p.change(lambda show: gr.update(visible=show), show_top_p, top_p_slider)
|
| 36 |
-
|
| 37 |
-
demo = gr.ChatInterface(
|
| 38 |
-
respond,
|
| 39 |
-
additional_inputs=[
|
| 40 |
-
system_message,
|
| 41 |
-
prompt_box,
|
| 42 |
-
max_length,
|
| 43 |
-
min_length,
|
| 44 |
-
max_new_tokens,
|
| 45 |
-
num_beams,
|
| 46 |
-
temperature,
|
| 47 |
-
top_p_slider,
|
| 48 |
-
],
|
| 49 |
-
)
|
| 50 |
|
| 51 |
demo.launch()
|
|
|
|
| 4 |
# Your response generation logic here
|
| 5 |
#response = correct_text(message, max_length, max_new_tokens, min_length, num_beams, temperature, top_p)
|
| 6 |
#yield response
|
| 7 |
+
#return f"System message: {system_message}, Max Length: {max_length}, Min Length: {min_length}, Max new tokens: {max_new_tokens}, Num Beams: {num_beams}, Temperature: {temperature}, Top-p: {top_p}"
|
| 8 |
+
return message
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Create the Gradio interface
|
| 12 |
with gr.Blocks() as demo:
|
| 13 |
+
gr.Markdown(
|
| 14 |
+
"""
|
| 15 |
+
# Grammar Correction App
|
| 16 |
+
""")
|
| 17 |
prompt_box = gr.Textbox(lines=2, placeholder="Enter your prompt here...")
|
| 18 |
+
output_box = gr.Textbox()
|
| 19 |
+
submitBtn = gr.Button("Submit")
|
| 20 |
+
|
| 21 |
|
| 22 |
+
with gr.Accordion("Generation Parameters:", open=False):
|
| 23 |
+
max_length = gr.Slider(minimum=1, maximum=256, value=80, step=1, label="Max Length")
|
| 24 |
+
min_length = gr.Slider(minimum=1, maximum=256, value=0, step=1, label="Min Length")
|
| 25 |
+
max_tokens = gr.Slider(minimum=0, maximum=256, value=0, step=1, label="Max new tokens")
|
| 26 |
+
num_beams = gr.Slider(minimum=1, maximum=10, value=5, step=1, label="Num Beams")
|
| 27 |
+
temperature = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature")
|
| 28 |
+
top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
|
| 29 |
+
|
| 30 |
+
#show_top_p = gr.Checkbox(value=True, label="Show Top-p Slider")
|
| 31 |
+
#top_p_slider = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)", visible=True)
|
| 32 |
+
#show_top_p.change(lambda show: gr.update(visible=show), show_top_p, top_p_slider)
|
| 33 |
+
|
| 34 |
+
submitBtn.click(respond, [prompt_box, max_length, min_length, max_tokens, num_beams, temperature, top_p], output_box)
|
| 35 |
+
|
| 36 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
demo.launch()
|