Skip to content

bobberdolle1/PersonaForge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Typing SVG

CI Release License

Rust Telegram Ollama SQLite Docker

Stars Forks Issues Last Commit

Wiki Bug Feature Discussions


PersonaForge Demo


Features

🎭 AI Personas

Create unique AI personalities with custom prompts, display names, and trigger keywords. Switch between personas on the fly.

{
  "name": "Philosopher",
  "display_name": "Сократ",
  "triggers": "философия,смысл,почему",
  "prompt": "Ты — Сократ..."
}

🧠 RAG Memory

Vector-based conversation memory with time-decay weighting. The bot remembers context and uses relevant information.

score = similarity × e^(-decay × hours/24)

🎤 Voice Messages

Whisper-powered voice transcription. Send voice messages and get intelligent responses through your active persona.

👁️ Vision & Media

Analyze images, GIFs (3-frame extraction), and video messages. Multimodal understanding through LLaVA/BakLLaVA.

🌐 Web Search

DuckDuckGo integration for real-time information. No API keys required — privacy-focused search.

🛡️ Security

40+ prompt injection patterns detection, strike system, adaptive rate limiting, and automatic blocking.


Quick Start

📋 Prerequisites

⚡ One-liner Install

git clone https://github.com/bobberdolle1/PersonaForge.git && cd PersonaForge && cp .env.example .env

🔧 Configure

TELOXIDE_TOKEN=your_bot_token_here
OWNER_ID=your_telegram_id
DATABASE_URL=sqlite:persona_forge.db
OLLAMA_CHAT_MODEL=llama3.2

🚀 Run

Cargo

cargo run --release

Docker

docker-compose up --build

Architecture

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
Loading
📁 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)

Commands

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

Mini App

📊 Status
Real-time monitoring
🎭 Personas
Create & manage
💬 Chats
Settings per chat
🛡️ Security
Block & monitor
⚙️ Config
Runtime settings
🔧 Setup Mini App
  1. Start HTTPS tunnel:
ssh -R 80:localhost:8080 serveo.net
# or: ngrok http 8080
  1. Create in @BotFather:
/newapp → Select bot → Name: PersonaForge Panel → URL: https://your-url.com
  1. Add menu button:
/setmenubutton → Select bot → web_app → 🎛️ Panel → URL

Configuration

📝 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

Persona Examples

🧙 Philosopher

{
  "name": "Сократ",
  "triggers": "философия,смысл",
  "prompt": "Ты — Сократ. Отвечаешь вопросами, подводя к истине."
}

🤖 Tech Expert

{
  "name": "Техник",
  "triggers": "код,баг,ошибка",
  "prompt": "Ты — senior разработчик. Даёшь чёткие ответы с примерами кода."
}

🎬 Character

{
  "name": "Чувак",
  "triggers": "dude,боулинг",
  "prompt": "Ты — The Dude из 'Большой Лебовски'. Расслабленный философ."
}

👋 Friend

{
  "name": "Бро",
  "triggers": "бро,друг",
  "prompt": "Ты — лучший друг. Поддерживаешь, шутишь, общаешься неформально."
}

Tech Stack

Category Technologies
Language Rust Tokio
Bot Teloxide
Web Axum
Database SQLite SQLx
AI Ollama Whisper
Search DuckDuckGo
Deploy Docker GitHub Actions

Beautiful Logging

╔══════════════════════════════════════════════════════════════╗
║   ██████╗ ███████╗██████╗ ███████╗ ██████╗ ███╗   ██╗ █████╗ ║
║   ██╔══██╗██╔════╝██╔══██╗██╔════╝██╔═══██╗████╗  ██║██╔══██╗║
║   ██████╔╝█████╗  ██████╔╝███████╗██║   ██║██╔██╗ ██║███████║║
║   ██╔═══╝ ██╔══╝  ██╔══██╗╚════██║██║   ██║██║╚██╗██║██╔══██║║
║   ██║     ███████╗██║  ██║███████║╚██████╔╝██║ ╚████║██║  ██║║
║   ╚═╝     ╚══════╝╚═╝  ╚═╝╚══════╝ ╚═════╝ ╚═╝  ╚═══╝╚═╝  ╚═╝║
║              🤖 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)

Contributing

Contributions are welcome! 🎉

PRs Welcome

  1. Fork the repository
  2. Create your branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'feat: add amazing feature'
  4. Push: git push origin feature/amazing-feature
  5. Open a Pull Request
📋 Before submitting
cargo fmt          # Format code
cargo clippy       # Lint
cargo test         # Run tests
cargo audit        # Security check

Support

If you like this project, please give it a ⭐!

Star History Chart


📜 License

This project is licensed under the MIT License


Made with 🦀 Rust and ❤️

About

A Telegram bot with custom AI personalities, long-term memory, and multimodal capabilities.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors