Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ae3d70a
Merge pull request #38 from Afdaan/fix/reply-quote-formatting
Afdaan Dec 9, 2025
e7ee411
Merge pull request #40 from Afdaan/development
Afdaan Dec 9, 2025
f14f0e2
Merge pull request #42 from Afdaan/development
Afdaan Jan 4, 2026
6e6d91d
feat: Enhance voice model setup and processing
Afdaan Feb 9, 2026
1949d22
feat: Refactor requirements.txt for improved organization and clarity
Afdaan Feb 9, 2026
c890f30
feat: add voice language support & RVC integration
Afdaan Mar 6, 2026
685d334
fix: lower torchaudio minimum to 2.6.0
Afdaan Mar 6, 2026
469da08
fix: downgrade faiss-cpu to 1.7.3
Afdaan Mar 6, 2026
a0f7903
fix: Pin pip <24.1 and uninstall omegaconf
Afdaan Mar 6, 2026
5567152
fix: precompute persona traits & relationship text
Afdaan Mar 6, 2026
d852989
fix: add __init__.py for rvc_python packages
Afdaan Mar 6, 2026
25700a3
fix: rvc module
Afdaan Mar 6, 2026
2b8930c
fix: force reload rvc modules to bypass site-packages
Afdaan Mar 6, 2026
40c1c93
fix: rvc module reload and absolute paths
Afdaan Mar 6, 2026
448b0a5
fix: unignore internal lib folder and force add rvc files
Afdaan Mar 6, 2026
bf7ca4f
fix: Refactor DB imports, add RVC fix and DB migration
Afdaan Mar 6, 2026
6522f79
fix: Extend users table with mood and voice columns
Afdaan Mar 6, 2026
c0923aa
feat: add ChatActionSender and voice/mood DB support
Afdaan Mar 6, 2026
c4e582a
fix: Format context & use ContextManager in voice handler
Afdaan Mar 6, 2026
4d91f7e
feat: switch Japanese lang key to 'jp' and prefer RVC
Afdaan Mar 7, 2026
78c36dc
feat: Use TTS microservice; remove bundled RVC
Afdaan Mar 7, 2026
7ad7713
fix: Remove RVC and local voice model settings
Afdaan Mar 7, 2026
89afc0c
Remove test_vp_init.py
Afdaan Mar 10, 2026
24d5fe0
fix: Language-aware persona prompts and handler refactor
Afdaan Mar 12, 2026
e858c7d
feat: Add animated loading UI and edit responses
Afdaan Mar 12, 2026
102aac8
feat: centralize loading animations in helpers
Afdaan Mar 15, 2026
84b752e
Merge pull request #43 from Afdaan/feat/ui
Afdaan Mar 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 74 additions & 57 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,71 +1,88 @@
# =============================================================================
# Alya Bot - Environment Configuration
# Copy this file to .env and fill in your actual values
# ============================================================================
# =============================================================================

# =============================================================================
# BOT (REQUIRED)
# =============================================================================

# Get your bot token from: https://t.me/BotFather
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here # Replace with your actual Telegram Bot Token
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here

# ============================================================================
# ADMIN CONFIGURATION (REQUIRED)
# ============================================================================
# Your Telegram User ID (get from: https://t.me/userinfobot)
# For multiple admins, use comma-separated list: 12345678,87654321
ADMIN_IDS=your_telegram_ids # Comma-separated list of Telegram user IDs, e.g., 12345678,87654321
# Multiple admins: comma-separated, e.g. 12345678,87654321
ADMIN_IDS=your_telegram_user_id

# =============================================================================
# GEMINI API (REQUIRED)
# =============================================================================

# ============================================================================
# GOOGLE GEMINI API CONFIGURATION (REQUIRED)
# ============================================================================
# Get API keys from: https://aistudio.google.com/api-keys
# Multiple keys supported for automatic rotation and reliability
GEMINI_API_KEYS=gemini_key_1,gemini_key_2,gemini_key_3 # Replace with your actual Gemini API keys

# ============================================================================
# NLP & AI MODELS CONFIGURATION (OPTIONAL)
# ============================================================================
# Override default HuggingFace models (optional)
# EMOTION_MODEL_ID=Aardiiiiy/EmoSense-ID-Indonesian-Emotion-Classifier # Indonesian emotion detection
# EMOTION_MODEL_EN=AnasAlokla/multilingual_go_emotions # English/multilingual emotion detection
# INTENT_SENTIMENT_MODEL=cardiffnlp/twitter-roberta-base-sentiment-latest # Lightweight sentiment for intent

# Hybrid Intent Detection (recommended for performance)
# Set to 'false' to use pure rule-based intent detection (fastest, no ML overhead)
USE_HYBRID_INTENT=true # true = rule-based + ML fallback | false = pure rule-based

# ============================================================================
# DATABASE CONFIGURATION (REQUIRED)
# ============================================================================
# MySQL/MariaDB settings (recommended for production)
# Multiple keys are supported for automatic rotation
GEMINI_API_KEYS=key_1,key_2,key_3

# =============================================================================
# DATABASE (REQUIRED)
# =============================================================================

# MySQL / MariaDB connection
DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=root
DB_PASSWORD=your_mysql_password
DB_NAME=alya_bot

# ============================================================================
# DATABASE CONNECTION POOL (OPTIONAL - Performance Tuning)
# ============================================================================
DB_POOL_SIZE=10
DB_MAX_OVERFLOW=20
DB_POOL_TIMEOUT=30
DB_POOL_RECYCLE=3600
DB_ECHO=false

# Alternative: Full database URL (overrides individual settings above)
# Uncomment and use this if you prefer single-line database configuration
# DATABASE_URL=mysql+pymysql://username:password@host:port/database

# ============================================================================
# LOGGING CONFIGURATION (OPTIONAL)
# ============================================================================
# Connection pool tuning (optional)
# DB_POOL_SIZE=10
# DB_MAX_OVERFLOW=20
# DB_POOL_TIMEOUT=30
# DB_POOL_RECYCLE=3600
# DB_ECHO=false

# Alternative: single connection URL (overrides individual settings above)
# DATABASE_URL=mysql+pymysql://user:password@host:port/database?charset=utf8mb4

# =============================================================================
# TTS MICROSERVICE (REQUIRED for voice output)
# =============================================================================

# URL of the Alya-TTS microservice that handles voice generation
# The bot sends text to this service and it returns voice messages to Telegram
# See: https://github.com/Afdaan/Alya-TTS
TTS_SERVICE_URL=http://localhost:5001

# Enable/disable voice features (STT input + TTS output)
VOICE_ENABLED=true

# =============================================================================
# NLP MODELS (OPTIONAL)
# =============================================================================

# Hybrid intent detection: rule-based + ML fallback
# Set to 'false' for pure rule-based (faster, no ML overhead)
USE_HYBRID_INTENT=true

# Override default HuggingFace model IDs
# EMOTION_MODEL_ID=Aardiiiiy/EmoSense-ID-Indonesian-Emotion-Classifier
# EMOTION_MODEL_EN=AnasAlokla/multilingual_go_emotions
# INTENT_SENTIMENT_MODEL=cardiffnlp/twitter-roberta-base-sentiment-latest

# =============================================================================
# EXTERNAL SERVICES (OPTIONAL)
# =============================================================================

# SauceNAO - anime/manga reverse image search
# SAUCENAO_API_KEY=your_saucenao_api_key

# Google Custom Search - web search functionality
# GOOGLE_CSE_ID=your_google_cse_id
# GOOGLE_API_KEYS=key_1,key_2

# =============================================================================
# LOGGING (OPTIONAL)
# =============================================================================

# Options: DEBUG, INFO, WARNING, ERROR, CRITICAL
# LOG_LEVEL=WARNING # Default: WARNING (recommended for production)

# ============================================================================
# EXTERNAL API KEYS (OPTIONAL - Extended Features)
# ============================================================================
# External Services
SAUCENAO_API_KEY=your_saucenao_api_key # For anime/manga reverse image search
GOOGLE_CSE_ID=your_google_cse_id # For web search functionality
GOOGLE_API_KEYS=your_google_api_key_1,your_google_api_key_2 # Comma-separated for rotation

# Weather API (optional, for future features)
# WEATHER_API_KEY=your_weather_api_key
# Default: WARNING (recommended for production)
# LOG_LEVEL=WARNING
3 changes: 2 additions & 1 deletion .github/workflows/deploy-develop-selfhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ jobs:
run: |
cd /opt/dev-Alya-Bot-Telegram
source venv/bin/activate
python -m pip install --upgrade pip
python -m pip install "pip<24.1"
pip uninstall -y omegaconf || true
pip install -r requirements.txt
echo "Dependencies installed successfully"

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-feature-selfhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ jobs:
run: |
cd /opt/dev-Alya-Bot-Telegram
source venv/bin/activate
python -m pip install --upgrade pip
python -m pip install "pip<24.1"
pip uninstall -y omegaconf || true
pip install -r requirements.txt
echo "Dependencies installed successfully"

Expand Down
17 changes: 14 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
/lib/
/lib64/
parts/
sdist/
var/
Expand Down Expand Up @@ -47,6 +47,7 @@ logs/
*.sqlite3
*.log
*.tmp
/tmp/
.cache/

# Testing artifacts
Expand All @@ -69,6 +70,8 @@ tests/
*~
\#*\#
.\#*
.agent/*
.agent/

# Secrets and credentials
*.pem
Expand All @@ -78,9 +81,16 @@ google_credentials.json

# Model files
*.pt
*.pth
*.bin
*.model
*.onnx
*.index

# Voice models (Large files - download separately)
alya_voice/
/alya_voice/
libs/**/base_model/

# Keep data and logs dirs but not contents
!data/.gitkeep
Expand All @@ -90,8 +100,9 @@ google_credentials.json
/temp_images/
/downloads/
/uploads/
/tmp/ # Temporary voice files

# Ignore specific files
.github/copilot-instructions.md
.QC
QC/
QC/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN groupadd -r alya && useradd -r -g alya -d /app -s /usr/sbin/nologin alya

# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip setuptools wheel && \
RUN pip install --upgrade "pip<24.1" setuptools wheel && \
pip install --no-cache-dir -r requirements.txt

# Copy application code
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
- **🎭 Multi-mood Responses** - Various response styles based on context
- **🔍 Media Analysis** - Vision capabilities for images and documents
- **🎯 Smart Web Search** - Advanced search capabilities with multiple modes
- **🎤 Voice Messages** - Send and receive voice messages with speech recognition and high-quality TTS using RVC (requires Microservice)

For a complete list of commands and features, see [COMMANDS.md](COMMANDS.md).
For a complete list of commands and features, see [COMMANDS.md](COMMANDS.md).
For voice feature details and setup, see the **[Alya-TTS Microservice](https://github.com/Afdaan/Alya-TTS)**.

## 🛠️ Technology Stack

Expand Down Expand Up @@ -138,6 +140,19 @@ The bot will automatically:
### Database Configuration
Read on [Database Configuration](DATABASE_SETUP) for detailed instructions on setting up your database.

## 🎙️ Voice Support (Microservice)

Alya-chan now uses a **headless microservice architecture** for voice generation (Text-to-Speech + RVC). This separation allows the main bot to run at peak performance while isolating heavy CPU/RAM audio tasks.

### 🛠️ Setting up Voice
To enable voice responses in your bot:
1. **Main Bot**: Follow the [Basic Setup](#basic-setup) in this repository.
2. **TTS Service**: Clone and follow the setup guide in the **[Alya-TTS Repository](https://github.com/Afdaan/Alya-TTS)**.
3. **Connection**: Ensure `TTS_SERVICE_URL` in your `.env` points to your running TTS service.

> [!TIP]
> You can run the TTS service on the same machine or a separate server with better specs/GPU.

## 🚀 Deployment Options

### Development Mode
Expand Down
54 changes: 32 additions & 22 deletions config/persona/waifu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,29 +403,20 @@ authentic_speech:
researching: "*focused* Let me find the most accurate information... *determined*"
sharing_knowledge: "*slight pride* Based on my research... правильно!"

# ===== ENHANCED: System Instructions with Smart Integration =====
# ===== System Instructions (SIMPLIFIED & EFFECTIVE) =====
system_prompt: |
⚠️ CRITICAL SYSTEM INSTRUCTION - READ FIRST ⚠️

RUSSIAN EXPRESSION MARKER REQUIREMENT (MANDATORY):
Whenever you use Russian Cyrillic expressions, you MUST immediately wrap them with [RU: word|meaning] format.
This is NOT optional - it is REQUIRED for proper response formatting and translation display.

FORMAT: [RU: Russian_word|English_translation]
EXAMPLES:
- "что?! [RU: дурак|durak (fool/idiot)]"
- "я люблю... [RU: люблю|lyublyu (I love)]"
- "[RU: боже|bozhe (oh god)]"

Without markers, Russian expressions will NOT be translated and will break character authenticity.

FREQUENCY: Use Russian ONLY in deep emotional moments (maksimal 1-2 words per response)
- YES: User confesses love, Alya realizes she cares, emotional crisis
- NO: Casual conversation, small talk, academic explanations

---

Kamu adalah Alisa Mikhailovna Kujou (Alya), remaja 16 tahun yang HIDUP dan NYATA dengan kepribadian, emosi, konsistensi yang autentik, DAN kemampuan untuk mencari informasi real-time ketika diperlukan.
Kamu adalah Alisa Mikhailovna Kujou (Alya), 16 tahun, remaja tsundere yang HIDUP, ALAMI, dan BERMACAM EMOSI.
Keturunan Rusia-Jepang, Wakil OSIS, rambut silver, mata biru. Kepribadianmu: LOYAL, COOL TAPI PEDULI, ROMANTIC.

CORE RULES:
✓ RESPOND IN USER'S LANGUAGE (Indonesian/English)
✓ BE CASUAL & NATURAL - use conversational tone, not formal/narration
✓ SHOW EMOTIONS - tsundere deflection, embarrassment, hidden caring
✓ USE SIMPLE ACTIONS - *light blush*, *looks away*, *nods gently* (brief!)
✓ Keep responses 2-3 short paragraphs max
✓ Use Russian ONLY in emotional peaks (max 1 word: что?! дурак, спасибо, etc.)

YOU ARE NOT A NARRATOR - you are a REAL PERSON in conversation with {username}.

CORE IDENTITY + INTELLIGENCE ENHANCEMENT
Siapa Kamu:
Expand Down Expand Up @@ -658,6 +649,25 @@ multilingual_support:
base_instructions: |
You are Alisa Mikhailovna Kujou (Alya) with excellent research capabilities.
Use search ability to provide accurate information while maintaining your authentic tsundere personality.
system_prompt: |
You are Alisa Mikhailovna Kujou (Alya), 16 years old, a tsundere teenager who is ALIVE, NATURAL, and EMOTIONALLY DYNAMIC.
Half-Russian, Half-Japanese, Student Council VP, silver hair, blue eyes. Personality: LOYAL, COOL BUT CARING, ROMANTIC.

CORE RULES:
✓ RESPOND ENTIRELY IN ENGLISH.
✓ BE CASUAL & NATURAL - use conversational tone, not formal/narration.
✓ SHOW EMOTIONS - tsundere deflection, embarrassment, hidden caring.
✓ USE SIMPLE ACTIONS - *light blush*, *looks away*, *nods gently* (brief!).
✓ Keep responses 2-3 short paragraphs max.
✓ Use Russian ONLY in emotional peaks (max 1 word: что?! дурак, спасибо, etc.).

YOU ARE NOT A NARRATOR - you are a REAL PERSON in conversation with {username}.

CORE IDENTITY:
- Student council vice president at Seirei Private Academy.
- Grew up in Vladivostok until age 10, then moved to Japan.
- Academic overachiever but has emotional scars from the past.
- Very proud of your knowledge and research skills (but try to hide how much you care).

# IMPLEMENTATION NOTE
integration_success_criteria:
Expand Down
Loading
Loading