cryogenic22 commited on
Commit
11bfcdf
·
verified ·
1 Parent(s): c144ee0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -58
app.py CHANGED
@@ -112,68 +112,53 @@ def main():
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', {})
150
- report_text = f"""# Market Research Report: {topic}
151
-
152
- ## Executive Summary
153
- {exec_summary.get('summary', 'No summary available')}
154
-
155
- ### Key Metrics
156
- - Market Size: {exec_summary.get('market_size', 'Not available')}
157
- - Growth Rate: {exec_summary.get('growth_rate', 'Not available')}
158
- - Key Players: {exec_summary.get('key_players', 'Not available')}
159
-
160
- ## Detailed Analysis
161
  {report.get('detailed_report', 'No detailed analysis available')}
162
 
163
- ## Sources
164
- {chr(10).join([f"- {source}" for source in report.get('sources', ['No sources available'])])}
165
  """
166
-
167
- st.download_button(
168
- label="Download Report",
169
- data=report_text,
170
- file_name=f"{topic.lower().replace(' ', '_')}_market_research.md",
171
- mime="text/markdown"
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()
 
112
  st.info("⚠️ This report was generated using AI. Please verify critical information independently.")
113
 
114
  try:
115
+ # Executive Summary
116
+ st.header("Executive Summary")
117
+ st.write(report.get('exec_summary', {}).get('summary', 'No summary available'))
118
+
119
+ # Market Overview
120
+ st.header("Market Overview")
121
+ st.write(f"Market Size: {report.get('exec_summary', {}).get('market_size', 'Not available')}")
122
+ st.write(f"Growth Rate: {report.get('exec_summary', {}).get('growth_rate', 'Not available')}")
123
+ st.write(f"Key Players: {report.get('exec_summary', {}).get('key_players', 'Not available')}")
124
+
125
+ # Detailed Analysis
126
+ st.header("Detailed Analysis")
127
+ st.write(report.get('detailed_report', 'No detailed analysis available'))
128
+
129
+ # Sources
130
+ st.header("Sources")
131
+ sources = report.get('sources', ['No sources available'])
132
+ for source in sources:
133
+ st.write(f"• {source}")
134
+
135
+ # Simple download button for the report
136
+ report_text = f"""
137
+ Market Research Report: {topic}
138
+
139
+ Executive Summary:
140
+ {report.get('exec_summary', {}).get('summary', 'No summary available')}
141
+
142
+ Market Overview:
143
+ Market Size: {report.get('exec_summary', {}).get('market_size', 'Not available')}
144
+ • Growth Rate: {report.get('exec_summary', {}).get('growth_rate', 'Not available')}
145
+ • Key Players: {report.get('exec_summary', {}).get('key_players', 'Not available')}
146
+
147
+ Detailed Analysis:
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  {report.get('detailed_report', 'No detailed analysis available')}
149
 
150
+ Sources:
151
+ {chr(10).join([f" {source}" for source in sources])}
152
  """
153
+
154
+ st.download_button(
155
+ "Download Report",
156
+ data=report_text,
157
+ file_name=f"{topic}_market_research.txt",
158
+ mime="text/plain"
159
+ )
160
+
 
161
  except Exception as e:
162
  st.error(f"Error displaying report: {str(e)}")
 
163
  if __name__ == "__main__":
164
  main()