Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,56 +112,35 @@ def main():
|
|
| 112 |
# Display AI Disclaimer
|
| 113 |
st.info("⚠️ This report was generated using AI. Please verify critical information independently.")
|
| 114 |
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
| 122 |
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 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 |
-
|
| 136 |
-
|
| 137 |
-
detailed_report = report.get('detailed_report', 'Detailed analysis not available')
|
| 138 |
-
st.write(detailed_report)
|
| 139 |
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|
|
|
|
| 112 |
# Display AI Disclaimer
|
| 113 |
st.info("⚠️ This report was generated using AI. Please verify critical information independently.")
|
| 114 |
|
| 115 |
+
# Download button with error handling
|
| 116 |
+
try:
|
| 117 |
+
# Safely get report sections with defaults
|
| 118 |
+
exec_summary = report.get('exec_summary', {})
|
| 119 |
+
report_text = f"""# Market Research Report: {topic}
|
| 120 |
+
|
| 121 |
+
## Executive Summary
|
| 122 |
+
{exec_summary.get('summary', 'No summary available')}
|
| 123 |
|
| 124 |
+
### Key Metrics
|
| 125 |
+
- Market Size: {exec_summary.get('market_size', 'Not available')}
|
| 126 |
+
- Growth Rate: {exec_summary.get('growth_rate', 'Not available')}
|
| 127 |
+
- Key Players: {exec_summary.get('key_players', 'Not available')}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
+
## Detailed Analysis
|
| 130 |
+
{report.get('detailed_report', 'No detailed analysis available')}
|
|
|
|
|
|
|
| 131 |
|
| 132 |
+
## Sources
|
| 133 |
+
{chr(10).join([f"- {source}" for source in report.get('sources', ['No sources available'])])}
|
| 134 |
+
"""
|
| 135 |
+
|
| 136 |
+
st.download_button(
|
| 137 |
+
label="Download Report",
|
| 138 |
+
data=report_text,
|
| 139 |
+
file_name=f"{topic.lower().replace(' ', '_')}_market_research.md",
|
| 140 |
+
mime="text/markdown"
|
| 141 |
+
)
|
| 142 |
+
except Exception as e:
|
| 143 |
+
st.error(f"Error preparing download: {str(e)}")
|
| 144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
if __name__ == "__main__":
|
| 146 |
main()
|