Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -138,23 +138,27 @@ def create_research_crew(topic: str):
|
|
| 138 |
process=Process.sequential
|
| 139 |
)
|
| 140 |
|
| 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)
|
|
@@ -173,6 +177,7 @@ def run_market_research(topic: str, progress_container, chat_container):
|
|
| 173 |
|
| 174 |
update_progress(progress_container, 100, "Report completed!")
|
| 175 |
st.success("✨ Report generation completed! You can now view the full report.")
|
|
|
|
| 176 |
|
| 177 |
# Store the report data in session state
|
| 178 |
st.session_state.current_report = report_data
|
|
@@ -180,6 +185,7 @@ def run_market_research(topic: str, progress_container, chat_container):
|
|
| 180 |
|
| 181 |
except Exception as e:
|
| 182 |
st.error(f"Error during research: {str(e)}")
|
|
|
|
| 183 |
|
| 184 |
def main():
|
| 185 |
st.title("🤖 AI Market Research Generator")
|
|
@@ -188,7 +194,7 @@ def main():
|
|
| 188 |
if 'generating' not in st.session_state:
|
| 189 |
st.session_state.generating = False
|
| 190 |
|
| 191 |
-
tab1, tab2 = st.tabs(["Generate Report", "View Reports"])
|
| 192 |
|
| 193 |
with tab1:
|
| 194 |
col1, col2 = st.columns([2, 3])
|
|
@@ -210,12 +216,13 @@ def main():
|
|
| 210 |
else:
|
| 211 |
st.session_state.generating = True
|
| 212 |
|
| 213 |
-
# Create containers for progress and
|
| 214 |
progress_container = st.container()
|
| 215 |
chat_container = st.container()
|
|
|
|
| 216 |
|
| 217 |
try:
|
| 218 |
-
run_market_research(topic, progress_container, chat_container)
|
| 219 |
except Exception as e:
|
| 220 |
st.error(f"Error generating report: {str(e)}")
|
| 221 |
finally:
|
|
@@ -278,6 +285,11 @@ def main():
|
|
| 278 |
st.subheader("Sources")
|
| 279 |
for source in report['sources']:
|
| 280 |
st.markdown(f"- {source}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
def format_json_output(raw_output):
|
| 283 |
"""Format CrewOutput or raw string into proper JSON structure"""
|
|
|
|
| 138 |
process=Process.sequential
|
| 139 |
)
|
| 140 |
|
| 141 |
+
def run_market_research(topic: str, progress_container, chat_container, log_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 |
+
log_container.write("Initializing research team...")
|
| 147 |
time.sleep(1)
|
| 148 |
|
| 149 |
# Step 2: Gathering market data
|
| 150 |
update_progress(progress_container, 25, "Gathering market data...")
|
| 151 |
+
log_container.write("Research Analyst is gathering market data...")
|
| 152 |
time.sleep(1)
|
| 153 |
|
| 154 |
# Step 3: Analyzing findings
|
| 155 |
update_progress(progress_container, 50, "Analyzing findings...")
|
| 156 |
+
log_container.write("Data Analyst is analyzing findings...")
|
| 157 |
time.sleep(1)
|
| 158 |
|
| 159 |
# Step 4: Compiling final report
|
| 160 |
update_progress(progress_container, 75, "Compiling final report...")
|
| 161 |
+
log_container.write("Report Writer is compiling the final report...")
|
| 162 |
|
| 163 |
# Create and run the crew
|
| 164 |
crew = create_research_crew(topic)
|
|
|
|
| 177 |
|
| 178 |
update_progress(progress_container, 100, "Report completed!")
|
| 179 |
st.success("✨ Report generation completed! You can now view the full report.")
|
| 180 |
+
log_container.write("Report generation completed!")
|
| 181 |
|
| 182 |
# Store the report data in session state
|
| 183 |
st.session_state.current_report = report_data
|
|
|
|
| 185 |
|
| 186 |
except Exception as e:
|
| 187 |
st.error(f"Error during research: {str(e)}")
|
| 188 |
+
log_container.write(f"Error during research: {str(e)}")
|
| 189 |
|
| 190 |
def main():
|
| 191 |
st.title("🤖 AI Market Research Generator")
|
|
|
|
| 194 |
if 'generating' not in st.session_state:
|
| 195 |
st.session_state.generating = False
|
| 196 |
|
| 197 |
+
tab1, tab2, tab3 = st.tabs(["Generate Report", "View Reports", "Live Agent Log"])
|
| 198 |
|
| 199 |
with tab1:
|
| 200 |
col1, col2 = st.columns([2, 3])
|
|
|
|
| 216 |
else:
|
| 217 |
st.session_state.generating = True
|
| 218 |
|
| 219 |
+
# Create containers for progress, chat, and log
|
| 220 |
progress_container = st.container()
|
| 221 |
chat_container = st.container()
|
| 222 |
+
log_container = st.container()
|
| 223 |
|
| 224 |
try:
|
| 225 |
+
run_market_research(topic, progress_container, chat_container, log_container)
|
| 226 |
except Exception as e:
|
| 227 |
st.error(f"Error generating report: {str(e)}")
|
| 228 |
finally:
|
|
|
|
| 285 |
st.subheader("Sources")
|
| 286 |
for source in report['sources']:
|
| 287 |
st.markdown(f"- {source}")
|
| 288 |
+
|
| 289 |
+
with tab3:
|
| 290 |
+
st.subheader("Live Agent Log")
|
| 291 |
+
if 'log_container' in st.session_state:
|
| 292 |
+
st.session_state['log_container'].write("Live log will appear here...")
|
| 293 |
|
| 294 |
def format_json_output(raw_output):
|
| 295 |
"""Format CrewOutput or raw string into proper JSON structure"""
|