Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ from llama_cpp import Llama
|
|
| 3 |
import os
|
| 4 |
import json
|
| 5 |
from fastapi import FastAPI, Request
|
| 6 |
-
from fastapi.responses import JSONResponse, StreamingResponse
|
| 7 |
import uvicorn
|
| 8 |
|
| 9 |
# 1. Load Model
|
|
@@ -19,6 +19,10 @@ llm = Llama(
|
|
| 19 |
# 2. FastAPI Setup
|
| 20 |
app = FastAPI()
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
@app.get("/health")
|
| 23 |
def health():
|
| 24 |
return {"status": "ok"}
|
|
@@ -73,11 +77,8 @@ demo = gr.ChatInterface(
|
|
| 73 |
description="Your private AI brain on Hugging Face.",
|
| 74 |
)
|
| 75 |
|
| 76 |
-
# 4. Mount Gradio to FastAPI
|
| 77 |
-
|
| 78 |
-
# Actually, to be safe, let's mount Gradio at / and see if FastAPI works.
|
| 79 |
-
# If not, we'll use /ui for Gradio.
|
| 80 |
-
app = gr.mount_gradio_app(app, demo, path="/")
|
| 81 |
|
| 82 |
if __name__ == "__main__":
|
| 83 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
| 3 |
import os
|
| 4 |
import json
|
| 5 |
from fastapi import FastAPI, Request
|
| 6 |
+
from fastapi.responses import JSONResponse, StreamingResponse, RedirectResponse
|
| 7 |
import uvicorn
|
| 8 |
|
| 9 |
# 1. Load Model
|
|
|
|
| 19 |
# 2. FastAPI Setup
|
| 20 |
app = FastAPI()
|
| 21 |
|
| 22 |
+
@app.get("/")
|
| 23 |
+
def read_root():
|
| 24 |
+
return RedirectResponse(url="/ui")
|
| 25 |
+
|
| 26 |
@app.get("/health")
|
| 27 |
def health():
|
| 28 |
return {"status": "ok"}
|
|
|
|
| 77 |
description="Your private AI brain on Hugging Face.",
|
| 78 |
)
|
| 79 |
|
| 80 |
+
# 4. Mount Gradio to FastAPI at /ui
|
| 81 |
+
app = gr.mount_gradio_app(app, demo, path="/ui")
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
if __name__ == "__main__":
|
| 84 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|