MrAli commited on
Commit
2d57c8a
·
verified ·
1 Parent(s): 67736a0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Request
2
+ from llama_cpp import Llama
3
+ from huggingface_hub import hf_hub_download
4
+ import os
5
+ os.system("ulimit -l unlimited")
6
+
7
+ app = FastAPI()
8
+
9
+ hf_hub_download("TheBloke/deepseek-coder-6.7B-base-GGUF", "deepseek-coder-6.7b-base.Q4_K_M.gguf", local_dir="./")
10
+ model_l = Llama(model_path="./deepseek-coder-6.7b-base.Q4_K_M.gguf", n_ctx=16000, n_gpu_layers=0, n_threads=2, use_mlock=True)
11
+
12
+
13
+ @app.get("/check")
14
+ async def index():
15
+ return {"msg": "OK!"}
16
+
17
+ @app.post("/api")
18
+ async def completion(request: Request):
19
+ data = await request.json()
20
+ prompt = data["prompt"]
21
+ mode = data['mode']
22
+
23
+ res = model_l(
24
+ prompt,
25
+ temperature=0.6,
26
+ echo=False,
27
+ max_tokens=41,
28
+ )
29
+ return {"responses": res["choices"]}
30
+
31
+ if __name__ == "__main__":
32
+ import uvicorn
33
+ uvicorn.run(app, host="0.0.0.0", port=7860)