Allture commited on
Commit
af84e50
·
verified ·
1 Parent(s): bc0607d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ if not os.path.exists(MODEL):
7
+ subprocess.run(["wget", URL])
8
+
9
+ if not os.path.exists("llama.cpp"):
10
+ subprocess.run(["git", "clone", "https://github.com/ggerganov/llama.cpp"])
11
+ subprocess.run(["make", "-C", "llama.cpp"])
12
+
13
+ def chat(prompt):
14
+ p = subprocess.Popen(
15
+ ["./llama.cpp/main", "-m", MODEL, "-p", prompt, "-n", "200"],
16
+ stdout=subprocess.PIPE
17
+ )
18
+ return p.stdout.read().decode()
19
+
20
+ gr.Interface(chat, gr.Textbox(label="Ask Dolphin"), gr.Textbox()).launch()