Spaces:
Sleeping
Sleeping
Create server.py
Browse files
server.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
import subprocess
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
|
| 6 |
+
MODEL_PATH = "deepseek-coder-v2-lite.Q4_K_M.gguf"
|
| 7 |
+
|
| 8 |
+
@app.get("/")
|
| 9 |
+
def read_root():
|
| 10 |
+
return {"status": "DeepSeek server running"}
|
| 11 |
+
|
| 12 |
+
@app.post("/generate")
|
| 13 |
+
def generate(prompt: str):
|
| 14 |
+
|
| 15 |
+
cmd = [
|
| 16 |
+
"./llama.cpp/main",
|
| 17 |
+
"-m", MODEL_PATH,
|
| 18 |
+
"-p", prompt,
|
| 19 |
+
"-n", "300",
|
| 20 |
+
"--ctx-size", "8192"
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
result = subprocess.run(cmd, capture_output=True, text=True)
|
| 24 |
+
|
| 25 |
+
return {"response": result.stdout}
|