DrishtiSharma
commited on
Update app.py
Browse files
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 |
-
#
|
168 |
-
st.markdown("###
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
if raw_output:
|
173 |
-
st.markdown("#### Executive Summary")
|
174 |
-
st.write(raw_output)
|
175 |
else:
|
176 |
-
st.warning("No
|
177 |
-
|
178 |
-
#
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
st.write(
|
187 |
-
st.write(task_raw)
|
188 |
-
else:
|
189 |
-
st.warning("No task outputs available.")
|
190 |
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
204 |
-
report_path = generate_pdf_report(
|
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}")
|
|
|
|
|
|
|
|
|
|
|
|