Spaces:
Sleeping
Sleeping
Update pages.py
Browse files
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 |
-
|
|
|
|
| 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
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 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 |
-
|
| 275 |
-
|
| 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 |
-
|
| 297 |
-
response =
|
| 298 |
-
|
| 299 |
st.rerun()
|
| 300 |
|
| 301 |
with col2:
|
| 302 |
if st.button("π Marketing Tips"):
|
| 303 |
-
|
| 304 |
-
response =
|
| 305 |
-
|
| 306 |
st.rerun()
|
| 307 |
|
| 308 |
with col3:
|
| 309 |
if st.button("π° Financial Planning"):
|
| 310 |
-
|
| 311 |
-
response =
|
| 312 |
-
|
| 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
|