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.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors