Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ from fastapi.responses import FileResponse
|
|
| 5 |
from fastapi.staticfiles import StaticFiles
|
| 6 |
import os
|
| 7 |
import re
|
|
|
|
| 8 |
|
| 9 |
try:
|
| 10 |
from llama_cpp import Llama
|
|
@@ -174,6 +175,18 @@ async def get_frontend_file(filename: str):
|
|
| 174 |
return FileResponse(file_path)
|
| 175 |
raise HTTPException(status_code=404, detail="File not found")
|
| 176 |
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
from fastapi.staticfiles import StaticFiles
|
| 6 |
import os
|
| 7 |
import re
|
| 8 |
+
import gradio as gr
|
| 9 |
|
| 10 |
try:
|
| 11 |
from llama_cpp import Llama
|
|
|
|
| 175 |
return FileResponse(file_path)
|
| 176 |
raise HTTPException(status_code=404, detail="File not found")
|
| 177 |
|
| 178 |
+
raise HTTPException(status_code=404, detail="File not found")
|
| 179 |
+
|
| 180 |
+
# ---------------------------------------------------------
|
| 181 |
+
# HF ZeroGPU Gradio Wrapper (The Final Hack)
|
| 182 |
+
# ---------------------------------------------------------
|
| 183 |
+
# ZeroGPU REQUIRES a Gradio app to exist, so we mount a dummy one.
|
| 184 |
+
@spaces.GPU(duration=120)
|
| 185 |
+
def dummy_gpu_task():
|
| 186 |
+
pass
|
| 187 |
+
|
| 188 |
+
demo = gr.Interface(fn=dummy_gpu_task, inputs="text", outputs="text")
|
| 189 |
+
app = gr.mount_gradio_app(app, demo, path="/dummy_gradio")
|
| 190 |
+
|
| 191 |
+
# !!!注意!!!
|
| 192 |
+
# uvicorn.run は絶対に呼ばないこと。Hugging FaceのGradioランチャーが自動でappを起動します。
|