teragron commited on
Commit
08f8163
1 Parent(s): 17945bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -9,24 +9,25 @@ except subprocess.CalledProcessError as e:
9
  print("Error:", e)
10
  print(e.stderr)
11
 
12
- def chatbot(prompt):
13
- command = ["./run", "stories15M.bin", "-t", "0.8", "-p", "0.9", "-n", "256", "-i", f"{prompt}"]
14
  try:
15
  result = subprocess.run(command, capture_output=True, text=True, check=True, shell=False)
16
  response = result.stdout
17
  except subprocess.CalledProcessError as e:
18
  response = "Error occurred while processing the request."
19
  return response
20
-
21
-
22
 
23
  with gr.Blocks() as demo:
24
  gr.Markdown("HF Spaces for TinyStories")
25
  with gr.Row():
26
  inp = gr.Textbox(placeholder="Type the beginning of the story")
 
 
 
 
27
  out = gr.Textbox()
28
  btn = gr.Button("Run")
29
- btn.click(fn=chatbot, inputs=inp, outputs=out)
30
 
31
  demo.launch()
32
-
 
9
  print("Error:", e)
10
  print(e.stderr)
11
 
12
+ def chatbot(prompt, temperature, topt, maxtoken, model_file):
13
+ command = ["./run", model_file, "-t", str(temperature), "-p", str(topt), "-n", str(maxtoken), "-i", f"{prompt}"]
14
  try:
15
  result = subprocess.run(command, capture_output=True, text=True, check=True, shell=False)
16
  response = result.stdout
17
  except subprocess.CalledProcessError as e:
18
  response = "Error occurred while processing the request."
19
  return response
 
 
20
 
21
  with gr.Blocks() as demo:
22
  gr.Markdown("HF Spaces for TinyStories")
23
  with gr.Row():
24
  inp = gr.Textbox(placeholder="Type the beginning of the story")
25
+ temperature_slider = gr.Slider(minimum=0.1, maximum=2.0, default=0.8, label="Temperature")
26
+ topt_slider = gr.Slider(minimum=0.1, maximum=1.0, default=0.9, label="Topt")
27
+ maxtoken_slider = gr.Slider(minimum=16, maximum=512, default=256, label="Max Tokens")
28
+ model_file_dropdown = gr.Dropdown(choices=["stories15M.bin", "stories42M.bin", "stories110M.bin"], label="Model File")
29
  out = gr.Textbox()
30
  btn = gr.Button("Run")
31
+ btn.click(fn=chatbot, inputs=[inp, temperature_slider, topt_slider, maxtoken_slider, model_file_dropdown], outputs=out)
32
 
33
  demo.launch()