eliebak HF staff commited on
Commit
b75458c
β€’
1 Parent(s): 49dac5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -18
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
- prompt = gr.Textbox(lines=3, label='Enter your prompt')
43
- output = gr.Textbox(lines=10, label='Generated text')
 
 
 
 
44
 
45
- with gr.Row():
46
- clear_button = gr.Button("🧹 Clear input")
47
- submit = gr.Button("πŸš€ Generate")
 
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
- with gr.Accordion("Advanced Settings", open=False):
55
- max_tokens = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max New Tokens")
56
- temperature = gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature")
57
- top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (Nucleus Sampling)")
 
 
 
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()