cryogenic22 commited on
Commit
10e4537
·
verified ·
1 Parent(s): 1f95884

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -47
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
- 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()
 
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()