Spaces:
Paused
Paused
Commit
•
a2ba236
1
Parent(s):
8e9db9f
Create main.py
Browse files
main.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, # set to number of cpu cores
|
8 |
+
model="model/gguf-model.bin",
|
9 |
+
embedding=True
|
10 |
+
)
|
11 |
+
)
|
12 |
+
|
13 |
+
# Read the content of index.html once and store it in memory
|
14 |
+
with open("index.html", "r") as f:
|
15 |
+
content = f.read()
|
16 |
+
|
17 |
+
|
18 |
+
@app.get("/", response_class=HTMLResponse)
|
19 |
+
async def read_items():
|
20 |
+
return content
|
21 |
+
|
22 |
+
if __name__ == "__main__":
|
23 |
+
import uvicorn
|
24 |
+
uvicorn.run(app,
|
25 |
+
host=os.environ["HOST"],
|
26 |
+
port=int(os.environ["PORT"])
|
27 |
+
)
|