Spaces:
Running
Running
File size: 6,587 Bytes
4421377 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
import streamlit as st
import requests
from typing import List, Dict
import json
class ChatbotManager:
def __init__(self):
if 'chat_history' not in st.session_state:
st.session_state.chat_history = []
if 'chat_initialized' not in st.session_state:
st.session_state.chat_initialized = False
def initialize_chat(self):
"""Initialize the chat with a welcome message"""
if not st.session_state.chat_initialized:
welcome_message = {
"role": "assistant",
"content": "Hello! I'm your AI Business Mentor. I can help you with business strategy, market analysis, product development, marketing insights, and more. What would you like to discuss today?"
}
st.session_state.chat_history.append(welcome_message)
st.session_state.chat_initialized = True
def add_message(self, role: str, content: str):
"""Add a message to the chat history"""
message = {"role": role, "content": content}
st.session_state.chat_history.append(message)
def get_chat_history(self) -> List[Dict]:
"""Get the current chat history"""
return st.session_state.chat_history
def clear_chat(self):
"""Clear the chat history"""
st.session_state.chat_history = []
st.session_state.chat_initialized = False
def generate_business_response(self, user_input: str) -> str:
"""
Generate a business-focused response based on user input
This is a simple rule-based system that can be enhanced with actual AI models
"""
user_input_lower = user_input.lower()
# Business strategy keywords
if any(keyword in user_input_lower for keyword in ['strategy', 'plan', 'planning', 'roadmap']):
return """Great question about business strategy! Here are some key considerations:
1. **Market Analysis**: Understand your target market, competitors, and industry trends
2. **Value Proposition**: Clearly define what unique value you provide
3. **Resource Allocation**: Determine how to best use your time, money, and team
4. **Growth Strategy**: Plan for sustainable scaling and expansion
5. **Risk Management**: Identify potential challenges and mitigation strategies
What specific aspect of strategy would you like to dive deeper into?"""
# Marketing keywords
elif any(keyword in user_input_lower for keyword in ['marketing', 'promotion', 'advertising', 'brand']):
return """Marketing is crucial for business success! Here's a framework to consider:
1. **Target Audience**: Define your ideal customer personas
2. **Channels**: Choose the right mix of digital and traditional channels
3. **Content Strategy**: Create valuable, engaging content
4. **Budget Allocation**: Distribute resources across channels effectively
5. **Metrics & Analytics**: Track performance and ROI
What's your current marketing challenge or goal?"""
# Product development keywords
elif any(keyword in user_input_lower for keyword in ['product', 'development', 'features', 'mvp']):
return """Product development is exciting! Here's a structured approach:
1. **Market Research**: Validate demand and understand user needs
2. **MVP Strategy**: Start with core features and iterate
3. **User Feedback**: Continuously gather and incorporate feedback
4. **Competitive Analysis**: Learn from competitors' successes and failures
5. **Roadmap Planning**: Prioritize features based on impact and effort
What stage is your product in, and what specific guidance do you need?"""
# Financial keywords
elif any(keyword in user_input_lower for keyword in ['finance', 'funding', 'revenue', 'profit', 'investment']):
return """Financial planning is the backbone of any successful business:
1. **Revenue Streams**: Diversify how you generate income
2. **Cost Management**: Track and optimize your expenses
3. **Cash Flow**: Maintain healthy cash flow for operations
4. **Funding Options**: Consider bootstrapping, loans, or investors
5. **Financial Projections**: Create realistic forecasts and budgets
What specific financial aspect would you like to explore?"""
# Team/HR keywords
elif any(keyword in user_input_lower for keyword in ['team', 'hiring', 'employee', 'culture', 'management']):
return """Building a strong team is essential for growth:
1. **Hiring Strategy**: Define roles clearly and hire for culture fit
2. **Team Culture**: Foster collaboration and shared values
3. **Performance Management**: Set clear expectations and provide feedback
4. **Development**: Invest in training and career growth
5. **Retention**: Create an environment where people want to stay
What team-related challenges are you facing?"""
# Startup keywords
elif any(keyword in user_input_lower for keyword in ['startup', 'entrepreneur', 'launch', 'idea']):
return """Launching a startup is an exciting journey! Key steps to consider:
1. **Idea Validation**: Test your concept with potential customers
2. **Business Model**: Define how you'll make money
3. **Legal Structure**: Choose the right business entity
4. **Minimum Viable Product**: Build and test quickly
5. **Network Building**: Connect with mentors, advisors, and peers
What stage are you at in your startup journey?"""
# General business advice
else:
return f"""Thank you for your question about "{user_input}".
As your AI Business Mentor, I'm here to help with various aspects of business including:
• **Strategy & Planning** - Business models, roadmaps, competitive analysis
• **Marketing & Sales** - Customer acquisition, branding, digital marketing
• **Product Development** - MVP creation, feature prioritization, user feedback
• **Finance & Operations** - Budgeting, funding, process optimization
• **Team & Leadership** - Hiring, culture building, management practices
Could you provide more specific details about what you'd like to explore? The more context you give me, the better I can tailor my advice to your situation."""
def format_message_for_display(self, message: Dict) -> str:
"""Format a message for display in the chat interface"""
role = message["role"]
content = message["content"]
if role == "user":
return f"**You:** {content}"
else:
return f"**AI Mentor:** {content}" |