File size: 790 Bytes
d7b9aa8
8039e43
d7b9aa8
8039e43
d7b9aa8
8039e43
 
d7b9aa8
 
 
 
 
8039e43
 
 
 
 
 
 
 
 
d7b9aa8
8039e43
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import subprocess
import gradio as gr

# Compile the model using "!make runfast"
try:
    subprocess.run(["make", "runfast"], check=True, shell=True)
    print("Model compilation successful.")
except subprocess.CalledProcessError as e:
    print("Error:", e)
    print(e.stderr)


def chatbot(prompt):
    import subprocess
    command = ["./run", "stories15M.bin", "-t", "0.8", "-p", "0.9", "-n", "256", "-i", f'"{prompt}"']
    try:
        result = subprocess.run(command, capture_output=True, text=True, check=True, shell=False)
        response = result.stdout
    except subprocess.CalledProcessError as e:
        response = "Error occurred while processing the request."
    return response

iface = gr.Interface(fn=chatbot, inputs="text", outputs="text", live=True)
iface.launch()