Spaces:
Paused
Paused
Commit
·
23af35e
1
Parent(s):
6292d66
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
|
|
|
|
|
| 1 |
from llama_cpp.server.app import create_app, Settings
|
| 2 |
import tomli
|
| 3 |
|
|
|
|
| 4 |
with open("config.toml", "rb") as f:
|
| 5 |
settings = tomli.load(f)
|
| 6 |
-
|
| 7 |
settings = Settings(**settings)
|
| 8 |
|
| 9 |
-
app = create_app(settings=settings)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
rom fastapi import FastAPI
|
| 2 |
+
from fastapi.responses import HTMLResponse
|
| 3 |
from llama_cpp.server.app import create_app, Settings
|
| 4 |
import tomli
|
| 5 |
|
| 6 |
+
# Load the configuration from the config.toml file
|
| 7 |
with open("config.toml", "rb") as f:
|
| 8 |
settings = tomli.load(f)
|
|
|
|
| 9 |
settings = Settings(**settings)
|
| 10 |
|
| 11 |
+
app = create_app(settings=settings)
|
| 12 |
+
|
| 13 |
+
# Extend the app with your custom route
|
| 14 |
+
@app.get('/', response_class=HTMLResponse)
|
| 15 |
+
def custom_index_route():
|
| 16 |
+
html_content = """
|
| 17 |
+
<html>
|
| 18 |
+
<body>
|
| 19 |
+
<iframe src="https://matthoffner-chatbot.hf.space" frameborder="0" width="100%" height="100%"></iframe>
|
| 20 |
+
</body>
|
| 21 |
+
</html>
|
| 22 |
+
"""
|
| 23 |
+
return HTMLResponse(content=html_content)
|
| 24 |
+
|
| 25 |
+
if __name__ == '__main__':
|
| 26 |
+
import uvicorn
|
| 27 |
+
uvicorn.run(app, host='0.0.0.0', port=8000)
|