Pranav0111 commited on
Commit
baca1ed
Β·
verified Β·
1 Parent(s): c337765

Update pages.py

Browse files
Files changed (1) hide show
  1. pages.py +17 -50
pages.py CHANGED
@@ -239,51 +239,18 @@ def render_brainstorm_page():
239
  st.info("No products yet. Create one to get started!")
240
 
241
 
242
- def render_chat():
 
243
  st.header("πŸ’¬ AI Business Mentor")
244
 
245
- # Initialize chatbot manager
246
- chatbot = ChatbotManager()
247
- chatbot.initialize_chat()
248
-
249
  # Sidebar options
250
- st.sidebar.subheader("Chat Options")
251
- if st.sidebar.button("Clear Chat History"):
252
- chatbot.clear_chat()
253
- st.rerun()
254
-
255
- # Display chat history
256
- st.subheader("πŸ€– Conversation")
257
-
258
- # Chat container
259
- chat_container = st.container()
260
-
261
- with chat_container:
262
- # Display all messages
263
- for message in chatbot.get_chat_history():
264
- if message["role"] == "user":
265
- with st.chat_message("user"):
266
- st.write(message["content"])
267
- else:
268
- with st.chat_message("assistant"):
269
- st.write(message["content"])
270
-
271
- # Chat input
272
- user_input = st.chat_input("Ask me anything about business strategy, marketing, products, or operations...")
273
 
274
- if user_input:
275
- # Add user message
276
- chatbot.add_message("user", user_input)
277
-
278
- # Generate response
279
- with st.spinner("Thinking..."):
280
- response = chatbot.generate_business_response(user_input)
281
-
282
- # Add assistant response
283
- chatbot.add_message("assistant", response)
284
-
285
- # Rerun to update the display
286
- st.rerun()
287
 
288
  # Additional helpful sections
289
  st.markdown("---")
@@ -293,23 +260,23 @@ def render_chat():
293
 
294
  with col1:
295
  if st.button("πŸ“Š Business Strategy"):
296
- chatbot.add_message("user", "I need help with business strategy")
297
- response = chatbot.generate_business_response("I need help with business strategy")
298
- chatbot.add_message("assistant", response)
299
  st.rerun()
300
 
301
  with col2:
302
  if st.button("πŸ“ˆ Marketing Tips"):
303
- chatbot.add_message("user", "Give me marketing advice")
304
- response = chatbot.generate_business_response("Give me marketing advice")
305
- chatbot.add_message("assistant", response)
306
  st.rerun()
307
 
308
  with col3:
309
  if st.button("πŸ’° Financial Planning"):
310
- chatbot.add_message("user", "Help with financial planning")
311
- response = chatbot.generate_business_response("Help with financial planning")
312
- chatbot.add_message("assistant", response)
313
  st.rerun()
314
 
315
  # Optional: Keep the iframe as alternative
 
239
  st.info("No products yet. Create one to get started!")
240
 
241
 
242
+ # Update the render_chat function in pages.py
243
+ def render_chat(chatbot_manager):
244
  st.header("πŸ’¬ AI Business Mentor")
245
 
 
 
 
 
246
  # Sidebar options
247
+ with st.sidebar:
248
+ if st.button("Clear Chat History"):
249
+ chatbot_manager.clear_chat()
250
+ st.rerun()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
 
252
+ # Render the chat interface using the manager
253
+ chatbot_manager.render_chat_interface()
 
 
 
 
 
 
 
 
 
 
 
254
 
255
  # Additional helpful sections
256
  st.markdown("---")
 
260
 
261
  with col1:
262
  if st.button("πŸ“Š Business Strategy"):
263
+ chatbot_manager.add_message("user", "I need help with business strategy")
264
+ response = chatbot_manager.generate_response("I need help with business strategy")
265
+ chatbot_manager.add_message("assistant", response)
266
  st.rerun()
267
 
268
  with col2:
269
  if st.button("πŸ“ˆ Marketing Tips"):
270
+ chatbot_manager.add_message("user", "Give me marketing advice")
271
+ response = chatbot_manager.generate_response("Give me marketing advice")
272
+ chatbot_manager.add_message("assistant", response)
273
  st.rerun()
274
 
275
  with col3:
276
  if st.button("πŸ’° Financial Planning"):
277
+ chatbot_manager.add_message("user", "Help with financial planning")
278
+ response = chatbot_manager.generate_response("Help with financial planning")
279
+ chatbot_manager.add_message("assistant", response)
280
  st.rerun()
281
 
282
  # Optional: Keep the iframe as alternative