Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ 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()
|
@@ -16,17 +17,22 @@ async def index():
|
|
16 |
|
17 |
@app.post("/api")
|
18 |
async def completion(request: Request):
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
if __name__ == "__main__":
|
32 |
import uvicorn
|
|
|
2 |
from llama_cpp import Llama
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
import os
|
5 |
+
import requests
|
6 |
os.system("ulimit -l unlimited")
|
7 |
|
8 |
app = FastAPI()
|
|
|
17 |
|
18 |
@app.post("/api")
|
19 |
async def completion(request: Request):
|
20 |
+
try:
|
21 |
+
data = await request.json()
|
22 |
+
prompt = data["prompt"]
|
23 |
+
mode = data['mode']
|
24 |
+
if mode == 'f':
|
25 |
+
return requests.post("https://mrali-codexpert-computing.hf.space/api", json={"prompt": prompt}).json()
|
26 |
+
else:
|
27 |
+
res = model_l(
|
28 |
+
prompt,
|
29 |
+
temperature=0.6,
|
30 |
+
echo=False,
|
31 |
+
max_tokens=41,
|
32 |
+
)
|
33 |
+
return {"responses": res["choices"]}
|
34 |
+
except:
|
35 |
+
return {"responses": "Error!"}
|
36 |
|
37 |
if __name__ == "__main__":
|
38 |
import uvicorn
|