# 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_PROMPT` is 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 **AAM XL (Anime Mix)** 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 1. **Download Ollama:** * **Standard:** Download from the [Official Website](https://ollama.com/download). * **For unsupported AMD GPUs:** If you have an older or unsupported Radeon card, use this fork: [Ollama for AMD](https://github.com/likelovewant/ollama-for-amd). 2. **Pull the Model:** Open your terminal and pull the model used in the config (default is `ministral-3:14b`): ```bash ollama pull ministral-3:14b ``` #### Step 2: Install & Configure SD.Next 1. **Install SD.Next:** Clone and install the repository from [vladmandic/sdnext](https://github.com/vladmandic/sdnext). 2. **Download the Checkpoint:** Download the **[✨ JANKU Trained + NoobAI + RouWei Illustrious XL ✨](https://civitai.com/models/1277670?modelVersionId=2358314)** model. 3. **Setup:** * Place the downloaded model into the `models/Stable-diffusion` folder inside your SD.Next directory. * Run SD.Next with the API flag enabled: ```bash ./webui.sh --api --debug # Or on Windows: # webui.bat --api --debug ``` #### Step 3: Install The Bot 1. **Clone this repository:** ```bash git clone https://git.maxo.one/Maxo/MyStar.git cd MyStar ``` 2. **Install Python Dependencies:** ```bash pip install python-telegram-bot python-telegram-bot[job-queue] openai-whisper requests ``` *(Note: You also need `ffmpeg` installed on your system path for Whisper to work).* 3. **Environment Setup:** Set your Telegram token as an environment variable (or edit the `TELEGRAM_BOT_TOKEN` line in the script directly, though not recommended for security). ```bash export TELEGRAM_BOT_TOKEN="your_telegram_bot_token" ``` 4. **Run the Bot:** ```bash python MyStarENG.py ``` ### 📄 License MIT License. See `LICENSE` file for details.