cryogenic22 commited on
Commit
94c647e
·
verified ·
1 Parent(s): bc2f51c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +116 -70
app.py CHANGED
@@ -17,11 +17,24 @@ st.set_page_config(
17
  initial_sidebar_state="expanded"
18
  )
19
 
20
- # Add custom CSS for animations and styling
21
  st.markdown("""
22
  <style>
 
 
 
 
 
 
 
 
 
 
23
  /* Main container styles */
24
- .main-container { padding: 20px; }
 
 
 
25
 
26
  /* Agent flow animation */
27
  .agent-flow {
@@ -33,7 +46,7 @@ st.markdown("""
33
  }
34
 
35
  .agent-node {
36
- background-color: white;
37
  border-radius: 50%;
38
  width: 80px;
39
  height: 80px;
@@ -43,6 +56,10 @@ st.markdown("""
43
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
44
  position: relative;
45
  z-index: 2;
 
 
 
 
46
  }
47
 
48
  .agent-connector {
@@ -69,34 +86,17 @@ st.markdown("""
69
  100% { transform: translateX(100%); opacity: 0; }
70
  }
71
 
72
- /* Progress animation */
73
- @keyframes progress {
74
- 0% { width: 0; }
75
- 100% { width: 100%; }
76
- }
77
-
78
- .progress-bar {
79
- height: 20px;
80
- background-color: #f0f0f0;
81
- border-radius: 10px;
82
- overflow: hidden;
83
- margin: 10px 0;
84
- }
85
-
86
- .progress-fill {
87
- height: 100%;
88
- background-color: #4CAF50;
89
- animation: progress 2s ease-in-out;
90
- }
91
-
92
  /* Agent status indicators */
93
  .agent-status {
94
- padding: 10px;
95
- margin: 5px 0;
96
- border-radius: 5px;
97
- background: #f8f9fa;
98
  border-left: 4px solid #4CAF50;
99
  animation: slideIn 0.3s ease-out;
 
 
 
100
  }
101
 
102
  @keyframes slideIn {
@@ -104,34 +104,73 @@ st.markdown("""
104
  to { transform: translateX(0); opacity: 1; }
105
  }
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  /* Tab styling */
108
  .stTabs [data-baseweb="tab-list"] {
109
  gap: 24px;
 
 
 
110
  }
111
 
112
  .stTabs [data-baseweb="tab"] {
113
  height: 50px;
114
  white-space: pre-wrap;
115
- background-color: #fff;
116
- border-radius: 4px;
117
- color: #000;
118
  padding: 10px 20px;
 
 
119
  }
120
 
121
  .stTabs [aria-selected="true"] {
122
- background-color: #e6f3ff;
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
 
125
- /* Report container */
126
- .report-section {
127
- background: white;
128
- padding: 20px;
129
- border-radius: 10px;
130
- margin: 10px 0;
131
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
132
  }
133
  </style>
134
- """, unsafe_allow_html=True)
135
 
136
  def create_agent_flow(container):
137
  """Create animated agent flow diagram"""
@@ -266,45 +305,47 @@ def run_market_research(topic: str, progress_bar, chat_container):
266
  def main():
267
  st.title("🤖 AI Market Research Generator")
268
 
 
 
 
269
  # Create tabs
270
  tab1, tab2 = st.tabs(["Generate Report", "View Report"])
271
 
272
  with tab1:
273
- col1, col2 = st.columns([2, 3])
274
-
275
- with col1:
276
- st.subheader("Enter Research Topic")
277
- topic = st.text_input(
278
- "What market would you like to research?",
279
- placeholder="e.g., Electric Vehicles Market",
280
- key="research_topic"
281
- )
282
 
283
- if st.button("Generate Report", type="primary"):
284
- if not topic:
285
- st.error("Please enter a research topic")
286
- return
287
-
288
- # Create progress bar and containers
289
- progress = st.progress(0)
290
- chat_container = st.container()
291
 
292
- # Show agent flow diagram
293
- create_agent_flow(col2)
294
-
295
- # Run the research
296
- report = run_market_research(topic, progress, chat_container)
297
-
298
- if report:
299
- # Store results in session state
300
- st.session_state.report = report
301
- st.session_state.current_tab = "report"
302
 
303
- # Switch to report tab
304
- st.experimental_rerun()
 
 
 
 
 
 
 
 
 
305
 
306
  with tab2:
307
- if hasattr(st.session_state, 'report'):
308
  st.subheader("📊 Market Research Report")
309
 
310
  # Display report in sections
@@ -317,11 +358,16 @@ def main():
317
  </div>
318
  """, unsafe_allow_html=True)
319
 
 
 
 
 
 
320
  # Download button
321
  st.download_button(
322
  label="Download Report",
323
  data=st.session_state.report,
324
- file_name=f"market_research_{topic.lower().replace(' ', '_')}.md",
325
  mime="text/markdown"
326
  )
327
 
 
17
  initial_sidebar_state="expanded"
18
  )
19
 
20
+ # Add custom CSS with darker text colors and better contrast
21
  st.markdown("""
22
  <style>
23
+ /* Text colors */
24
+ .stTabs [data-baseweb="tab"] {
25
+ color: #1a1a1a !important;
26
+ font-weight: 500;
27
+ }
28
+
29
+ .stMarkdown, .stText {
30
+ color: #1a1a1a !important;
31
+ }
32
+
33
  /* Main container styles */
34
+ .main-container {
35
+ padding: 20px;
36
+ color: #1a1a1a;
37
+ }
38
 
39
  /* Agent flow animation */
40
  .agent-flow {
 
46
  }
47
 
48
  .agent-node {
49
+ background-color: #ffffff;
50
  border-radius: 50%;
51
  width: 80px;
52
  height: 80px;
 
56
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
57
  position: relative;
58
  z-index: 2;
59
+ color: #1a1a1a;
60
+ font-weight: 500;
61
+ text-align: center;
62
+ line-height: 1.2;
63
  }
64
 
65
  .agent-connector {
 
86
  100% { transform: translateX(100%); opacity: 0; }
87
  }
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  /* Agent status indicators */
90
  .agent-status {
91
+ padding: 15px;
92
+ margin: 10px 0;
93
+ border-radius: 8px;
94
+ background: #ffffff;
95
  border-left: 4px solid #4CAF50;
96
  animation: slideIn 0.3s ease-out;
97
+ color: #1a1a1a;
98
+ font-weight: 400;
99
+ box-shadow: 0 2px 4px rgba(0,0,0,0.05);
100
  }
101
 
102
  @keyframes slideIn {
 
104
  to { transform: translateX(0); opacity: 1; }
105
  }
106
 
107
+ /* Report sections */
108
+ .report-section {
109
+ background: #ffffff;
110
+ padding: 20px;
111
+ border-radius: 10px;
112
+ margin: 15px 0;
113
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
114
+ color: #1a1a1a;
115
+ font-weight: 400;
116
+ line-height: 1.6;
117
+ }
118
+
119
+ /* Progress bar */
120
+ .stProgress > div > div {
121
+ background-color: #4CAF50;
122
+ }
123
+
124
+ /* Button styles */
125
+ .stButton > button {
126
+ font-weight: 500;
127
+ color: #1a1a1a;
128
+ }
129
+
130
  /* Tab styling */
131
  .stTabs [data-baseweb="tab-list"] {
132
  gap: 24px;
133
+ background-color: #f8f9fa;
134
+ padding: 10px;
135
+ border-radius: 10px;
136
  }
137
 
138
  .stTabs [data-baseweb="tab"] {
139
  height: 50px;
140
  white-space: pre-wrap;
141
+ background-color: #ffffff;
142
+ border-radius: 8px;
 
143
  padding: 10px 20px;
144
+ font-weight: 500;
145
+ box-shadow: 0 2px 4px rgba(0,0,0,0.05);
146
  }
147
 
148
  .stTabs [aria-selected="true"] {
149
+ background-color: #e7f3ff;
150
+ color: #0066cc !important;
151
+ }
152
+
153
+ /* Headers */
154
+ h1, h2, h3, h4, h5, h6 {
155
+ color: #1a1a1a !important;
156
+ font-weight: 600;
157
+ }
158
+
159
+ /* Links */
160
+ a {
161
+ color: #0066cc !important;
162
+ text-decoration: none;
163
  }
164
 
165
+ /* Error messages */
166
+ .stAlert {
167
+ background-color: #ffebee;
168
+ color: #c62828;
169
+ padding: 10px;
170
+ border-radius: 8px;
 
171
  }
172
  </style>
173
+ """, unsafe_allow_html=True)
174
 
175
  def create_agent_flow(container):
176
  """Create animated agent flow diagram"""
 
305
  def main():
306
  st.title("🤖 AI Market Research Generator")
307
 
308
+ if 'current_tab' not in st.session_state:
309
+ st.session_state.current_tab = "generate"
310
+
311
  # Create tabs
312
  tab1, tab2 = st.tabs(["Generate Report", "View Report"])
313
 
314
  with tab1:
315
+ if st.session_state.current_tab == "generate":
316
+ col1, col2 = st.columns([2, 3])
 
 
 
 
 
 
 
317
 
318
+ with col1:
319
+ st.subheader("Enter Research Topic")
320
+ topic = st.text_input(
321
+ "What market would you like to research?",
322
+ placeholder="e.g., Electric Vehicles Market",
323
+ key="research_topic"
324
+ )
 
325
 
326
+ if st.button("Generate Report", type="primary"):
327
+ if not topic:
328
+ st.error("Please enter a research topic")
329
+ return
330
+
331
+ # Create progress bar and containers
332
+ progress = st.progress(0)
333
+ chat_container = st.container()
 
 
334
 
335
+ # Show agent flow diagram
336
+ create_agent_flow(col2)
337
+
338
+ # Run the research
339
+ report = run_market_research(topic, progress, chat_container)
340
+
341
+ if report:
342
+ # Store results in session state
343
+ st.session_state.report = report
344
+ st.session_state.current_tab = "report"
345
+ st.rerun() # Using st.rerun() instead of experimental_rerun
346
 
347
  with tab2:
348
+ if st.session_state.current_tab == "report" and hasattr(st.session_state, 'report'):
349
  st.subheader("📊 Market Research Report")
350
 
351
  # Display report in sections
 
358
  </div>
359
  """, unsafe_allow_html=True)
360
 
361
+ # Add 'Generate New Report' button
362
+ if st.button("Generate New Report"):
363
+ st.session_state.current_tab = "generate"
364
+ st.rerun()
365
+
366
  # Download button
367
  st.download_button(
368
  label="Download Report",
369
  data=st.session_state.report,
370
+ file_name=f"market_research_{st.session_state.get('research_topic', 'report').lower().replace(' ', '_')}.md",
371
  mime="text/markdown"
372
  )
373