Allture commited on
Commit
c9f4e23
·
verified ·
1 Parent(s): e9809a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
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
- 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()
 
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()