DrishtiSharma commited on
Commit
d6c1fc7
Β·
verified Β·
1 Parent(s): 1950034

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -36
app.py CHANGED
@@ -164,52 +164,42 @@ if st.button("Generate Insights"):
164
  results = crew.kickoff(inputs={"topic": business, "stakeholder": stakeholder})
165
  elapsed_time = time.time() - start_time
166
 
167
- # Parse and Display Results
168
- st.markdown("### Insights and Analysis")
169
-
170
- # Handle Raw Output
171
- raw_output = getattr(results, "raw", None)
172
- if raw_output:
173
- st.markdown("#### Executive Summary")
174
- st.write(raw_output)
175
  else:
176
- st.warning("No executive summary available.")
177
-
178
- # Handle Task Outputs
179
- tasks_output = getattr(results, "tasks_output", [])
180
- if tasks_output:
181
- st.markdown("#### Task Outputs")
182
- for idx, task in enumerate(tasks_output):
183
- task_description = getattr(task,"description", "No description available.")
184
- task_raw = getattr(task, "raw", "No details available.")
185
- st.subheader(f"Task {idx + 1}")
186
- st.write(f"**Description:** {task_description}")
187
- st.write(task_raw)
188
- else:
189
- st.warning("No task outputs available.")
190
 
191
- # Display Token Usage
 
 
 
 
 
 
 
192
  token_usage = getattr(results, "token_usage", None)
193
  if token_usage:
194
  st.markdown("#### Token Usage")
195
  st.json(token_usage)
196
- else:
197
- st.warning("No token usage information available.")
198
-
199
- # Display Execution Time
200
- st.success(f"Analysis completed in {elapsed_time:.2f} seconds.")
201
 
202
  # Generate PDF Report
203
- if raw_output:
204
- report_path = generate_pdf_report(raw_output)
205
  with open(report_path, "rb") as report_file:
206
  st.download_button("Download Report", data=report_file, file_name="Business_Report.pdf")
207
 
208
  except Exception as e:
209
  st.error(f"An error occurred during execution: {e}")
210
-
211
-
212
- # Add reference and credits in the sidebar
213
- st.sidebar.markdown("---")
214
- st.sidebar.markdown("### Reference:")
215
- st.sidebar.markdown("[Multi-Agent Business Consultant - Hanan Tabak](https://medium.com/@hanan.tabak/user-friendly-open-source-multi-agent-ai-business-consultant-on-crewai-and-streamlit-0f972feb1b74)")
 
164
  results = crew.kickoff(inputs={"topic": business, "stakeholder": stakeholder})
165
  elapsed_time = time.time() - start_time
166
 
167
+ # Display Final Report (Writer's Output)
168
+ st.markdown("### Final Report: Executive Summary")
169
+ writer_output = getattr(results.tasks_output[2], "raw", "No details available.")
170
+ if writer_output:
171
+ st.write(writer_output)
 
 
 
172
  else:
173
+ st.warning("No final report available.")
174
+
175
+ # Option for Detailed Insights
176
+ with st.expander("Explore Detailed Insights"):
177
+ tab1, tab2 = st.tabs(["Planner's Insights", "Analyst's Analysis"])
178
+
179
+ # Planner's Output
180
+ with tab1:
181
+ st.markdown("### Planner's Insights")
182
+ planner_output = getattr(results.tasks_output[0], "raw", "No details available.")
183
+ st.write(planner_output)
 
 
 
184
 
185
+ # Analyst's Output
186
+ with tab2:
187
+ st.markdown("### Analyst's Analysis")
188
+ analyst_output = getattr(results.tasks_output[1], "raw", "No details available.")
189
+ st.write(analyst_output)
190
+
191
+ # Display Token Usage and Execution Time
192
+ st.success(f"Analysis completed in {elapsed_time:.2f} seconds.")
193
  token_usage = getattr(results, "token_usage", None)
194
  if token_usage:
195
  st.markdown("#### Token Usage")
196
  st.json(token_usage)
 
 
 
 
 
197
 
198
  # Generate PDF Report
199
+ if writer_output:
200
+ report_path = generate_pdf_report(writer_output)
201
  with open(report_path, "rb") as report_file:
202
  st.download_button("Download Report", data=report_file, file_name="Business_Report.pdf")
203
 
204
  except Exception as e:
205
  st.error(f"An error occurred during execution: {e}")