Spaces:
Sleeping
Sleeping
Update server.py
Browse files
server.py
CHANGED
|
@@ -1,9 +1,17 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
import subprocess
|
|
|
|
| 3 |
|
| 4 |
app = FastAPI()
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
@app.get("/")
|
| 9 |
def read_root():
|
|
@@ -13,12 +21,12 @@ def read_root():
|
|
| 13 |
def generate(prompt: str):
|
| 14 |
|
| 15 |
cmd = [
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
]
|
| 22 |
|
| 23 |
result = subprocess.run(cmd, capture_output=True, text=True)
|
| 24 |
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
import subprocess
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
app = FastAPI()
|
| 6 |
|
| 7 |
+
MODEL_URL = "https://huggingface.co/TheBloke/deepseek-coder-v2-lite-GGUF/resolve/main/deepseek-coder-v2-lite.Q4_K_M.gguf"
|
| 8 |
+
MODEL_PATH = "deepseek-coder.gguf"
|
| 9 |
+
|
| 10 |
+
def download_model():
|
| 11 |
+
if not os.path.exists(MODEL_PATH):
|
| 12 |
+
subprocess.run(["wget", MODEL_URL, "-O", MODEL_PATH])
|
| 13 |
+
|
| 14 |
+
download_model()
|
| 15 |
|
| 16 |
@app.get("/")
|
| 17 |
def read_root():
|
|
|
|
| 21 |
def generate(prompt: str):
|
| 22 |
|
| 23 |
cmd = [
|
| 24 |
+
"/app/llama.cpp/build/bin/llama-cli",
|
| 25 |
+
"-m", MODEL_PATH,
|
| 26 |
+
"-p", prompt,
|
| 27 |
+
"-n", "200",
|
| 28 |
+
"--ctx-size", "8192"
|
| 29 |
+
]
|
| 30 |
|
| 31 |
result = subprocess.run(cmd, capture_output=True, text=True)
|
| 32 |
|