Sergidev commited on
Commit
b4c2fa9
·
verified ·
1 Parent(s): 2800109

Delete modules/app.py

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