-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_simple_demo.py
More file actions
285 lines (236 loc) · 10.1 KB
/
streamlit_simple_demo.py
File metadata and controls
285 lines (236 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#!/usr/bin/env python3
"""Simplified Streamlit interface for ReqDefender"""
import streamlit as st
import random
import time
from datetime import datetime
# Page configuration
st.set_page_config(
page_title="ReqDefender - Agent Debate Arena",
page_icon="🛡️",
layout="wide"
)
# CSS for styling
st.markdown("""
<style>
.big-title {
font-size: 3rem;
text-align: center;
color: #1f77b4;
margin-bottom: 0.5rem;
}
.subtitle {
text-align: center;
color: #666;
margin-bottom: 2rem;
}
.verdict-approved {
background: #d1fae5;
border: 2px solid #10b981;
padding: 1rem;
border-radius: 0.5rem;
color: #065f46;
}
.verdict-rejected {
background: #fee2e2;
border: 2px solid #ef4444;
padding: 1rem;
border-radius: 0.5rem;
color: #991b1b;
}
.evidence-card {
background: linear-gradient(135deg, #1F2937 0%, #111827 100%) !important;
border: 2px solid #3B82F6 !important;
color: #F3F4F6 !important;
padding: 1rem;
border-radius: 0.5rem;
margin: 0.5rem 0;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.evidence-card strong {
color: #60A5FA !important;
}
.evidence-card em {
color: #F3F4F6 !important;
}
.evidence-card small {
color: #D1D5DB !important;
}
</style>
""", unsafe_allow_html=True)
def main():
# Header
st.markdown('<h1 class="big-title">🛡️ ReqDefender</h1>', unsafe_allow_html=True)
st.markdown('<p class="subtitle">AI Agents Debate Your Requirements to Death</p>', unsafe_allow_html=True)
st.markdown("---")
# Sidebar configuration
with st.sidebar:
st.header("⚙️ Configuration")
judge_type = st.selectbox(
"Judge Personality",
["Pragmatist", "Innovator", "User Advocate"],
help="Different judges have different biases"
)
intensity = st.select_slider(
"Debate Intensity",
options=["Quick", "Standard", "Deep"],
value="Standard"
)
st.markdown("---")
st.subheader("🎭 The Agents")
st.markdown("**PRO Team (Advocates) 💚**")
st.markdown("🎯 Product Visionary \n💰 Sales Champion \n🎨 UX Designer")
st.markdown("**CON Team (Skeptics) ❤️**")
st.markdown("🏗️ Senior Architect \n🔍 QA Engineer \n📊 Data Analyst")
# Main interface
col1, col2 = st.columns([3, 1])
with col1:
requirement = st.text_area(
"What feature or requirement should we debate?",
placeholder="e.g., 'Add blockchain to our todo app', 'Implement AI-powered code review'",
height=100
)
with col2:
st.markdown("<br>", unsafe_allow_html=True)
analyze_button = st.button("🎯 Start Debate", type="primary", use_container_width=True)
# Example buttons
st.markdown("**Try these examples:**")
col1, col2, col3 = st.columns(3)
with col1:
if st.button("💡 Add blockchain to our todo app"):
st.session_state.example_requirement = "Add blockchain to our todo app"
with col2:
if st.button("💡 Implement real-time collaboration"):
st.session_state.example_requirement = "Implement real-time collaboration"
with col3:
if st.button("💡 Build AI chatbot for support"):
st.session_state.example_requirement = "Build AI chatbot for customer support"
# Use example if clicked
if hasattr(st.session_state, 'example_requirement'):
requirement = st.session_state.example_requirement
del st.session_state.example_requirement
st.rerun()
if analyze_button and requirement:
run_debate_simulation(requirement, judge_type, intensity)
def run_debate_simulation(requirement: str, judge_type: str, intensity: str):
"""Run a simulated debate"""
st.markdown("---")
st.markdown("## ⚔️ Debate Arena")
# Progress bar
progress_bar = st.progress(0)
status_text = st.empty()
# Simulate debate phases
phases = [
("🎭 Pre-Battle", "Agents preparing arguments..."),
("📢 Opening Statements", "Teams present their initial positions..."),
("⚔️ Evidence Duel", "Rapid-fire evidence exchange!"),
("🎯 Cross-Examination", "Critical questions and challenges..."),
("🏁 Final Arguments", "Last chance to convince the judge..."),
("⚖️ Judgment", "Judge deliberating...")
]
# Debate visualization
debate_container = st.container()
for i, (phase, description) in enumerate(phases):
progress_bar.progress((i + 1) / len(phases))
status_text.text(f"{phase}: {description}")
with debate_container:
if i == 0: # Pre-battle
st.info(f"🎭 **Analyzing requirement:** {requirement}")
elif i == 1: # Opening statements
col1, col2 = st.columns(2)
with col1:
st.success("💚 **Product Visionary**: This represents the future of our industry! Innovation requires bold moves like this.")
with col2:
st.error("❤️ **Senior Architect**: I've seen this fail spectacularly before. The complexity alone will sink us.")
elif i == 2: # Evidence duel
st.markdown("### 📊 Evidence Presented")
col1, col2 = st.columns(2)
with col1:
st.markdown("""
<div class="evidence-card">
<strong>🥈 SILVER EVIDENCE</strong><br>
<em>Claim:</em> Market research shows 73% want this feature<br>
<small>Source: TechReport 2024</small>
</div>
""", unsafe_allow_html=True)
with col2:
st.markdown("""
<div class="evidence-card">
<strong>🥇 GOLD EVIDENCE</strong><br>
<em>Claim:</em> 3 competitors removed similar features after poor adoption<br>
<small>Source: Post-mortem Analysis</small>
</div>
""", unsafe_allow_html=True)
st.warning("⚡ **OBJECTION!** That market research was B2C focused, we're B2B!")
elif i == 3: # Cross-examination
st.markdown("### 🎯 Critical Questions")
st.info("**QA Engineer**: What about the 47 edge cases I've documented? Each one needs testing and maintenance.")
st.info("**UX Designer**: Users are already confused by our current interface. This adds complexity without solving core pain points.")
# Add delay for drama
delay = 0.5 if intensity == "Quick" else 1.0 if intensity == "Standard" else 1.5
time.sleep(delay)
# Final verdict
st.markdown("---")
st.markdown("## 🏛️ Final Verdict")
# Simulate judgment based on requirement
confidence = random.randint(65, 95)
# Simple heuristics for demo
blockchain_keywords = ["blockchain", "crypto", "nft", "web3"]
ai_keywords = ["ai", "machine learning", "artificial intelligence"]
simple_keywords = ["search", "filter", "sort", "export"]
req_lower = requirement.lower()
if any(keyword in req_lower for keyword in blockchain_keywords):
verdict = "REJECTED"
confidence = random.randint(80, 95)
alternative = "Use PostgreSQL with audit logs for immutable records"
savings = 2100000
elif any(keyword in req_lower for keyword in simple_keywords):
verdict = "APPROVED"
confidence = random.randint(75, 90)
alternative = None
savings = 0
else:
verdict = random.choice(["APPROVED", "REJECTED", "CONDITIONAL"])
alternative = "Consider a simpler MVP approach first"
savings = random.randint(500000, 3000000) if verdict == "REJECTED" else 0
# Display verdict
if verdict == "APPROVED":
st.markdown(f"""
<div class="verdict-approved">
<h2 style="text-align: center;">✅ VERDICT: APPROVED ✅</h2>
<h3 style="text-align: center;">Judge Confidence: {confidence}%</h3>
<p><strong>Judge ({judge_type}):</strong> The evidence supports implementing this requirement.
Proceed with implementation while monitoring adoption closely.</p>
</div>
""", unsafe_allow_html=True)
else:
st.markdown(f"""
<div class="verdict-rejected">
<h2 style="text-align: center;">❌ VERDICT: {verdict} ❌</h2>
<h3 style="text-align: center;">Judge Confidence: {confidence}%</h3>
<p><strong>Judge ({judge_type}):</strong> The evidence suggests significant risks and concerns.
The implementation complexity and maintenance burden outweigh potential benefits.</p>
{f'<p><strong>Alternative:</strong> {alternative}</p>' if alternative else ''}
{f'<h2 style="text-align: center;">💰 Money Saved: ${savings:,}</h2>' if savings > 0 else ''}
</div>
""", unsafe_allow_html=True)
# Show confidence meters
st.markdown("### 📊 Final Confidence Scores")
col1, col2 = st.columns(2)
with col1:
pro_confidence = 100 - confidence if verdict == "REJECTED" else confidence
st.metric("💚 PRO Team", f"{pro_confidence}%")
with col2:
con_confidence = confidence if verdict == "REJECTED" else 100 - confidence
st.metric("❤️ CON Team", f"{con_confidence}%")
# Celebrate or commiserate
if verdict == "APPROVED":
st.balloons()
else:
st.success("💡 **Money Saved!** Another bad requirement stopped before development.")
# Add restart button
if st.button("🔄 Analyze Another Requirement"):
st.rerun()
if __name__ == "__main__":
main()
#built with love