MyStar: Self-Hosted AI Companion
MyStar is an advanced, fully local AI companion bot for Telegram built with Python, Ollama, SD.Next, and Whisper.
Unlike simple chatbots, MyStar features a "living" personality with long-term memory, simulated biological cycles, multimodal perception (vision/hearing), and autonomous behavior.
🚀 Key Features
🧠 1. Dynamic Personality & Cognition
- Modular Prompting: The
SYSTEM_PROMPTis assembled dynamically on the fly. Depending on the context, different personality modules are injected into the base prompt. - Long-Term Memory (LTM): The bot utilizes a "Diary" system (SQLite). It does not simply feed the entire chat history to the LLM. Instead, it injects:
[Base Persona] + [LTM Summary] + [Recent Context]. - Background "Thinking": When you are inactive, a background process (
run_memory_summarization) analyzes recent conversations, extracts key facts about you (hobbies, problems, plans), and saves them to the LTM database.
💖 2. Relationships & Biological States
- Relationship Progression: The bot supports three distinct stages: Stranger, Friend, and Lover.
- Auto-Progression: The bot automatically detects romantic intent and upgrades the relationship status.
- Simulated 28-Day Cycle: The bot tracks a simulated cycle that affects her mood and prompt directives:
- Period (Days 1-7): She may feel moody, crave comfort, and will refuse NSFW interactions.
- Ovulation (Days 12-16): She becomes more flirtatious, confident, and affectionate.
👁️ 3. Multimodal Perception ("Sensors")
- Vision (Image Recognition): You can send photos to the bot. She "sees" them and comments on them naturally.
- Hearing (Voice Messages): Integrated OpenAI Whisper allows the bot to listen to your voice notes and respond to them as text.
- Context Awareness: She detects your work schedule and respects your time (avoiding distractions during work hours).
💬 4. Advanced Interaction & Visuals
- AI Spontaneous Messages: No hardcoded templates. If you haven't texted in a while, she generates a unique, context-aware message to check on you.
- High-Quality Image Generation:
- Powered by SD.Next and the ✨ JANKU Trained + NoobAI + RouWei Illustrious XL ✨ model for top-tier anime aesthetics.
- SFW by Default: Generates cute/cozy selfies based on the conversation context.
- Contextual NSFW: Explicit generation is strictly gated (requires 'Lover' status, specific user request, and appropriate timing).
🛠️ Tech Stack
- Python 3.10+
- Ollama: Local LLM backend.
- SD.Next: Advanced Stable Diffusion WebUI.
- FFmpeg: Audio processing for Whisper.
📦 Installation Guide
Step 1: Install & Configure Ollama
- Download Ollama:
- Standard: Download from the Official Website.
- For unsupported AMD GPUs: If you have an older or unsupported Radeon card, use this fork: Ollama for AMD.
- Pull the Model:
Open your terminal and pull the model used in the config (default is
gemma3:12b):ollama pull gemma3:12b
Step 2: Install & Configure SD.Next
- Install SD.Next: Clone and install the repository from vladmandic/sdnext.
- Download the Checkpoint: Download the ✨ JANKU Trained + NoobAI + RouWei Illustrious XL ✨ model.
- Setup:
- Place the downloaded model into the
models/Stable-diffusionfolder inside your SD.Next directory. - Run SD.Next with the API flag enabled:
./webui.sh --api --debug # Or on Windows: webui.bat --api --debug
- Place the downloaded model into the
Step 3: Install The Bot
-
Clone this repository:
git clone https://git.maxo.one/Maxo/MyStar.git cd MyStar -
Install Python Dependencies:
pip install python-telegram-bot python-telegram-bot[job-queue] openai-whisper requests(Note: You also need
ffmpeginstalled on your system path for Whisper to work). -
Environment Setup: Set your Telegram token as an environment variable (or edit the
TELEGRAM_BOT_TOKENline in the script directly, though not recommended for security).export TELEGRAM_BOT_TOKEN="your_telegram_bot_token" -
Run the Bot:
python MyStarENG.py
📄 License
MIT License. See LICENSE file for details.
Languages
Python
100%