Delete app.py
Browse files
app.py
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
from fastapi import FastAPI, Request
|
2 |
-
from fastapi.responses import HTMLResponse, StreamingResponse
|
3 |
-
from fastapi.staticfiles import StaticFiles
|
4 |
-
from modules.pmbl import PMBL
|
5 |
-
|
6 |
-
app = FastAPI(docs_url=None, redoc_url=None)
|
7 |
-
|
8 |
-
app.mount("/static", StaticFiles(directory="static"), name="static")
|
9 |
-
app.mount("/templates", StaticFiles(directory="templates"), name="templates")
|
10 |
-
|
11 |
-
pmbl = PMBL("./PMB-7b.Q6_K.gguf") # Replace with the path to your model
|
12 |
-
|
13 |
-
@app.head("/")
|
14 |
-
@app.get("/")
|
15 |
-
def index() -> HTMLResponse:
|
16 |
-
with open("templates/index.html") as f:
|
17 |
-
return HTMLResponse(content=f.read())
|
18 |
-
|
19 |
-
@app.post("/chat")
|
20 |
-
async def chat(request: Request):
|
21 |
-
try:
|
22 |
-
data = await request.json()
|
23 |
-
user_input = data["user_input"]
|
24 |
-
mode = data["mode"]
|
25 |
-
history = pmbl.get_chat_history(mode, user_input)
|
26 |
-
response_generator = pmbl.generate_response(user_input, history, mode)
|
27 |
-
return StreamingResponse(response_generator, media_type="text/plain")
|
28 |
-
except Exception as e:
|
29 |
-
print(f"[SYSTEM] Error: {str(e)}")
|
30 |
-
return {"error": str(e)}
|
31 |
-
|
32 |
-
@app.post("/sleep")
|
33 |
-
async def sleep():
|
34 |
-
try:
|
35 |
-
pmbl.sleep_mode()
|
36 |
-
return {"message": "Sleep mode completed successfully"}
|
37 |
-
except Exception as e:
|
38 |
-
print(f"[SYSTEM] Error: {str(e)}")
|
39 |
-
return {"error": str(e)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|