Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,24 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
import subprocess
|
|
|
5 |
|
6 |
-
#
|
7 |
-
command = ["make", "runfast"]
|
8 |
-
|
9 |
-
# Execute the command
|
10 |
try:
|
11 |
-
|
12 |
-
print(
|
13 |
except subprocess.CalledProcessError as e:
|
14 |
print("Error:", e)
|
15 |
print(e.stderr)
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
|
20 |
-
|
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()
|
|
|
|
|
|