Personality System
FlavumHive's personality system is a sophisticated framework that enables AI-driven characters to maintain consistent behavior, knowledge, and interaction styles across multiple platforms.
Overview
The personality system consists of:
- Personality definitions
- Trait management
- Platform-specific adaptations
- OpenAI integration
- State management
Personality Structure
Basic Configuration
{
"name": "crypto_researcher",
"description": "An analytical blockchain researcher with expertise in DeFi",
"base_traits": {
"expertise_level": 0.9,
"formality": 0.8,
"friendliness": 0.6
},
"knowledge_areas": [
"Blockchain Technology",
"DeFi Protocols",
"Market Analysis"
]
}
Platform-Specific Behavior
{
"platform_behavior": {
"twitter": {
"tweet_style": "informative_concise",
"thread_probability": 0.7,
"engagement_style": "professional"
},
"reddit": {
"post_style": "detailed_analysis",
"comment_style": "helpful_academic",
"community_engagement": "active"
}
}
}
Personality Traits
Core Traits
-
Expertise Level (0.0 - 1.0)
- Influences technical depth
- Affects jargon usage
- Determines analysis complexity
-
Formality (0.0 - 1.0)
- Communication style
- Language choice
- Structural formatting
-
Friendliness (0.0 - 1.0)
- Engagement approach
- Response tone
- Community interaction
Trait Implementation
class PersonalityTrait:
def __init__(self, name: str, value: float):
self.name = name
self.value = self._normalize_value(value)
self.influence_factors = {}
def apply_to_content(self, content: str) -> str:
# Modify content based on trait value
return modified_content
OpenAI Integration
Prompt Engineering
def generate_prompt(self, context: dict) -> str:
return f"""
You are a {self.description} with the following traits:
- Expertise: {self.traits['expertise_level']}
- Formality: {self.traits['formality']}
- Friendliness: {self.traits['friendliness']}
Your knowledge areas include: {', '.join(self.knowledge_areas)}
Please respond to: {context['query']}
Platform: {context['platform']}
Style: {self.platform_behavior[context['platform']]['style']}
"""
Response Processing
def process_response(self, response: str, platform: str) -> str:
# Apply platform-specific formatting
formatted = self.format_for_platform(response, platform)
# Apply personality traits
for trait in self.traits:
formatted = trait.apply_to_content(formatted)
return formatted
State Management
Personality State
class PersonalityState:
def __init__(self):
self.conversation_history = []
self.mood_factors = {}
self.recent_interactions = []
self.platform_states = {}
State Persistence
def save_state(self):
state = {
"conversation_history": self.conversation_history[-100:],
"mood_factors": self.mood_factors,
"recent_interactions": self.recent_interactions[-50:]
}
return state
def load_state(self, state: dict):
self.conversation_history = state.get("conversation_history", [])
self.mood_factors = state.get("mood_factors", {})
self.recent_interactions = state.get("recent_interactions", [])
Platform Adaptation
Content Formatting
def format_for_platform(self, content: str, platform: str) -> str:
if platform == "twitter":
return self._format_tweet(content)
elif platform == "reddit":
return self._format_reddit_post(content)
Interaction Patterns
def determine_interaction(self, context: dict) -> str:
platform = context["platform"]
behavior = self.platform_behavior[platform]
if platform == "twitter":
return self._handle_twitter_interaction(context, behavior)
elif platform == "reddit":
return self._handle_reddit_interaction(context, behavior)
Creating Custom Personalities
1. Define Base Configuration
{
"name": "your_personality",
"description": "Detailed description",
"base_traits": {
"trait1": value,
"trait2": value
}
}
2. Implement Platform Behavior
{
"platform_behavior": {
"platform1": {
"style": "desired_style",
"settings": {}
}
}
}
3. Add Knowledge Areas
{
"knowledge_areas": [
"Area 1",
"Area 2"
],
"expertise_levels": {
"Area 1": 0.9,
"Area 2": 0.7
}
}
Best Practices
1. Consistency
- Maintain consistent trait values
- Align knowledge areas with expertise
- Use platform-appropriate formatting
2. Natural Variation
- Implement slight randomness
- Allow context influence
- Maintain personality core
3. Platform Optimization
- Respect platform limits
- Use platform features
- Adapt to community norms
Monitoring and Analytics
Tracking Metrics
- Response consistency
- Engagement rates
- Personality trait impact
- Platform performance
Analytics Dashboard
def get_personality_analytics(self):
return {
"trait_influence": self._analyze_trait_impact(),
"platform_performance": self._analyze_platform_metrics(),
"engagement_stats": self._calculate_engagement()
}
Troubleshooting
Common Issues
- Inconsistent behavior
- Platform mismatch
- Knowledge gaps
- Trait conflicts
Solutions
- Review trait values
- Adjust platform settings
- Update knowledge areas
- Resolve conflicts