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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -30
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
- # Executive Summary
115
- st.subheader("Executive Summary")
116
- st.write(report['exec_summary']['summary'])
117
-
118
- # Key Metrics
119
- col1, col2, col3 = st.columns(3)
120
- with col1:
121
- st.metric("Market Size", report['exec_summary']['market_size'])
122
- with col2:
123
- st.metric("Growth Rate", report['exec_summary']['growth_rate'])
124
- with col3:
125
- st.metric("Key Players", report['exec_summary']['key_players'])
126
-
127
- # Detailed Report
128
- st.subheader("Detailed Analysis")
129
- st.write(report['detailed_report'])
130
-
131
- # Sources
132
- if report['sources']:
133
- st.subheader("Sources")
134
- for source in report['sources']:
135
- st.markdown(f"- {source}")
136
-
137
- # Download button
138
- st.download_button(
139
- "Download Report",
140
- data=str(report['detailed_report']),
141
- file_name=f"{topic.lower().replace(' ', '_')}_market_research.md",
142
- mime="text/markdown"
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()