Sergidev commited on
Commit
889f3e5
1 Parent(s): 13796cc

Static html v1.

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -1,14 +1,15 @@
1
  from fastapi import FastAPI, Request
2
  from fastapi.responses import HTMLResponse, StreamingResponse
3
  from fastapi.templating import Jinja2Templates
 
4
  from pmbl import PMBL
5
-
6
-
7
-
8
 
9
  app = FastAPI()
10
  pmbl = PMBL("./PMB-7b.Q6_K.gguf") # Replace with the path to your model
11
 
 
 
12
  templates = Jinja2Templates(directory=".")
13
 
14
  @app.post("/chat")
@@ -37,11 +38,9 @@ async def sleep():
37
  print(f"[SYSTEM] Error: {str(e)}")
38
  return {"error": str(e)}
39
 
40
- # Remove the main function as Hugging Face Spaces will automatically run the app. Using here to test
41
-
42
  if __name__ == "__main__":
43
  import uvicorn
44
  import asyncio
45
 
46
  loop = asyncio.get_event_loop()
47
- loop.run_until_complete(uvicorn.run(app, host="0.0.0.0", port=1771))
 
1
  from fastapi import FastAPI, Request
2
  from fastapi.responses import HTMLResponse, StreamingResponse
3
  from fastapi.templating import Jinja2Templates
4
+ from fastapi.staticfiles import StaticFiles
5
  from pmbl import PMBL
6
+ import os
 
 
7
 
8
  app = FastAPI()
9
  pmbl = PMBL("./PMB-7b.Q6_K.gguf") # Replace with the path to your model
10
 
11
+ app.mount("/", StaticFiles(directory="."), name="static")
12
+
13
  templates = Jinja2Templates(directory=".")
14
 
15
  @app.post("/chat")
 
38
  print(f"[SYSTEM] Error: {str(e)}")
39
  return {"error": str(e)}
40
 
 
 
41
  if __name__ == "__main__":
42
  import uvicorn
43
  import asyncio
44
 
45
  loop = asyncio.get_event_loop()
46
+ loop.run_until_complete(uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", 8000))))