Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,34 +21,34 @@ st.set_page_config(
|
|
| 21 |
# Add all CSS styles
|
| 22 |
st.markdown("""
|
| 23 |
<style>
|
| 24 |
-
/* Progress
|
| 25 |
-
.progress-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
}
|
| 31 |
|
| 32 |
-
.progress-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
}
|
| 41 |
</style>
|
| 42 |
-
|
| 43 |
""", unsafe_allow_html=True)
|
| 44 |
|
| 45 |
-
def
|
| 46 |
-
"""
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
| 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 |
-
|
| 153 |
time.sleep(1)
|
| 154 |
|
| 155 |
# Step 2: Gathering market data
|
| 156 |
-
|
| 157 |
time.sleep(1)
|
| 158 |
|
| 159 |
# Step 3: Analyzing findings
|
| 160 |
-
|
| 161 |
time.sleep(1)
|
| 162 |
|
| 163 |
# Step 4: Compiling final report
|
| 164 |
-
|
| 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
|