|
Create unique AI personalities with custom prompts, display names, and trigger keywords. Switch between personas on the fly. {
"name": "Philosopher",
"display_name": "Сократ",
"triggers": "философия,смысл,почему",
"prompt": "Ты — Сократ..."
} |
Vector-based conversation memory with time-decay weighting. The bot remembers context and uses relevant information. |
|
Whisper-powered voice transcription. Send voice messages and get intelligent responses through your active persona. |
Analyze images, GIFs (3-frame extraction), and video messages. Multimodal understanding through LLaVA/BakLLaVA. |
|
DuckDuckGo integration for real-time information. No API keys required — privacy-focused search. |
40+ prompt injection patterns detection, strike system, adaptive rate limiting, and automatic blocking. |
git clone https://github.com/bobberdolle1/PersonaForge.git && cd PersonaForge && cp .env.example .envTELOXIDE_TOKEN=your_bot_token_here
OWNER_ID=your_telegram_id
DATABASE_URL=sqlite:persona_forge.db
OLLAMA_CHAT_MODEL=llama3.2|
Cargo cargo run --release |
Docker docker-compose up --build |
graph TB
subgraph Telegram
TG[Telegram API]
end
subgraph PersonaForge
BOT[🤖 Bot Handlers]
WEB[🌐 Mini App]
SEC[🛡️ Security]
RAG[🧠 RAG Engine]
DB[(💾 SQLite)]
end
subgraph External
OLL[🦙 Ollama]
WHI[🎤 Whisper]
DDG[🔍 DuckDuckGo]
end
TG <--> BOT
TG <--> WEB
BOT --> SEC
BOT --> RAG
BOT <--> DB
RAG <--> DB
BOT <--> OLL
BOT <--> WHI
BOT <--> DDG
WEB <--> DB
style BOT fill:#6C63FF,color:#fff
style RAG fill:#00D9FF,color:#000
style SEC fill:#FF6B6B,color:#fff
style DB fill:#4CAF50,color:#fff
📁 Project Structure
src/
├── main.rs # Entry point, dispatcher setup
├── config.rs # Environment configuration
├── state.rs # Shared state (AppState)
├── logging.rs # Colored logging system
│
├── bot/handlers/
│ ├── commands.rs # /menu, /status, /create_persona...
│ ├── messages.rs # Message processing, RAG retrieval
│ └── callbacks.rs # Inline keyboard handlers
│
├── db/ # SQLx queries
├── llm/ # Ollama client
├── security/ # Prompt injection protection
├── voice/ # Whisper integration
├── web/ # DuckDuckGo search
└── webapp/ # Mini App (Axum + embedded frontend)
| Command | Description |
|---|---|
/menu |
🎛️ Interactive main menu |
/status |
📊 System status (Ollama, DB, queue) |
/create_persona name|prompt |
🎭 Create new persona |
/list_personas |
📋 List all personas |
/activate_persona ID |
✅ Activate persona |
/set_model name |
🧠 Change LLM model |
/set_temperature 0.7 |
🌡️ Set temperature |
/triggers word1, word2 |
🎯 Set trigger keywords |
/enable_rag / /disable_rag |
🧠 Toggle RAG memory |
/block user_id [min] |
🚫 Block user |
/whoami |
👤 What bot knows about you |
| 📊 Status Real-time monitoring |
🎭 Personas Create & manage |
💬 Chats Settings per chat |
🛡️ Security Block & monitor |
⚙️ Config Runtime settings |
🔧 Setup Mini App
- Start HTTPS tunnel:
ssh -R 80:localhost:8080 serveo.net
# or: ngrok http 8080- Create in @BotFather:
/newapp → Select bot → Name: PersonaForge Panel → URL: https://your-url.com
- Add menu button:
/setmenubutton → Select bot → web_app → 🎛️ Panel → URL
📝 Full .env Example
# ═══════════════════════════════════════════════════════════════
# 🤖 TELEGRAM
# ═══════════════════════════════════════════════════════════════
TELOXIDE_TOKEN=your_bot_token
OWNER_ID=123456789
# ═══════════════════════════════════════════════════════════════
# 💾 DATABASE
# ═══════════════════════════════════════════════════════════════
DATABASE_URL=sqlite:persona_forge.db
# ═══════════════════════════════════════════════════════════════
# 🦙 OLLAMA
# ═══════════════════════════════════════════════════════════════
OLLAMA_URL=http://localhost:11434
OLLAMA_CHAT_MODEL=llama3.2
OLLAMA_EMBEDDING_MODEL=nomic-embed-text
OLLAMA_VISION_MODEL=llava
# ═══════════════════════════════════════════════════════════════
# ⚡ GENERATION
# ═══════════════════════════════════════════════════════════════
TEMPERATURE=0.7
MAX_TOKENS=2048
LLM_TIMEOUT_SECONDS=120
# ═══════════════════════════════════════════════════════════════
# 🎛️ FEATURES
# ═══════════════════════════════════════════════════════════════
VISION_ENABLED=true
VOICE_ENABLED=true
WEB_SEARCH_ENABLED=true
# ═══════════════════════════════════════════════════════════════
# 🎤 WHISPER
# ═══════════════════════════════════════════════════════════════
WHISPER_URL=http://localhost:8080/inference
# ═══════════════════════════════════════════════════════════════
# 🧠 RAG
# ═══════════════════════════════════════════════════════════════
RAG_DECAY_RATE=0.1
SUMMARY_THRESHOLD=50
# ═══════════════════════════════════════════════════════════════
# 📊 QUEUE
# ═══════════════════════════════════════════════════════════════
MAX_CONCURRENT_LLM_REQUESTS=3
QUEUE_TIMEOUT_SECONDS=30
# ═══════════════════════════════════════════════════════════════
# 🌐 WEBAPP
# ═══════════════════════════════════════════════════════════════
WEBAPP_PORT=8080|
🧙 Philosopher {
"name": "Сократ",
"triggers": "философия,смысл",
"prompt": "Ты — Сократ. Отвечаешь вопросами, подводя к истине."
} |
🤖 Tech Expert {
"name": "Техник",
"triggers": "код,баг,ошибка",
"prompt": "Ты — senior разработчик. Даёшь чёткие ответы с примерами кода."
} |
|
🎬 Character {
"name": "Чувак",
"triggers": "dude,боулинг",
"prompt": "Ты — The Dude из 'Большой Лебовски'. Расслабленный философ."
} |
👋 Friend {
"name": "Бро",
"triggers": "бро,друг",
"prompt": "Ты — лучший друг. Поддерживаешь, шутишь, общаешься неформально."
} |
╔══════════════════════════════════════════════════════════════╗
║ ██████╗ ███████╗██████╗ ███████╗ ██████╗ ███╗ ██╗ █████╗ ║
║ ██╔══██╗██╔════╝██╔══██╗██╔════╝██╔═══██╗████╗ ██║██╔══██╗║
║ ██████╔╝█████╗ ██████╔╝███████╗██║ ██║██╔██╗ ██║███████║║
║ ██╔═══╝ ██╔══╝ ██╔══██╗╚════██║██║ ██║██║╚██╗██║██╔══██║║
║ ██║ ███████╗██║ ██║███████║╚██████╔╝██║ ╚████║██║ ██║║
║ ╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝║
║ 🤖 F O R G E v1.0.0 ║
╚══════════════════════════════════════════════════════════════╝
┌─ Configuration ─────────────────────────────────────────────┐
│ 🤖 Bot Name │ PersonaForge │
│ 🧠 LLM Model │ llama3.2 │
│ ✓ Vision │ Enabled │
└──────────────────────────────────────────────────────────────┘
✓ Database connected: sqlite:persona_forge.db
✓ Bot identity: MyBot (@my_bot)
✓ WebApp listening on port 8080
🚀 PersonaForge is ready and listening!
12:34:56 INF [messages] 💬 User in -123456: "Привет!"
12:34:57 INF [llm] 🧠 Response in 1234ms (156 chars)
- Fork the repository
- Create your branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'feat: add amazing feature' - Push:
git push origin feature/amazing-feature - Open a Pull Request
📋 Before submitting
cargo fmt # Format code
cargo clippy # Lint
cargo test # Run tests
cargo audit # Security check