Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import gradio as gr
|
|
3 |
|
4 |
model_file = "best_model_4800it_40M.bin"
|
5 |
|
|
|
|
|
6 |
try:
|
7 |
subprocess.run(["make", "runfast"], check=True, shell=True)
|
8 |
print("Model compilation successful.")
|
@@ -10,8 +12,8 @@ except subprocess.CalledProcessError as e:
|
|
10 |
print("Error:", e)
|
11 |
print(e.stderr)
|
12 |
|
13 |
-
def chatbot(prompt, temperature, topt, maxtoken):
|
14 |
-
command = ["./run",
|
15 |
try:
|
16 |
result = subprocess.run(command, capture_output=True, text=True, check=True, shell=False)
|
17 |
response = result.stdout
|
@@ -29,11 +31,12 @@ with gr.Blocks() as demo:
|
|
29 |
temperature_slider = gr.Slider(minimum=0.1, maximum=2.0, value=0.8, label="Temperature")
|
30 |
topt_slider = gr.Slider(minimum=0.1, maximum=1.0, value=0.9, label="Topt")
|
31 |
maxtoken_slider = gr.Slider(minimum=64, maximum=1024, value=256, label="Max Tokens")
|
|
|
32 |
out = gr.Textbox()
|
33 |
|
34 |
btn = gr.Button("Run")
|
35 |
gr.Examples(examples=[["best sci-fi book ever"], ["great laptop for the price"]], inputs=[inp])
|
36 |
-
btn.click(fn=chatbot, inputs=[inp, temperature_slider, topt_slider, maxtoken_slider], outputs=out)
|
37 |
|
38 |
|
39 |
demo.launch()
|
|
|
3 |
|
4 |
model_file = "best_model_4800it_40M.bin"
|
5 |
|
6 |
+
|
7 |
+
|
8 |
try:
|
9 |
subprocess.run(["make", "runfast"], check=True, shell=True)
|
10 |
print("Model compilation successful.")
|
|
|
12 |
print("Error:", e)
|
13 |
print(e.stderr)
|
14 |
|
15 |
+
def chatbot(prompt, temperature, topt, maxtoken, model):
|
16 |
+
command = ["./run", model, "-t", str(temperature), "-p", str(topt), "-n", str(maxtoken), "-i", f"{prompt}"]
|
17 |
try:
|
18 |
result = subprocess.run(command, capture_output=True, text=True, check=True, shell=False)
|
19 |
response = result.stdout
|
|
|
31 |
temperature_slider = gr.Slider(minimum=0.1, maximum=2.0, value=0.8, label="Temperature")
|
32 |
topt_slider = gr.Slider(minimum=0.1, maximum=1.0, value=0.9, label="Topt")
|
33 |
maxtoken_slider = gr.Slider(minimum=64, maximum=1024, value=256, label="Max Tokens")
|
34 |
+
model_pick = gr.Dropdown(["best_model_4800it_40M.bin", "model_2200.bin", "model_4200.bin"], label="Model", info="Model")
|
35 |
out = gr.Textbox()
|
36 |
|
37 |
btn = gr.Button("Run")
|
38 |
gr.Examples(examples=[["best sci-fi book ever"], ["great laptop for the price"]], inputs=[inp])
|
39 |
+
btn.click(fn=chatbot, inputs=[inp, temperature_slider, topt_slider, maxtoken_slider, model_pick], outputs=out)
|
40 |
|
41 |
|
42 |
demo.launch()
|