kazutab commited on
Commit
3b70b16
·
verified ·
1 Parent(s): 23805c5

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +16 -3
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
- if __name__ == "__main__":
178
- import uvicorn
179
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
 
 
 
 
 
 
 
 
 
 
 
 
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を起動します。