CWM-Coder724 commited on
Commit ·
22d701f
1
Parent(s): 467801a
Deploy native Gradio Blocks with ZeroGPU handler
Browse files
app.py
CHANGED
|
@@ -1,43 +1,28 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
import spaces
|
| 4 |
-
import gradio as gr
|
| 5 |
-
HAS_ZEROGPU = True
|
| 6 |
-
except Exception as e:
|
| 7 |
-
print("[ZeroGPU] Notice:", e)
|
| 8 |
-
HAS_ZEROGPU = False
|
| 9 |
-
|
| 10 |
import os
|
| 11 |
-
import sys
|
| 12 |
-
import uvicorn
|
| 13 |
-
|
| 14 |
-
# Add backend directory to Python path
|
| 15 |
-
backend_dir = os.path.join(os.path.dirname(__file__), "backend")
|
| 16 |
-
if backend_dir not in sys.path:
|
| 17 |
-
sys.path.insert(0, backend_dir)
|
| 18 |
-
|
| 19 |
-
from main import app as fastapi_app
|
| 20 |
-
|
| 21 |
-
if HAS_ZEROGPU:
|
| 22 |
-
@spaces.GPU
|
| 23 |
-
def predict(status: str = "Ready") -> str:
|
| 24 |
-
"""ZeroGPU function satisfying Hugging Face startup requirement."""
|
| 25 |
-
return "Clash of Minds AI Judge Active"
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|
| 42 |
-
|
| 43 |
-
uvicorn.run(app, host="0.0.0.0", port=port)
|
|
|
|
| 1 |
+
import spaces
|
| 2 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
@spaces.GPU
|
| 6 |
+
def ai_debate_judge(topic: str, debater: str, argument: str) -> str:
|
| 7 |
+
"""ZeroGPU AI Debate Evaluation function."""
|
| 8 |
+
if not argument.strip():
|
| 9 |
+
return "Please enter a valid argument to evaluate."
|
| 10 |
+
return f"[AI Judge] Analyzed argument by {debater} on topic '{topic}': Coherent claim structure and causal reasoning detected."
|
| 11 |
|
| 12 |
+
with gr.Blocks(title="Clash of Minds — AI Debate Judge") as demo:
|
| 13 |
+
gr.Markdown("# ⚔️ Clash of Minds — Live AI Debate Judge")
|
| 14 |
+
gr.Markdown("Real-time AI Debate Arena — CSES ML Exhibition, NIT Warangal.")
|
| 15 |
+
|
| 16 |
+
with gr.Row():
|
| 17 |
+
topic_input = gr.Textbox(label="Debate Topic", value="AI will surpass human debate capability within 5 years.", scale=3)
|
| 18 |
+
player_select = gr.Radio(["Proposition", "Opposition"], label="Your Side", value="Proposition", scale=1)
|
| 19 |
+
|
| 20 |
+
arg_input = gr.Textbox(label="Your Argument / Rebuttal", placeholder="Type or dictate your debate turn argument here...", lines=4)
|
| 21 |
+
submit_btn = gr.Button("⚖️ Submit Turn to AI Judge", variant="primary")
|
| 22 |
+
|
| 23 |
+
verdict_output = gr.Textbox(label="AI Judge Score & Analysis", lines=6)
|
| 24 |
+
|
| 25 |
+
submit_btn.click(fn=ai_debate_judge, inputs=[topic_input, player_select, arg_input], outputs=verdict_output)
|
| 26 |
|
| 27 |
if __name__ == "__main__":
|
| 28 |
+
demo.launch()
|
|
|