File size: 902 Bytes
0608d7d
9b737c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3f85238
 
9b737c5
 
 
 
 
 
0608d7d
9b737c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
import spaces
import uvicorn

# Dummy GPU function at the module level to pass ZeroGPU startup check
@spaces.GPU
def _satisfy_zerogpu_startup_check():
    """Dummy function to bypass ZeroGPU startup requirement."""
    return "GPU available"

from app.main import app as fastapi_app

# 1. Create the Gradio Interface
def moderate_ui(text):
    return f"Processing text: {text}"

demo = gr.Interface(
    fn=moderate_ui,
    inputs="text",
    outputs="text",
    title="Multilingual Moderation API"
)

# 2. Mount your FastAPI app onto Gradio's underlying FastAPI instance
# This keeps your /moderate and /health endpoints accessible.
# We mount it under the "/api" path to avoid conflicts.
demo.app.mount("/api", fastapi_app)

# 3. Launch Gradio (required for ZeroGPU)
if __name__ == "__main__":
    demo.launch(server_name="0.0.0.0", server_port=7860)