Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,55 +1,118 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from orchestrator import run_workflow
|
| 3 |
|
| 4 |
-
def launch_app(problem, agent_order, bias_mode, human_override, human_text):
|
| 5 |
-
outputs = run_workflow(problem, agent_order, bias_mode)
|
| 6 |
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
return (
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
final
|
| 18 |
)
|
| 19 |
|
| 20 |
-
with gr.Blocks(title="AI Strategy Lab") as demo:
|
| 21 |
-
gr.Markdown("# π§ AI Strategy Lab")
|
| 22 |
-
gr.Markdown("**Multi-Agent AI | Workflow Order | Human-in-the-Loop**")
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
)
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
)
|
| 54 |
|
|
|
|
| 55 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from orchestrator import run_workflow
|
| 3 |
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
def run_system(problem, order, bias, override, human_text):
|
| 6 |
|
| 7 |
+
results = run_workflow(problem, order, bias)
|
| 8 |
+
|
| 9 |
+
final = results.get("Final", "")
|
| 10 |
+
|
| 11 |
+
if override and human_text.strip():
|
| 12 |
+
final = f"π§ββοΈ HUMAN OVERRIDE\n\n{human_text}"
|
| 13 |
|
| 14 |
return (
|
| 15 |
+
results.get("Market", ""),
|
| 16 |
+
results.get("Finance", ""),
|
| 17 |
+
results.get("Risk", ""),
|
| 18 |
+
results.get("Ethics", ""),
|
| 19 |
final
|
| 20 |
)
|
| 21 |
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
# Material-style theme
|
| 24 |
+
theme = gr.themes.Soft(
|
| 25 |
+
primary_hue="blue",
|
| 26 |
+
secondary_hue="cyan",
|
| 27 |
+
radius_size="lg",
|
| 28 |
+
font=["Inter", "sans-serif"]
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
|
| 32 |
+
with gr.Blocks(theme=theme) as demo:
|
| 33 |
+
|
| 34 |
+
gr.Markdown(
|
| 35 |
+
"""
|
| 36 |
+
# π§ AI Strategy Lab
|
| 37 |
+
### Multi-Agent Decision System
|
| 38 |
+
|
| 39 |
+
Demonstrates:
|
| 40 |
+
β’ Agent workflows
|
| 41 |
+
β’ Order effects
|
| 42 |
+
β’ Bias
|
| 43 |
+
β’ Human-in-the-loop
|
| 44 |
+
"""
|
| 45 |
)
|
| 46 |
|
| 47 |
+
with gr.Row():
|
| 48 |
+
|
| 49 |
+
with gr.Column(scale=2):
|
| 50 |
+
|
| 51 |
+
problem = gr.Textbox(
|
| 52 |
+
label="π Problem Statement",
|
| 53 |
+
lines=4,
|
| 54 |
+
placeholder="Should we launch Product X in Market Y?"
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
order = gr.Textbox(
|
| 58 |
+
label="π Agent Order (comma-separated)",
|
| 59 |
+
value="Market, Finance, Risk, Ethics",
|
| 60 |
+
info="Example: Risk, Finance, Market, Ethics"
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
bias = gr.Checkbox(
|
| 64 |
+
label="Inject Market Bias"
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
override = gr.Checkbox(
|
| 68 |
+
label="Enable Human Override"
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
human_text = gr.Textbox(
|
| 72 |
+
label="Human Decision",
|
| 73 |
+
lines=3
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
run_btn = gr.Button(
|
| 77 |
+
"π Run Analysis",
|
| 78 |
+
variant="primary"
|
| 79 |
+
)
|
| 80 |
+
|
| 81 |
+
with gr.Column(scale=3):
|
| 82 |
+
|
| 83 |
+
with gr.Tab("π Market"):
|
| 84 |
+
market_out = gr.Textbox(lines=10)
|
| 85 |
+
|
| 86 |
+
with gr.Tab("π° Finance"):
|
| 87 |
+
finance_out = gr.Textbox(lines=10)
|
| 88 |
+
|
| 89 |
+
with gr.Tab("β οΈ Risk"):
|
| 90 |
+
risk_out = gr.Textbox(lines=10)
|
| 91 |
+
|
| 92 |
+
with gr.Tab("π± Ethics"):
|
| 93 |
+
ethics_out = gr.Textbox(lines=10)
|
| 94 |
+
|
| 95 |
+
with gr.Tab("β
Final Decision"):
|
| 96 |
+
final_out = gr.Textbox(lines=12)
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
run_btn.click(
|
| 100 |
+
run_system,
|
| 101 |
+
inputs=[
|
| 102 |
+
problem,
|
| 103 |
+
order,
|
| 104 |
+
bias,
|
| 105 |
+
override,
|
| 106 |
+
human_text
|
| 107 |
+
],
|
| 108 |
+
outputs=[
|
| 109 |
+
market_out,
|
| 110 |
+
finance_out,
|
| 111 |
+
risk_out,
|
| 112 |
+
ethics_out,
|
| 113 |
+
final_out
|
| 114 |
+
]
|
| 115 |
)
|
| 116 |
|
| 117 |
+
|
| 118 |
demo.launch()
|