DrishtiSharma commited on
Commit
c575495
Β·
verified Β·
1 Parent(s): 3a46f4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -24
app.py CHANGED
@@ -172,17 +172,10 @@ if st.session_state.df is not None:
172
  context=[analyze_data],
173
  )
174
 
175
- # Crew with separate tasks for report and conclusion
176
- crew_report = Crew(
177
- agents=[sql_dev, data_analyst, report_writer],
178
- tasks=[extract_data, analyze_data, write_report],
179
- process=Process.sequential,
180
- verbose=True,
181
- )
182
-
183
- crew_conclusion = Crew(
184
- agents=[data_analyst, conclusion_writer],
185
- tasks=[write_conclusion],
186
  process=Process.sequential,
187
  verbose=True,
188
  )
@@ -195,15 +188,15 @@ if st.session_state.df is not None:
195
  query = st.text_area("Enter Query:", value="Provide insights into the salary of a Principal Data Scientist.")
196
  if st.button("Submit Query"):
197
  with st.spinner("Processing query..."):
198
- # Step 1: Generate the main report (without Conclusion)
199
- report_inputs = {"query": query}
200
- report_result = crew_report.kickoff(inputs=report_inputs)
201
 
202
- # Step 2: Generate ONLY the Conclusion
203
- conclusion_inputs = {"query": query}
204
- conclusion_result = crew_conclusion.kickoff(inputs=conclusion_inputs)
205
 
206
  st.markdown("### Analysis Report:")
 
207
 
208
  # Step 3: Generate relevant visualizations
209
  visualizations = []
@@ -223,17 +216,14 @@ if st.session_state.df is not None:
223
  title="Salary Distribution by Employment Type")
224
  visualizations.append(fig_employment)
225
 
226
- # Step 4: Display the main report
227
- st.markdown(report_result)
228
-
229
- # Step 5: Insert Visual Insights
230
  st.markdown("## πŸ“Š Visual Insights")
231
  for fig in visualizations:
232
  st.plotly_chart(fig, use_container_width=True)
233
 
234
- # Step 6: Append the Conclusion
235
  st.markdown("## Conclusion")
236
- st.markdown(conclusion_result)
237
 
238
  # Tab 2: Full Data Visualization
239
  with tab2:
@@ -257,7 +247,6 @@ if st.session_state.df is not None:
257
  else:
258
  st.info("Please load a dataset to proceed.")
259
 
260
-
261
  # Sidebar Reference
262
  with st.sidebar:
263
  st.header("πŸ“š Reference:")
 
172
  context=[analyze_data],
173
  )
174
 
175
+ # βœ… Optimized Single Crew for Report and Conclusion
176
+ crew = Crew(
177
+ agents=[sql_dev, data_analyst, report_writer, conclusion_writer],
178
+ tasks=[extract_data, analyze_data, write_report, write_conclusion],
 
 
 
 
 
 
 
179
  process=Process.sequential,
180
  verbose=True,
181
  )
 
188
  query = st.text_area("Enter Query:", value="Provide insights into the salary of a Principal Data Scientist.")
189
  if st.button("Submit Query"):
190
  with st.spinner("Processing query..."):
191
+ inputs = {"query": query}
192
+ result = crew.kickoff(inputs=inputs)
 
193
 
194
+ # Assuming result is structured as a dictionary:
195
+ main_report = result.get('write_report', '')
196
+ conclusion = result.get('write_conclusion', '')
197
 
198
  st.markdown("### Analysis Report:")
199
+ st.markdown(main_report)
200
 
201
  # Step 3: Generate relevant visualizations
202
  visualizations = []
 
216
  title="Salary Distribution by Employment Type")
217
  visualizations.append(fig_employment)
218
 
219
+ # Step 4: Insert Visual Insights
 
 
 
220
  st.markdown("## πŸ“Š Visual Insights")
221
  for fig in visualizations:
222
  st.plotly_chart(fig, use_container_width=True)
223
 
224
+ # Step 5: Append the Conclusion
225
  st.markdown("## Conclusion")
226
+ st.markdown(conclusion)
227
 
228
  # Tab 2: Full Data Visualization
229
  with tab2:
 
247
  else:
248
  st.info("Please load a dataset to proceed.")
249
 
 
250
  # Sidebar Reference
251
  with st.sidebar:
252
  st.header("πŸ“š Reference:")