Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -103,7 +103,6 @@ def main():
|
|
| 103 |
finally:
|
| 104 |
st.session_state.generating = False
|
| 105 |
|
| 106 |
-
# Inside the tab2 section of main()
|
| 107 |
with tab2:
|
| 108 |
if 'current_report' in st.session_state:
|
| 109 |
report = st.session_state.current_report
|
|
@@ -112,7 +111,39 @@ def main():
|
|
| 112 |
# Display AI Disclaimer
|
| 113 |
st.info("⚠️ This report was generated using AI. Please verify critical information independently.")
|
| 114 |
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
try:
|
| 117 |
# Safely get report sections with defaults
|
| 118 |
exec_summary = report.get('exec_summary', {})
|
|
@@ -141,6 +172,8 @@ def main():
|
|
| 141 |
)
|
| 142 |
except Exception as e:
|
| 143 |
st.error(f"Error preparing download: {str(e)}")
|
|
|
|
|
|
|
| 144 |
|
| 145 |
if __name__ == "__main__":
|
| 146 |
main()
|
|
|
|
| 103 |
finally:
|
| 104 |
st.session_state.generating = False
|
| 105 |
|
|
|
|
| 106 |
with tab2:
|
| 107 |
if 'current_report' in st.session_state:
|
| 108 |
report = st.session_state.current_report
|
|
|
|
| 111 |
# Display AI Disclaimer
|
| 112 |
st.info("⚠️ This report was generated using AI. Please verify critical information independently.")
|
| 113 |
|
| 114 |
+
try:
|
| 115 |
+
# Executive Summary Section with error handling
|
| 116 |
+
st.subheader("Executive Summary")
|
| 117 |
+
if report.get('exec_summary', {}).get('summary'):
|
| 118 |
+
st.write(report['exec_summary']['summary'])
|
| 119 |
+
else:
|
| 120 |
+
st.write("Executive summary not available")
|
| 121 |
+
|
| 122 |
+
# Key Metrics with error handling
|
| 123 |
+
col1, col2, col3 = st.columns(3)
|
| 124 |
+
with col1:
|
| 125 |
+
market_size = report.get('exec_summary', {}).get('market_size', 'N/A')
|
| 126 |
+
st.metric("Market Size", market_size)
|
| 127 |
+
with col2:
|
| 128 |
+
growth_rate = report.get('exec_summary', {}).get('growth_rate', 'N/A')
|
| 129 |
+
st.metric("Growth Rate", growth_rate)
|
| 130 |
+
with col3:
|
| 131 |
+
key_players = report.get('exec_summary', {}).get('key_players', 'N/A')
|
| 132 |
+
st.metric("Key Players", key_players)
|
| 133 |
+
|
| 134 |
+
# Detailed Report Section
|
| 135 |
+
st.subheader("Detailed Analysis")
|
| 136 |
+
detailed_report = report.get('detailed_report', 'Detailed analysis not available')
|
| 137 |
+
st.write(detailed_report)
|
| 138 |
+
|
| 139 |
+
# Sources Section
|
| 140 |
+
sources = report.get('sources', [])
|
| 141 |
+
if sources:
|
| 142 |
+
st.subheader("Sources")
|
| 143 |
+
for source in sources:
|
| 144 |
+
st.markdown(f"- {source}")
|
| 145 |
+
|
| 146 |
+
# Download button
|
| 147 |
try:
|
| 148 |
# Safely get report sections with defaults
|
| 149 |
exec_summary = report.get('exec_summary', {})
|
|
|
|
| 172 |
)
|
| 173 |
except Exception as e:
|
| 174 |
st.error(f"Error preparing download: {str(e)}")
|
| 175 |
+
except Exception as e:
|
| 176 |
+
st.error(f"Error displaying report: {str(e)}")
|
| 177 |
|
| 178 |
if __name__ == "__main__":
|
| 179 |
main()
|