Prof-Hunter commited on
Commit
249243b
Β·
verified Β·
1 Parent(s): e9ec130

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +101 -38
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
- final = outputs["Final Recommendation"]
8
 
9
- if human_override:
10
- final = f"HUMAN OVERRIDE APPLIED:\n\n{human_text}"
 
 
 
 
11
 
12
  return (
13
- outputs.get("Market", ""),
14
- outputs.get("Finance", ""),
15
- outputs.get("Risk", ""),
16
- outputs.get("Ethics", ""),
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
- problem = gr.Textbox(label="Problem Statement", lines=4)
 
 
 
 
 
 
 
25
 
26
- agent_order = gr.CheckboxGroup(
27
- ["Market", "Finance", "Risk", "Ethics"],
28
- value=["Market", "Finance", "Risk", "Ethics"],
29
- label="Agent Execution Order (ORDER MATTERS!)"
 
 
 
 
 
 
 
 
 
30
  )
31
 
32
- bias_mode = gr.Checkbox(label="Inject Market Optimism Bias")
33
- human_override = gr.Checkbox(label="Enable Human Override")
34
- human_text = gr.Textbox(label="Human Decision", lines=3)
35
-
36
- run = gr.Button("πŸš€ Run AI Strategy Lab")
37
-
38
- with gr.Tab("Market Agent"):
39
- market_out = gr.Textbox(lines=10)
40
- with gr.Tab("Finance Agent"):
41
- finance_out = gr.Textbox(lines=10)
42
- with gr.Tab("Risk Agent"):
43
- risk_out = gr.Textbox(lines=10)
44
- with gr.Tab("Ethics Agent"):
45
- ethics_out = gr.Textbox(lines=10)
46
- with gr.Tab("Final Decision"):
47
- final_out = gr.Textbox(lines=12)
48
-
49
- run.click(
50
- launch_app,
51
- inputs=[problem, agent_order, bias_mode, human_override, human_text],
52
- outputs=[market_out, finance_out, risk_out, ethics_out, final_out]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()