Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,24 @@
|
|
| 1 |
-
import os, subprocess, gradio as gr
|
| 2 |
|
| 3 |
MODEL = "dolphin-2.9.3-llama3-8b.Q4_K_M.gguf"
|
| 4 |
URL = "https://huggingface.co/TheBloke/dolphin-2.9.3-llama3-8b-GGUF/resolve/main/" + MODEL
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
-
if not os.path.exists("llama
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
def chat(prompt):
|
| 14 |
p = subprocess.Popen(
|
| 15 |
-
["./llama
|
| 16 |
stdout=subprocess.PIPE
|
| 17 |
)
|
| 18 |
-
return p.stdout.read().decode()
|
| 19 |
|
| 20 |
gr.Interface(chat, gr.Textbox(label="Ask Dolphin"), gr.Textbox()).launch()
|
|
|
|
| 1 |
+
import os, subprocess, gradio as gr, shutil
|
| 2 |
|
| 3 |
MODEL = "dolphin-2.9.3-llama3-8b.Q4_K_M.gguf"
|
| 4 |
URL = "https://huggingface.co/TheBloke/dolphin-2.9.3-llama3-8b-GGUF/resolve/main/" + MODEL
|
| 5 |
|
| 6 |
+
def setup():
|
| 7 |
+
if not os.path.exists(MODEL):
|
| 8 |
+
subprocess.run(["wget", "-q", URL])
|
| 9 |
|
| 10 |
+
if not os.path.exists("llama"):
|
| 11 |
+
subprocess.run(["git", "clone", "https://github.com/ggerganov/llama.cpp"])
|
| 12 |
+
subprocess.run(["cmake", "-S", "llama.cpp", "-B", "llama"])
|
| 13 |
+
subprocess.run(["cmake", "--build", "llama", "--config", "Release"])
|
| 14 |
+
|
| 15 |
+
setup()
|
| 16 |
|
| 17 |
def chat(prompt):
|
| 18 |
p = subprocess.Popen(
|
| 19 |
+
["./llama/main", "-m", MODEL, "-p", prompt, "-n", "200"],
|
| 20 |
stdout=subprocess.PIPE
|
| 21 |
)
|
| 22 |
+
return p.stdout.read().decode(errors="ignore")
|
| 23 |
|
| 24 |
gr.Interface(chat, gr.Textbox(label="Ask Dolphin"), gr.Textbox()).launch()
|