Spaces:
Sleeping
Sleeping
AFischer1985
commited on
Commit
•
818675e
1
Parent(s):
cd4ef9f
Create main.py
Browse files
main.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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="https://huggingface.co/TheBloke/OpenHermes-2-Mistral-7B-GGUF/resolve/main/openhermes-2-mistral-7b.Q4_0.gguf",
|
9 |
+
embedding=False
|
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="0.0.0.0",
|
26 |
+
port=int("2600")
|
27 |
+
)
|
28 |
+
|