DrishtiSharma commited on
Commit
ca52e87
Β·
verified Β·
1 Parent(s): 623e206

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -12
app.py CHANGED
@@ -149,7 +149,7 @@ if st.session_state.df is not None:
149
  llm=llm,
150
  )
151
 
152
- # Tasks for each agent
153
  extract_data = Task(
154
  description="Extract data based on the query: {query}.",
155
  expected_output="Database results matching the query.",
@@ -170,6 +170,7 @@ if st.session_state.df is not None:
170
  context=[analyze_data],
171
  )
172
 
 
173
  write_conclusion = Task(
174
  description=(
175
  "Summarize the findings into a concise Conclusion. Include the max, min, and average salary in USD, "
@@ -180,10 +181,17 @@ if st.session_state.df is not None:
180
  context=[analyze_data],
181
  )
182
 
183
- # Crew setup
184
- crew = Crew(
185
- agents=[sql_dev, data_analyst, report_writer, conclusion_writer],
186
- tasks=[extract_data, analyze_data, write_report, write_conclusion],
 
 
 
 
 
 
 
187
  process=Process.sequential,
188
  verbose=True,
189
  )
@@ -197,16 +205,16 @@ if st.session_state.df is not None:
197
  if st.button("Submit Query"):
198
  with st.spinner("Processing query..."):
199
  # Step 1: Generate the main report (without Conclusion)
200
- report_inputs = {"query": query + " Provide a detailed analysis but DO NOT include a Conclusion."}
201
- report_result = crew.kickoff(inputs=report_inputs)
202
 
203
  # Step 2: Generate only the Conclusion
204
- conclusion_inputs = {"query": query + " Now, provide only the Conclusion for this analysis."}
205
- conclusion_result = crew.kickoff(inputs=conclusion_inputs)
206
 
207
- # Handle Crew Output safely
208
- main_report = getattr(report_result, 'output', "⚠️ No Report Generated.")
209
- conclusion = getattr(conclusion_result, 'output', "⚠️ No Conclusion Generated.")
210
 
211
  st.markdown("### Analysis Report:")
212
  st.markdown(main_report)
@@ -260,6 +268,7 @@ if st.session_state.df is not None:
260
  else:
261
  st.info("Please load a dataset to proceed.")
262
 
 
263
  # Sidebar Reference
264
  with st.sidebar:
265
  st.header("πŸ“š Reference:")
 
149
  llm=llm,
150
  )
151
 
152
+ # Tasks for Report
153
  extract_data = Task(
154
  description="Extract data based on the query: {query}.",
155
  expected_output="Database results matching the query.",
 
170
  context=[analyze_data],
171
  )
172
 
173
+ # Task for Conclusion
174
  write_conclusion = Task(
175
  description=(
176
  "Summarize the findings into a concise Conclusion. Include the max, min, and average salary in USD, "
 
181
  context=[analyze_data],
182
  )
183
 
184
+ # Separate Crews for Report and Conclusion
185
+ crew_report = Crew(
186
+ agents=[sql_dev, data_analyst, report_writer],
187
+ tasks=[extract_data, analyze_data, write_report],
188
+ process=Process.sequential,
189
+ verbose=True,
190
+ )
191
+
192
+ crew_conclusion = Crew(
193
+ agents=[data_analyst, conclusion_writer],
194
+ tasks=[write_conclusion],
195
  process=Process.sequential,
196
  verbose=True,
197
  )
 
205
  if st.button("Submit Query"):
206
  with st.spinner("Processing query..."):
207
  # Step 1: Generate the main report (without Conclusion)
208
+ report_inputs = {"query": query}
209
+ report_result = crew_report.kickoff(inputs=report_inputs)
210
 
211
  # Step 2: Generate only the Conclusion
212
+ conclusion_inputs = {"query": query}
213
+ conclusion_result = crew_conclusion.kickoff(inputs=conclusion_inputs)
214
 
215
+ # Extract results safely
216
+ main_report = report_result[0].output if report_result and hasattr(report_result[0], 'output') else "⚠️ No Report Generated."
217
+ conclusion = conclusion_result[0].output if conclusion_result and hasattr(conclusion_result[0], 'output') else "⚠️ No Conclusion Generated."
218
 
219
  st.markdown("### Analysis Report:")
220
  st.markdown(main_report)
 
268
  else:
269
  st.info("Please load a dataset to proceed.")
270
 
271
+
272
  # Sidebar Reference
273
  with st.sidebar:
274
  st.header("πŸ“š Reference:")