Spaces:
Sleeping
Sleeping
I766446 commited on
Commit ·
3015947
1
Parent(s): 5ff0156
final4
Browse files
app.py
CHANGED
|
@@ -1,52 +1,23 @@
|
|
| 1 |
-
"""
|
| 2 |
-
app.py
|
| 3 |
-
======
|
| 4 |
-
HuggingFace Spaces entry point (Gradio SDK).
|
| 5 |
-
|
| 6 |
-
Mounts the FastAPI OpenEnv server and exposes a minimal Gradio UI
|
| 7 |
-
so the Space is recognised as a Gradio app while all OpenEnv HTTP
|
| 8 |
-
endpoints (/reset, /step, /state, /health) remain accessible.
|
| 9 |
-
"""
|
| 10 |
-
|
| 11 |
-
import uvicorn
|
| 12 |
import gradio as gr
|
|
|
|
| 13 |
from server import app as fastapi_app
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
# ---------------------------------------------------------------------------
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
def run_health_check():
|
| 20 |
-
return "InformationIntegrityEnv is running.
|
| 21 |
|
| 22 |
demo = gr.Interface(
|
| 23 |
fn=run_health_check,
|
| 24 |
inputs=[],
|
| 25 |
-
outputs=
|
| 26 |
title="InformationIntegrityEnv",
|
| 27 |
-
description=(
|
| 28 |
-
"OpenEnv-compatible deterministic benchmark for reasoning-based content moderation.\n\n"
|
| 29 |
-
"**API Endpoints:**\n"
|
| 30 |
-
"- `POST /reset` — start episode (`{\"difficulty\": \"easy|medium|hard\"}`)\n"
|
| 31 |
-
"- `POST /step` — submit action\n"
|
| 32 |
-
"- `GET /health` — liveness check\n"
|
| 33 |
-
"- `GET /tasks` — list available scenarios"
|
| 34 |
-
),
|
| 35 |
)
|
| 36 |
|
| 37 |
-
# Mount Gradio
|
| 38 |
-
|
| 39 |
-
import gradio as gr
|
| 40 |
-
from server import app as fastapi_app
|
| 41 |
-
|
| 42 |
-
# Create root app
|
| 43 |
-
app = FastAPI()
|
| 44 |
-
|
| 45 |
-
# Mount FastAPI API at root
|
| 46 |
-
app.mount("/", fastapi_app)
|
| 47 |
-
|
| 48 |
-
# Mount Gradio UI separately
|
| 49 |
-
app = gr.mount_gradio_app(app, demo, path="/ui")
|
| 50 |
-
|
| 51 |
-
if __name__ == "__main__":
|
| 52 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from fastapi import FastAPI
|
| 3 |
from server import app as fastapi_app
|
| 4 |
|
| 5 |
+
# Create main app
|
| 6 |
+
app = FastAPI()
|
|
|
|
| 7 |
|
| 8 |
+
# Mount FastAPI FIRST at root
|
| 9 |
+
app.mount("", fastapi_app)
|
| 10 |
+
|
| 11 |
+
# Minimal UI
|
| 12 |
def run_health_check():
|
| 13 |
+
return "InformationIntegrityEnv is running."
|
| 14 |
|
| 15 |
demo = gr.Interface(
|
| 16 |
fn=run_health_check,
|
| 17 |
inputs=[],
|
| 18 |
+
outputs="text",
|
| 19 |
title="InformationIntegrityEnv",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
)
|
| 21 |
|
| 22 |
+
# Mount Gradio at /ui (NOT root)
|
| 23 |
+
app = gr.mount_gradio_app(app, demo, path="/ui")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|