Tomoniai commited on
Commit
f917e9d
·
1 Parent(s): c06b567

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +25 -0
main.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from llama_cpp.server.app import create_app, Settings
2
+ from fastapi.responses import HTMLResponse
3
+ import os
4
+
5
+ app = create_app(
6
+ Settings(
7
+ n_threads=2, # number of cpu cores
8
+ model="models/gguf-model.bin",
9
+ embedding=False
10
+ )
11
+ )
12
+
13
+ with open("index.html", "r") as f:
14
+ content = f.read()
15
+
16
+ @app.get("/", response_class=HTMLResponse)
17
+ async def read_items():
18
+ return content
19
+
20
+ if __name__ == "__main__":
21
+ import uvicorn
22
+ uvicorn.run(app,
23
+ host=os.environ["HOST"],
24
+ port=int(os.environ["PORT"])
25
+ )