cryogenic22 commited on
Commit
e120fd1
·
verified ·
1 Parent(s): 7ab7051

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -192
app.py CHANGED
@@ -21,186 +21,34 @@ st.set_page_config(
21
  # Add all CSS styles
22
  st.markdown("""
23
  <style>
24
- /* Agent Team Section */
25
- .agent-team {
26
- display: flex;
27
- justify-content: space-around;
28
- margin-bottom: 20px;
29
- padding: 20px;
30
- background: rgba(255, 255, 255, 0.9);
31
- border-radius: 15px;
32
- box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
33
- }
34
-
35
- .agent-card {
36
- text-align: center;
37
- padding: 15px;
38
- border-radius: 10px;
39
- transition: all 0.3s ease;
40
- }
41
-
42
- .agent-card.active {
43
- transform: scale(1.05);
44
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
45
- }
46
-
47
- .agent-avatar {
48
- width: 60px;
49
- height: 60px;
50
- border-radius: 50%;
51
- margin: 0 auto 10px;
52
  display: flex;
53
  align-items: center;
54
- justify-content: center;
55
- font-size: 30px;
56
- background: white;
57
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
58
- }
59
-
60
- /* Chat Messages */
61
- .chat-container {
62
- height: 400px;
63
- overflow-y: auto;
64
- padding: 20px;
65
- background: rgba(255, 255, 255, 0.9);
66
- border-radius: 15px;
67
- margin: 20px 0;
68
- }
69
-
70
- .chat-message {
71
- display: flex;
72
- margin: 15px 0;
73
- opacity: 0;
74
- animation: fadeIn 0.5s forwards;
75
- }
76
-
77
- @keyframes fadeIn {
78
- to { opacity: 1; }
79
- }
80
-
81
- .message-content {
82
- background: white;
83
- padding: 15px;
84
- border-radius: 15px;
85
- margin-left: 15px;
86
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
87
- max-width: 80%;
88
- }
89
-
90
- /* Progress Bar */
91
- .progress-container {
92
- width: 100%;
93
- height: 8px;
94
- background: #f0f0f0;
95
- border-radius: 4px;
96
- overflow: hidden;
97
- margin: 20px 0;
98
- }
99
-
100
- .progress-bar {
101
- height: 100%;
102
- background: linear-gradient(90deg, #4CAF50, #81C784);
103
- transition: width 0.5s ease;
104
  }
105
-
106
- /* Report Sections */
107
- .report-header {
108
- background: #f8f9fa;
109
- padding: 15px;
110
- border-radius: 10px;
111
- margin-bottom: 20px;
112
- border-left: 4px solid #ff4444;
113
- }
114
-
115
- .exec-summary {
116
- background: white;
117
- padding: 25px;
118
- border-radius: 15px;
119
- margin-bottom: 30px;
120
- box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
121
- }
122
-
123
- .key-findings {
124
- display: grid;
125
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
126
- gap: 20px;
127
- margin: 20px 0;
128
- }
129
-
130
- .finding-card {
131
- background: white;
132
- padding: 20px;
133
- border-radius: 10px;
134
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
135
  }
136
-
137
- .detailed-section {
138
- background: white;
139
- padding: 30px;
140
- border-radius: 15px;
141
- margin: 20px 0;
142
- box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
143
  }
144
  </style>
145
  """, unsafe_allow_html=True)
146
 
147
- def display_agent_team(container, active_agent=None):
148
- """Display the team of agents with active state"""
149
- agents = [
150
- {"role": "Research Analyst", "icon": "🔍", "color": "#E3F2FD"},
151
- {"role": "Data Analyst", "icon": "📊", "color": "#F3E5F5"},
152
- {"role": "Report Writer", "icon": "✍️", "color": "#E8F5E9"}
153
- ]
154
-
155
- html = '<div class="agent-team">'
156
- for agent in agents:
157
- active_class = "active" if agent["role"] == active_agent else ""
158
- html += f"""
159
- <div class="agent-card {active_class}" style="background: {agent['color']}">
160
- <div class="agent-avatar">{agent['icon']}</div>
161
- <div class="agent-role">{agent['role']}</div>
162
- <div class="agent-status">
163
- {"Working..." if agent["role"] == active_agent else "Standby"}
164
- </div>
165
- </div>
166
- """
167
- html += '</div>'
168
-
169
  container.markdown(html, unsafe_allow_html=True)
170
 
171
- def display_agent_message(container, agent_type: str, message: str):
172
- """Display an agent message with improved styling"""
173
- icons = {"researcher": "🔍", "analyst": "📊", "writer": "✍️"}
174
- colors = {
175
- "researcher": "#E3F2FD",
176
- "analyst": "#F3E5F5",
177
- "writer": "#E8F5E9"
178
- }
179
-
180
- html = f"""
181
- <div class="chat-message">
182
- <div class="agent-avatar" style="background: {colors.get(agent_type, '#fff')}">
183
- {icons.get(agent_type, "👤")}
184
- </div>
185
- <div class="message-content">
186
- <div>{message}</div>
187
- </div>
188
- </div>
189
- """
190
- container.markdown(html, unsafe_allow_html=True)
191
-
192
- def update_progress(container, progress, message=""):
193
- """Update progress bar with animation"""
194
- progress_html = f"""
195
- <div class="progress-container">
196
- <div class="progress-bar" style="width: {progress}%"></div>
197
- </div>
198
- <div style="text-align: center; color: #666;">
199
- {message}
200
- </div>
201
- """
202
- container.markdown(progress_html, unsafe_allow_html=True)
203
-
204
  def create_research_crew(topic: str):
205
  """Create the research crew with enhanced prompts"""
206
  researcher = Agent(
@@ -292,29 +140,27 @@ def create_research_crew(topic: str):
292
  def run_market_research(topic: str, progress_container, chat_container):
293
  """Run the market research process"""
294
  try:
295
- # Initialize with team display
296
- display_agent_team(progress_container, None)
297
- update_progress(progress_container, 0, "Initializing research team...")
 
 
 
 
 
 
 
298
 
299
- # Research Phase
300
- display_agent_team(progress_container, "Research Analyst")
301
- display_agent_message(chat_container, "researcher",
302
- f"Starting comprehensive research on {topic}...")
303
- update_progress(progress_container, 25, "Gathering market data...")
304
  time.sleep(1)
305
 
306
- # Analysis Phase
307
- display_agent_team(progress_container, "Data Analyst")
308
- display_agent_message(chat_container, "analyst",
309
- "Processing research data and identifying key insights...")
310
- update_progress(progress_container, 50, "Analyzing findings...")
311
  time.sleep(1)
312
 
313
- # Report Phase
314
- display_agent_team(progress_container, "Report Writer")
315
- display_agent_message(chat_container, "writer",
316
- "Compiling final report with executive summary and detailed analysis...")
317
- update_progress(progress_container, 75, "Generating report...")
318
 
319
  # Create and run the crew
320
  crew = create_research_crew(topic)
@@ -335,9 +181,7 @@ def run_market_research(topic: str, progress_container, chat_container):
335
  charts = generate_visualizations(report_data)
336
  report_data['charts'] = charts
337
 
338
- update_progress(progress_container, 100, "Report completed!")
339
- display_agent_message(chat_container, "writer",
340
- "✨ Report generation completed! You can now view the full report.")
341
 
342
  # Store the report data in session state
343
  st.session_state.current_report = report_data
@@ -381,7 +225,6 @@ def main():
381
 
382
  try:
383
  run_market_research(topic, progress_container, chat_container)
384
- st.success("Report generated successfully! View it in the Reports tab.")
385
  except Exception as e:
386
  st.error(f"Error generating report: {str(e)}")
387
  finally:
 
21
  # Add all CSS styles
22
  st.markdown("""
23
  <style>
24
+ /* Progress Tracker Section */
25
+ .progress-step {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  display: flex;
27
  align-items: center;
28
+ margin: 10px 0;
29
+ font-size: 1.1em;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  }
31
+
32
+ .progress-step.active::before {
33
+ content: '🍕';
34
+ margin-right: 10px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
+
37
+ .progress-step.done::before {
38
+ content: '✅';
39
+ margin-right: 10px;
 
 
 
40
  }
41
  </style>
42
  """, unsafe_allow_html=True)
43
 
44
+ def display_progress_tracker(container, steps, current_step_index):
45
+ """Display a progress tracker like a recipe being made."""
46
+ html = ""
47
+ for index, step in enumerate(steps):
48
+ step_class = "done" if index < current_step_index else "active" if index == current_step_index else ""
49
+ html += f"<div class='progress-step {step_class}'>{step}</div>"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  container.markdown(html, unsafe_allow_html=True)
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  def create_research_crew(topic: str):
53
  """Create the research crew with enhanced prompts"""
54
  researcher = Agent(
 
140
  def run_market_research(topic: str, progress_container, chat_container):
141
  """Run the market research process"""
142
  try:
143
+ steps = [
144
+ "Initializing research team...",
145
+ "Gathering market data...",
146
+ "Analyzing findings...",
147
+ "Compiling final report..."
148
+ ]
149
+
150
+ # Step 1: Initialize research team
151
+ display_progress_tracker(progress_container, steps, 0)
152
+ time.sleep(1)
153
 
154
+ # Step 2: Gathering market data
155
+ display_progress_tracker(progress_container, steps, 1)
 
 
 
156
  time.sleep(1)
157
 
158
+ # Step 3: Analyzing findings
159
+ display_progress_tracker(progress_container, steps, 2)
 
 
 
160
  time.sleep(1)
161
 
162
+ # Step 4: Compiling final report
163
+ display_progress_tracker(progress_container, steps, 3)
 
 
 
164
 
165
  # Create and run the crew
166
  crew = create_research_crew(topic)
 
181
  charts = generate_visualizations(report_data)
182
  report_data['charts'] = charts
183
 
184
+ st.success("✨ Report generation completed! You can now view the full report.")
 
 
185
 
186
  # Store the report data in session state
187
  st.session_state.current_report = report_data
 
225
 
226
  try:
227
  run_market_research(topic, progress_container, chat_container)
 
228
  except Exception as e:
229
  st.error(f"Error generating report: {str(e)}")
230
  finally: