cryogenic22 commited on
Commit
982e3fa
·
verified ·
1 Parent(s): a8f1228

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -41
app.py CHANGED
@@ -21,34 +21,34 @@ st.set_page_config(
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
-
43
  """, unsafe_allow_html=True)
44
 
45
- def display_progress_tracker(container, steps, current_step_index):
46
- """Display a progress tracker like a recipe being made."""
47
- html = ""
48
- for index, step in enumerate(steps):
49
- step_class = "done" if index < current_step_index else "active" if index == current_step_index else ""
50
- html += f"<div class='progress-step {step_class}'>{step}</div>"
51
- container.markdown(html, unsafe_allow_html=True)
 
52
 
53
  def create_research_crew(topic: str):
54
  """Create the research crew with enhanced prompts"""
@@ -141,47 +141,33 @@ def create_research_crew(topic: str):
141
  def run_market_research(topic: str, progress_container, chat_container):
142
  """Run the market research process"""
143
  try:
144
- steps = [
145
- "Initializing research team...",
146
- "Gathering market data...",
147
- "Analyzing findings...",
148
- "Compiling final report..."
149
- ]
150
-
151
  # Step 1: Initialize research team
152
- display_progress_tracker(progress_container, steps, 0)
153
  time.sleep(1)
154
 
155
  # Step 2: Gathering market data
156
- display_progress_tracker(progress_container, steps, 1)
157
  time.sleep(1)
158
 
159
  # Step 3: Analyzing findings
160
- display_progress_tracker(progress_container, steps, 2)
161
  time.sleep(1)
162
 
163
  # Step 4: Compiling final report
164
- display_progress_tracker(progress_container, steps, 3)
165
 
166
  # Create and run the crew
167
  crew = create_research_crew(topic)
168
  result = crew.kickoff()
169
 
170
- # Debugging: Display raw output to verify data
171
- st.write("Debug: Raw output from CrewAI agents:")
172
- st.write(result)
173
-
174
  # Format and process the result
175
  report_data = format_json_output(result)
176
 
177
- # Debugging: Display formatted JSON output
178
- st.write("Debug: Formatted JSON output:")
179
- st.write(report_data)
180
-
181
  # Add visualizations
182
  charts = generate_visualizations(report_data)
183
  report_data['charts'] = charts
184
 
 
185
  st.success("✨ Report generation completed! You can now view the full report.")
186
 
187
  # Store the report data in session state
 
21
  # Add all CSS styles
22
  st.markdown("""
23
  <style>
24
+ /* Progress Bar */
25
+ .progress-container {
26
+ width: 100%;
27
+ background: #f0f0f0;
28
+ border-radius: 8px;
29
+ margin: 20px 0;
30
  }
31
 
32
+ .progress-bar {
33
+ height: 24px;
34
+ background: linear-gradient(90deg, #4caf50, #81c784);
35
+ border-radius: 8px;
36
+ text-align: center;
37
+ line-height: 24px;
38
+ color: white;
39
+ transition: width 0.5s ease;
40
  }
41
  </style>
 
42
  """, unsafe_allow_html=True)
43
 
44
+ def update_progress(progress_container, percentage, message=""):
45
+ """Update the progress bar."""
46
+ progress_html = f"""
47
+ <div class="progress-container">
48
+ <div class="progress-bar" style="width: {percentage}%">{message}</div>
49
+ </div>
50
+ """
51
+ progress_container.markdown(progress_html, unsafe_allow_html=True)
52
 
53
  def create_research_crew(topic: str):
54
  """Create the research crew with enhanced prompts"""
 
141
  def run_market_research(topic: str, progress_container, chat_container):
142
  """Run the market research process"""
143
  try:
 
 
 
 
 
 
 
144
  # Step 1: Initialize research team
145
+ update_progress(progress_container, 0, "Initializing research team...")
146
  time.sleep(1)
147
 
148
  # Step 2: Gathering market data
149
+ update_progress(progress_container, 25, "Gathering market data...")
150
  time.sleep(1)
151
 
152
  # Step 3: Analyzing findings
153
+ update_progress(progress_container, 50, "Analyzing findings...")
154
  time.sleep(1)
155
 
156
  # Step 4: Compiling final report
157
+ update_progress(progress_container, 75, "Compiling final report...")
158
 
159
  # Create and run the crew
160
  crew = create_research_crew(topic)
161
  result = crew.kickoff()
162
 
 
 
 
 
163
  # Format and process the result
164
  report_data = format_json_output(result)
165
 
 
 
 
 
166
  # Add visualizations
167
  charts = generate_visualizations(report_data)
168
  report_data['charts'] = charts
169
 
170
+ update_progress(progress_container, 100, "Report completed!")
171
  st.success("✨ Report generation completed! You can now view the full report.")
172
 
173
  # Store the report data in session state