teragron commited on
Commit
8039e43
1 Parent(s): 4f0a142

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -1,23 +1,24 @@
1
- import gradio as gr
2
-
3
-
4
  import subprocess
 
5
 
6
- # Define the shell command as a list of strings
7
- command = ["make", "runfast"]
8
-
9
- # Execute the command
10
  try:
11
- result = subprocess.run(command, capture_output=True, text=True, check=True)
12
- print(result.stdout)
13
  except subprocess.CalledProcessError as e:
14
  print("Error:", e)
15
  print(e.stderr)
16
 
17
 
 
 
 
 
 
 
 
 
 
18
 
19
- def greet(name):
20
- return "Hello " + name + "!!"
21
-
22
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
23
- iface.launch()
 
 
 
 
1
  import subprocess
2
+ import gradio as gr
3
 
4
+ # Compile the model using "!make runfast"
 
 
 
5
  try:
6
+ subprocess.run(["make", "runfast"], check=True, shell=True)
7
+ print("Model compilation successful.")
8
  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()