teragron commited on
Commit
17945bc
1 Parent(s): 8039e43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -9,16 +9,24 @@ except subprocess.CalledProcessError as e:
9
  print("Error:", e)
10
  print(e.stderr)
11
 
12
-
13
  def chatbot(prompt):
14
- import subprocess
15
- command = ["./run", "stories15M.bin", "-t", "0.8", "-p", "0.9", "-n", "256", "-i", f'"{prompt}"']
16
  try:
17
  result = subprocess.run(command, capture_output=True, text=True, check=True, shell=False)
18
  response = result.stdout
19
  except subprocess.CalledProcessError as e:
20
  response = "Error occurred while processing the request."
21
  return response
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- iface = gr.Interface(fn=chatbot, inputs="text", outputs="text", live=True)
24
- iface.launch()
 
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