Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -39,35 +39,37 @@ time_travel_example = "Explain the grandfather paradox in time travel and propos
|
|
39 |
with gr.Blocks() as demo:
|
40 |
gr.Markdown("<h1 style='text-align: center;'>LLM.C 1.5B Demo</h1>")
|
41 |
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
|
45 |
-
with gr.
|
46 |
-
|
47 |
-
|
|
|
48 |
|
49 |
gr.Markdown("### Example prompts")
|
50 |
with gr.Row():
|
51 |
example1 = gr.Button("π¦ Unicorn Discovery")
|
52 |
example2 = gr.Button("β³ Time Travel Paradox")
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
58 |
|
59 |
# Set up event handlers
|
60 |
-
submit.click(generate_text, inputs=[prompt, max_tokens, temperature, top_p], outputs=output)
|
|
|
61 |
clear_button.click(clear_input, inputs=[], outputs=prompt)
|
62 |
example1.click(lambda: unicorn_example, inputs=[], outputs=prompt)
|
63 |
example2.click(lambda: time_travel_example, inputs=[], outputs=prompt)
|
64 |
|
65 |
-
gr.Markdown(
|
66 |
-
"""
|
67 |
-
## About LLM.C
|
68 |
-
some stuff about llmc
|
69 |
-
"""
|
70 |
-
)
|
71 |
-
|
72 |
if __name__ == "__main__":
|
73 |
demo.launch()
|
|
|
39 |
with gr.Blocks() as demo:
|
40 |
gr.Markdown("<h1 style='text-align: center;'>LLM.C 1.5B Demo</h1>")
|
41 |
|
42 |
+
gr.Markdown(
|
43 |
+
"""
|
44 |
+
## About LLM.C
|
45 |
+
some stuff about llmc
|
46 |
+
"""
|
47 |
+
)
|
48 |
|
49 |
+
with gr.Accordion("Advanced Settings", open=False):
|
50 |
+
max_tokens = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max New Tokens")
|
51 |
+
temperature = gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature")
|
52 |
+
top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (Nucleus Sampling)")
|
53 |
|
54 |
gr.Markdown("### Example prompts")
|
55 |
with gr.Row():
|
56 |
example1 = gr.Button("π¦ Unicorn Discovery")
|
57 |
example2 = gr.Button("β³ Time Travel Paradox")
|
58 |
+
|
59 |
+
prompt = gr.Textbox(lines=3, label='Enter your prompt')
|
60 |
+
output = gr.Textbox(lines=10, label='Generated text')
|
61 |
+
|
62 |
+
with gr.Row():
|
63 |
+
clear_button = gr.Button("π§Ή Clear input")
|
64 |
+
submit = gr.Button("π Generate")
|
65 |
+
stop_button = gr.Button("π Stop")
|
66 |
|
67 |
# Set up event handlers
|
68 |
+
submit_event = submit.click(generate_text, inputs=[prompt, max_tokens, temperature, top_p], outputs=output)
|
69 |
+
stop_button.click(fn=None, inputs=None, outputs=None, cancels=[submit_event])
|
70 |
clear_button.click(clear_input, inputs=[], outputs=prompt)
|
71 |
example1.click(lambda: unicorn_example, inputs=[], outputs=prompt)
|
72 |
example2.click(lambda: time_travel_example, inputs=[], outputs=prompt)
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
if __name__ == "__main__":
|
75 |
demo.launch()
|