Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
|
| 4 |
+
MODEL_PATH = "/app/model/model.gguf"
|
| 5 |
+
|
| 6 |
+
def query_model(prompt):
|
| 7 |
+
cmd = [
|
| 8 |
+
"/llama.cpp/main", "-m", MODEL_PATH,
|
| 9 |
+
"-t", "4", # threads
|
| 10 |
+
"--prompt", prompt,
|
| 11 |
+
"--n_predict", "128" # tokens to generate
|
| 12 |
+
]
|
| 13 |
+
result = subprocess.run(cmd, capture_output=True, text=True)
|
| 14 |
+
return result.stdout
|
| 15 |
+
|
| 16 |
+
iface = gr.Interface(
|
| 17 |
+
fn=query_model,
|
| 18 |
+
inputs="text",
|
| 19 |
+
outputs="text",
|
| 20 |
+
title="GGUF Docker Chatbot"
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|