Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -103,6 +103,7 @@ def 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,36 +112,56 @@ def main():
|
|
| 111 |
# Display AI Disclaimer
|
| 112 |
st.info("⚠️ This report was generated using AI. Please verify critical information independently.")
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
st.
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
|
|
|
| 144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
if __name__ == "__main__":
|
| 146 |
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 |
# Display AI Disclaimer
|
| 113 |
st.info("⚠️ This report was generated using AI. Please verify critical information independently.")
|
| 114 |
|
| 115 |
+
try:
|
| 116 |
+
# Executive Summary Section with error handling
|
| 117 |
+
st.subheader("Executive Summary")
|
| 118 |
+
if report.get('exec_summary', {}).get('summary'):
|
| 119 |
+
st.write(report['exec_summary']['summary'])
|
| 120 |
+
else:
|
| 121 |
+
st.write("Executive summary not available")
|
| 122 |
+
|
| 123 |
+
# Key Metrics with error handling
|
| 124 |
+
col1, col2, col3 = st.columns(3)
|
| 125 |
+
with col1:
|
| 126 |
+
market_size = report.get('exec_summary', {}).get('market_size', 'N/A')
|
| 127 |
+
st.metric("Market Size", market_size)
|
| 128 |
+
with col2:
|
| 129 |
+
growth_rate = report.get('exec_summary', {}).get('growth_rate', 'N/A')
|
| 130 |
+
st.metric("Growth Rate", growth_rate)
|
| 131 |
+
with col3:
|
| 132 |
+
key_players = report.get('exec_summary', {}).get('key_players', 'N/A')
|
| 133 |
+
st.metric("Key Players", key_players)
|
| 134 |
+
|
| 135 |
+
# Detailed Report Section
|
| 136 |
+
st.subheader("Detailed Analysis")
|
| 137 |
+
detailed_report = report.get('detailed_report', 'Detailed analysis not available')
|
| 138 |
+
st.write(detailed_report)
|
| 139 |
+
|
| 140 |
+
# Sources Section
|
| 141 |
+
sources = report.get('sources', [])
|
| 142 |
+
if sources:
|
| 143 |
+
st.subheader("Sources")
|
| 144 |
+
for source in sources:
|
| 145 |
+
st.markdown(f"- {source}")
|
| 146 |
|
| 147 |
+
# Download button
|
| 148 |
+
report_text = (
|
| 149 |
+
f"# Market Research Report: {topic}\n\n"
|
| 150 |
+
f"## Executive Summary\n{report['exec_summary']['summary']}\n\n"
|
| 151 |
+
f"### Key Metrics\n"
|
| 152 |
+
f"- Market Size: {report['exec_summary']['market_size']}\n"
|
| 153 |
+
f"- Growth Rate: {report['exec_summary']['growth_rate']}\n"
|
| 154 |
+
f"- Key Players: {report['exec_summary']['key_players']}\n\n"
|
| 155 |
+
f"## Detailed Analysis\n{report['detailed_report']}\n\n"
|
| 156 |
+
f"## Sources\n" + "\n".join([f"- {source}" for source in report['sources']])
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
st.download_button(
|
| 160 |
+
"Download Report",
|
| 161 |
+
data=report_text,
|
| 162 |
+
file_name=f"{topic.lower().replace(' ', '_')}_market_research.md",
|
| 163 |
+
mime="text/markdown"
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
if __name__ == "__main__":
|
| 167 |
main()
|