Nafiul Huda commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import os, io, json, time,
|
| 2 |
from pathlib import Path
|
| 3 |
|
| 4 |
import gradio as gr
|
|
@@ -70,15 +70,17 @@ def ensure_llama_server() -> Path:
|
|
| 70 |
root = Path.home() / ".cache" / "llamacpp" / tag
|
| 71 |
server = root / "build" / "bin" / "llama-server"
|
| 72 |
if not server.exists():
|
|
|
|
| 73 |
url = (f"https://github.com/ggml-org/llama.cpp/releases/download/"
|
| 74 |
-
f"{tag}/llama-{tag}-bin-ubuntu-x64.
|
| 75 |
print(f"[llama.cpp] downloading {url}")
|
| 76 |
req = urllib.request.Request(url, headers={"User-Agent": "hf-space"})
|
| 77 |
with urllib.request.urlopen(req, timeout=180) as r:
|
| 78 |
blob = r.read()
|
| 79 |
root.mkdir(parents=True, exist_ok=True)
|
| 80 |
-
|
| 81 |
-
|
|
|
|
| 82 |
for f in (root / "build" / "bin").iterdir():
|
| 83 |
f.chmod(0o755)
|
| 84 |
return server
|
|
|
|
| 1 |
+
import os, io, json, time, tarfile, subprocess, urllib.request
|
| 2 |
from pathlib import Path
|
| 3 |
|
| 4 |
import gradio as gr
|
|
|
|
| 70 |
root = Path.home() / ".cache" / "llamacpp" / tag
|
| 71 |
server = root / "build" / "bin" / "llama-server"
|
| 72 |
if not server.exists():
|
| 73 |
+
# llama.cpp Linux binaries are now distributed as .tar.gz (not .zip)
|
| 74 |
url = (f"https://github.com/ggml-org/llama.cpp/releases/download/"
|
| 75 |
+
f"{tag}/llama-{tag}-bin-ubuntu-x64.tar.gz")
|
| 76 |
print(f"[llama.cpp] downloading {url}")
|
| 77 |
req = urllib.request.Request(url, headers={"User-Agent": "hf-space"})
|
| 78 |
with urllib.request.urlopen(req, timeout=180) as r:
|
| 79 |
blob = r.read()
|
| 80 |
root.mkdir(parents=True, exist_ok=True)
|
| 81 |
+
# Extract tar.gz archive
|
| 82 |
+
with tarfile.open(fileobj=io.BytesIO(blob), mode="r:gz") as t:
|
| 83 |
+
t.extractall(root)
|
| 84 |
for f in (root / "build" / "bin").iterdir():
|
| 85 |
f.chmod(0o755)
|
| 86 |
return server
|