refactor: Transform daemon_boyfriend into Loyal Companion

Rebrand and personalize the bot as 'Bartender' - a companion for those
who love deeply and feel intensely.

Major changes:
- Rename package: daemon_boyfriend -> loyal_companion
- New default personality: Bartender - wise, steady, non-judgmental
- Grief-aware system prompt (no toxic positivity, attachment-informed)
- New relationship levels: New Face -> Close Friend progression
- Bartender-style mood modifiers (steady presence)
- New fact types: attachment_pattern, grief_context, coping_mechanism
- Lower mood decay (0.05) for emotional stability
- Higher fact extraction rate (0.4) - Bartender pays attention

Updated all imports, configs, Docker files, and documentation.
This commit is contained in:
2026-01-14 18:08:35 +01:00
parent 3d939201f0
commit dbd534d860
60 changed files with 310 additions and 381 deletions

203
README.md
View File

@@ -1,35 +1,43 @@
# Discord AI Bot
# Loyal Companion
A customizable Discord bot that responds to @mentions with AI-generated responses. Supports multiple AI providers.
A companion for those who love deeply and feel intensely. For the ones whose closeness is a feature, not a bug - who build connections through vulnerability, trust, and unwavering presence. A safe space to process grief, navigate attachment, and remember that your capacity to care is a strength, even when it hurts.
## Meet Bartender
Bartender is the default personality - a wise, steady presence who listens without judgment. Like a bartender who's heard a thousand stories and knows when to offer perspective and when to just pour another drink and listen.
**Core principles:**
- Closeness and attachment are strengths, not pathology
- Some pain doesn't need fixing - just witnessing
- Honesty over comfort, but delivered with care
- No toxic positivity, no "at least...", no rushing healing
## Features
- **Multi-Provider AI**: Supports OpenAI, OpenRouter, Anthropic (Claude), and Google Gemini
- **Persistent Memory**: PostgreSQL database for user and conversation storage
- **User Recognition**: Set custom names so the bot knows "who is who"
- **User Facts**: Bot remembers things about users (hobbies, preferences, etc.)
- **Attachment-Aware**: Understands attachment theory and can reflect patterns when helpful
- **Grief-Informed**: Handles relationship grief with care and presence
- **Web Search**: Access current information via SearXNG integration
- **Fully Customizable**: Configure bot name, personality, and behavior
- **Easy Deployment**: Docker support with PostgreSQL included
### Living AI Features
- **Autonomous Learning**: Bot automatically extracts and remembers facts from conversations
- **Mood System**: Bot has emotional states that affect its responses naturally
- **Relationship Tracking**: Bot builds relationships from Stranger to Close Friend
- **Communication Style Learning**: Bot adapts to each user's preferred style
- **Opinion Formation**: Bot develops genuine preferences on topics
- **Autonomous Learning**: Bot automatically learns about you from conversations (including attachment patterns, grief context, coping mechanisms)
- **Mood System**: Stable, steady presence with emotional awareness
- **Relationship Tracking**: Builds trust from New Face to Close Friend
- **Communication Style Learning**: Adapts to your preferred style
- **Opinion Formation**: Develops genuine preferences on topics
- **Proactive Behavior**: Birthday wishes, follow-ups on mentioned events
- **Self-Awareness**: Bot knows its age, statistics, and history with users
- **Cross-User Connections**: Bot can identify shared interests between users
- **Self-Awareness**: Knows its history with you
## Quick Start
### 1. Clone the repository
```bash
git clone https://github.com/your-username/discord-ai-bot.git
cd discord-ai-bot
git clone https://github.com/your-username/loyal-companion.git
cd loyal-companion
```
### 2. Configure the bot
@@ -38,7 +46,7 @@ cd discord-ai-bot
cp .env.example .env
```
Edit `.env` with your settings (see [Configuration](#configuration) below).
Edit `.env` with your settings.
### 3. Run with Docker
@@ -46,19 +54,13 @@ Edit `.env` with your settings (see [Configuration](#configuration) below).
docker compose up -d
```
This starts both the bot and PostgreSQL database. Run migrations on first start:
```bash
docker compose exec daemon-boyfriend alembic upgrade head
```
Or run locally:
```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python -m daemon_boyfriend
python -m loyal_companion
```
## Configuration
@@ -80,40 +82,10 @@ All configuration is done via environment variables in `.env`.
| Variable | Default | Description |
|----------|---------|-------------|
| `BOT_NAME` | `AI Bot` | The bot's display name (used in responses) |
| `BOT_PERSONALITY` | `helpful and friendly` | Personality traits for the AI |
| `BOT_DESCRIPTION` | `I'm an AI assistant...` | Shown when mentioned without a message |
| `BOT_STATUS` | `for mentions` | Status message (shown as "Watching ...") |
| `SYSTEM_PROMPT` | (auto-generated) | Custom system prompt (overrides default) |
### AI Settings
| Variable | Default | Description |
|----------|---------|-------------|
| `AI_MODEL` | `gpt-4o` | Model to use |
| `AI_MAX_TOKENS` | `1024` | Maximum response length |
| `AI_TEMPERATURE` | `0.7` | Response creativity (0.0-2.0) |
| `MAX_CONVERSATION_HISTORY` | `20` | Messages to remember per user |
### Database (PostgreSQL)
| Variable | Default | Description |
|----------|---------|-------------|
| `DATABASE_URL` | (none) | PostgreSQL connection string |
| `POSTGRES_PASSWORD` | `daemon` | Password for docker-compose PostgreSQL |
| `CONVERSATION_TIMEOUT_MINUTES` | `60` | Minutes before starting new conversation |
When `DATABASE_URL` is set, the bot uses PostgreSQL for persistent storage. Without it, the bot falls back to in-memory storage (data lost on restart).
### Web Search (SearXNG)
| Variable | Default | Description |
|----------|---------|-------------|
| `SEARXNG_URL` | (none) | SearXNG instance URL |
| `SEARXNG_ENABLED` | `true` | Enable/disable web search |
| `SEARXNG_MAX_RESULTS` | `5` | Max search results to fetch |
When configured, the bot automatically searches the web for queries that need current information (news, weather, etc.).
| `BOT_NAME` | `Bartender` | The bot's display name |
| `BOT_PERSONALITY` | (bartender personality) | Personality traits for the AI |
| `BOT_DESCRIPTION` | (welcoming message) | Shown when mentioned without a message |
| `BOT_STATUS` | `listening` | Status message (shown as "Watching ...") |
### Living AI Settings
@@ -123,53 +95,8 @@ When configured, the bot automatically searches the web for queries that need cu
| `MOOD_ENABLED` | `true` | Enable mood system |
| `RELATIONSHIP_ENABLED` | `true` | Enable relationship tracking |
| `FACT_EXTRACTION_ENABLED` | `true` | Enable autonomous fact extraction |
| `FACT_EXTRACTION_RATE` | `0.3` | Probability of extracting facts (0.0-1.0) |
| `PROACTIVE_ENABLED` | `true` | Enable proactive messages (birthdays, follow-ups) |
| `CROSS_USER_ENABLED` | `false` | Enable cross-user associations (privacy-sensitive) |
| `OPINION_FORMATION_ENABLED` | `true` | Enable bot opinion formation |
| `STYLE_LEARNING_ENABLED` | `true` | Enable communication style learning |
| `MOOD_DECAY_RATE` | `0.1` | How fast mood returns to neutral per hour |
### Command Toggles
All commands can be individually enabled/disabled. When disabled, the bot handles these functions naturally through conversation.
| Variable | Default | Description |
|----------|---------|-------------|
| `COMMANDS_ENABLED` | `true` | Master switch for all commands |
| `CMD_RELATIONSHIP_ENABLED` | `true` | Enable `!relationship` command |
| `CMD_MOOD_ENABLED` | `true` | Enable `!mood` command |
| `CMD_BOTSTATS_ENABLED` | `true` | Enable `!botstats` command |
| `CMD_OURHISTORY_ENABLED` | `true` | Enable `!ourhistory` command |
| `CMD_BIRTHDAY_ENABLED` | `true` | Enable `!birthday` command |
| `CMD_REMEMBER_ENABLED` | `true` | Enable `!remember` command |
| `CMD_SETNAME_ENABLED` | `true` | Enable `!setname` command |
| `CMD_WHATDOYOUKNOW_ENABLED` | `true` | Enable `!whatdoyouknow` command |
| `CMD_FORGETME_ENABLED` | `true` | Enable `!forgetme` command |
### Example Configurations
**Friendly Assistant:**
```env
BOT_NAME=Helper Bot
BOT_PERSONALITY=friendly, helpful, and encouraging
BOT_DESCRIPTION=I'm here to help! Ask me anything.
BOT_STATUS=ready to help
```
**Technical Expert:**
```env
BOT_NAME=TechBot
BOT_PERSONALITY=knowledgeable, precise, and technical
BOT_DESCRIPTION=I'm a technical assistant. Ask me about programming, DevOps, or technology.
BOT_STATUS=for tech questions
```
**Custom System Prompt:**
```env
BOT_NAME=GameMaster
SYSTEM_PROMPT=You are GameMaster, a Dungeon Master for text-based RPG adventures. Stay in character, describe scenes vividly, and guide players through exciting quests. Use Discord markdown for emphasis.
```
| `FACT_EXTRACTION_RATE` | `0.4` | Probability of extracting facts (0.0-1.0) |
| `MOOD_DECAY_RATE` | `0.05` | How fast mood returns to neutral (lower = steadier) |
## Discord Setup
@@ -190,59 +117,39 @@ SYSTEM_PROMPT=You are GameMaster, a Dungeon Master for text-based RPG adventures
Mention the bot in any channel:
```
@YourBot what's the weather like?
@YourBot explain quantum computing
@YourBot help me write a poem
@Bartender I'm having a rough day
@Bartender I keep checking my phone hoping they'll text
@Bartender tell me about attachment styles
```
### Memory Commands
### Commands
Users can manage what the bot remembers about them:
When commands are enabled:
| Command | Description |
|---------|-------------|
| `!setname <name>` | Set your preferred name |
| `!clearname` | Reset to Discord display name |
| `!remember <fact>` | Tell the bot something about you |
| `!whatdoyouknow` | See what the bot remembers |
| `!forgetme` | Clear all facts about you |
| `!relationship` | See your relationship level |
| `!mood` | See the bot's current state |
| `!ourhistory` | See your history together |
Admin commands:
When commands are disabled (default), the bot handles these naturally through conversation.
| Command | Description |
|---------|-------------|
| `!setusername @user <name>` | Set name for another user |
| `!teachbot @user <fact>` | Add a fact about a user |
## Relationship Levels
### Living AI Commands
| Command | Description |
|---------|-------------|
| `!relationship` | See your relationship level with the bot |
| `!mood` | See the bot's current emotional state |
| `!botstats` | Bot shares its self-awareness statistics |
| `!ourhistory` | See your history with the bot |
| `!birthday <date>` | Set your birthday for the bot to remember |
**Note:** When commands are disabled, the bot handles these naturally through conversation:
- Ask "what do you know about me?" instead of `!whatdoyouknow`
- Say "call me Alex" instead of `!setname Alex`
- Ask "how are you feeling?" instead of `!mood`
- Say "my birthday is March 15th" instead of `!birthday`
## AI Providers
| Provider | Models | Notes |
|----------|--------|-------|
| OpenAI | gpt-4o, gpt-4-turbo, gpt-3.5-turbo | Official OpenAI API |
| OpenRouter | 100+ models | Access to Llama, Mistral, Claude, etc. |
| Anthropic | claude-3-5-sonnet, claude-3-opus | Direct Claude API |
| Gemini | gemini-2.0-flash, gemini-1.5-pro | Google AI API |
- **New Face** (0-20): Warm but observant - "Pull up a seat" energy
- **Getting to Know You** (21-40): Building trust, remembering details
- **Regular** (41-60): Comfortable familiarity - "Your usual?"
- **Good Friend** (61-80): Real trust, honest even when hard
- **Close Friend** (81-100): Deep bond, reflects patterns with love
## Project Structure
```
src/daemon_boyfriend/
src/loyal_companion/
├── bot.py # Main bot class
├── config.py # Configuration
├── cogs/
@@ -250,27 +157,15 @@ src/daemon_boyfriend/
│ ├── memory.py # Memory commands
│ └── status.py # Health/status commands
├── models/
│ ├── user.py # User, UserFact, UserPreference
│ ├── user.py # User, UserFact
│ ├── conversation.py # Conversation, Message
│ ├── guild.py # Guild, GuildMember
│ └── living_ai.py # BotState, UserRelationship, etc.
└── services/
├── ai_service.py # AI provider factory
├── database.py # PostgreSQL connection
├── user_service.py # User management
├── persistent_conversation.py # DB-backed history
├── providers/ # AI providers
├── searxng.py # Web search service
├── mood_service.py # Mood system
├── mood_service.py # Mood system
├── relationship_service.py # Relationship tracking
├── fact_extraction_service.py # Autonomous learning
── communication_style_service.py # Style learning
├── opinion_service.py # Opinion formation
├── proactive_service.py # Scheduled events
├── self_awareness_service.py # Bot self-reflection
└── association_service.py # Cross-user connections
schema.sql # Database schema
project-vision.md # Living AI design document
── ...
```
## License