Nimesh Desai
Updated description
18f52c9
import os
import gradio as gr
import time
from debate_runner import run_debate, run_debate_stream, cancel_debate
# Prevent CrewAI from initializing OpenAI
os.environ.pop("OPENAI_API_KEY", None)
os.environ["CREWAI_DISABLE_TELEMETRY"] = "true"
def debate_interface(topic):
if not topic.strip():
return "Please enter a debate topic."
result = run_debate(topic)
return result
def test_debate(topic):
time.sleep(10)
result = f"""**Summary of Both Positions**
The debate surrounding {topic}"""
return result
def handle_button(topic, state, button_label):
# If currently running β†’ cancel
if button_label == "Cancel Debate":
state = cancel_debate(state)
return (
"❌ Cancelling debate...",
state,
gr.update(value="Start Debate", variant="primary")
)
# Otherwise start debate
generator = run_debate_stream(topic, state)
# First update button to Cancel
yield (
"⏳ Starting debate...\n",
state,
gr.update(value="Cancel Debate", variant="stop")
)
# Stream debate
for output, updated_state in generator:
yield (
output,
updated_state,
gr.update(value="Cancel Debate", variant="stop")
)
# When finished β†’ reset button
yield (
output,
updated_state,
gr.update(value="Start Debate", variant="primary")
)
with gr.Blocks() as app:
gr.Markdown("# 🧠 Leadership Calibration Debate Engine")
gr.Markdown(
"Leadership Calibration Debate Engine lets you explore decisions from two key "
"engineering leadership perspectives.\n\n"
"Enter any topic and watch two AI personas debate it:\n\n"
"Technical Architect – focuses on system design, scalability, reliability, "
"and long-term technical impact.\n\n"
"Engineering Manager – focuses on team productivity, collaboration, delivery, "
"and people considerations.\n\n"
"The agents analyze the topic, challenge each other's viewpoints, and produce "
"a balanced final conclusion that reflects both technical and human factors."
)
topic_input = gr.TextArea(
label="Debate Topic",
placeholder="Example: Should companies adopt a 4-day work week?",
lines=5
)
state = gr.State({"cancelled": False})
debate_button = gr.Button("Start Debate", variant="primary")
output = gr.Markdown(visible=True)
debate_button.click(
handle_button,
inputs=[topic_input, state, debate_button],
outputs=[output, state, debate_button]
)
if __name__ == "__main__":
app.queue()
app.launch()