Skip to content

spcookie/Erii

Repository files navigation


πŸ“– Overview

Erii is an AI group chat bot system based on a multi-dimensional psychological model. Unlike traditional Q&A bots, Erii has an emotion system, long-term memory, conversation flow and proactive behaviors, enabling it to participate in group chats like a real person, interjecting, breaking the ice, and adjusting speaking style based on emotional state.

✨ Core Features:

  • 🎭 Emotion System: Based on PAD model, simulating real emotional responses
  • 🧠 Long-term Memory: Multi-dimensional recording of user profiles, preferences, and group chat facts
  • 🌊 Flow Mechanism: Dynamically adjusts participation depth based on topic engagement
  • ⚑ Proactive Behaviors: Initiates conversations based on impulse values for ice-breaking and daily interactions

πŸš€ Features

🧠 Core Systems

🎭 Emotion System (Emotion)

  • PAD Three-Dimensional Emotion Model - Pleasure, Arousal, Dominance
  • Dynamic Emotion Regulation - Real-time emotional state adjustment based on conversation content
  • Emotional Expression - Affects reply tone, emoji usage, reply delay
  • Long-term Mood - Maintains baseline mood tone, influencing overall behavioral tendencies

πŸ’Ύ Memory System (Memory)

  • Multi-dimensional Memory - User profiles, preference settings, factual knowledge, conversation summaries
  • Three-level Scope - Global memory, group memory, member-group memory
  • Semantic Retrieval - Intelligent memory recall based on vector similarity
  • LLM-driven - AI automatically extracts and manages long-term memory

🌊 Flow System (Flow)

  • Engagement Quantification - 0-100 flow value, three-stage state machine
  • Topic Matching - Quickly enters flow state when encountering interesting topics
  • Focus Mechanism - Locks onto conversation goals during high flow, filtering irrelevant distractions
  • Overheat Protection - Simulates fatigue to prevent excessive output

⚑ Volition System (Volition)

  • Impulse Calculation - Calculates desire to speak proactively based on emotion, flow, and keywords
  • Three Interjection Modes - Interrupt, Icebreak, Routine
  • Social Awareness - Detects serious topics and group emotions to avoid inappropriate comments
  • Fatigue Suppression - Accumulates fatigue after proactive speaking to prevent spamming

🧬 Evolution System (Evolution)

  • Vocabulary Learning - Automatically learns new words and memes from group chats
  • Semantic Understanding - Records word meanings, usage scenarios, and tones
  • Natural Integration - Naturally uses learned group chat expressions in appropriate scenarios

🎭 Meme System (Meme)

  • Meme Extraction - Automatically extracts trending phrases and memes from group chats
  • Vector Storage - Semantic vector representation, supporting similarity retrieval
  • Popularity Tracking - Tracks usage frequency and popularity of high-frequency words

πŸ”Œ Built-in Plugins

Plugin Type Description
speech AgentExtension Text-to-speech plugin using MiniMax TTS
lolisuki RouteExtension Anime image plugin from lolisuki.cn
net-ease-music PassiveExtension NetEase music plugin for music cards
qa RouteExtension AI Q&A plugin with web search
qq-face PassiveExtension QQ emoji semantic matching plugin
reminder AgentExtension Scheduled reminder plugin
seeddream RouteExtension AI image generation plugin

πŸ’¬ Conversation Enhancement

  • Context Understanding - References historical conversations and long-term memory
  • Multiple Personas - Supports multiple bot role configurations
  • Emotional Resonance - Perceives group atmosphere, adjusts participation style

🏁 Getting Started

πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

  • JDK 17+
  • Gradle 8.0+
  • NapCat - QQ integration service
  • LLM API Key - Google Gemini / DeepSeek / MiniMax API

βš™οΈ Installation & Configuration

  1. Clone the repository

    git clone https://github.com/spcookie/Erii.git
    cd Erii
  2. Configure environment variables Copy and edit the environment template:

    cp .env.local.template .env.local
    nano .env.local

    Main configuration items:

    • CHOICE_MODEL: Select LLM provider (GOOGLE / DEEP_SEEK / MINIMAX)
    • Corresponding API Key configuration
    • NAPCAT_TOKEN: NapCat authentication token
    • ENABLE_GROUPS: List of enabled groups
  3. Configure the bot Copy and edit the configuration template:

    cp application.conf.template application.conf
    nano application.conf

    Main configuration items:

    • llm.choice-model: Select LLM provider (GOOGLE / DEEP_SEEK / MINIMAX)
    • onebot.bots: QQ bot connection information
    • groups.enable-groups: List of enabled groups
  4. Start the development server

    ./gradlew run

🐳 Docker Deployment

Start Erii main service

docker-compose up -d

Start NapCat QQ integration service

cd docker/napcat-docker && docker-compose up -d

Start Playwright browser service

cd docker/playwright-docker && docker-compose up -d

πŸ› οΈ Tech Stack

πŸ–₯️ Backend Framework

  • Language: Kotlin 1.9+
  • Web Framework: Ktor 2.3+
  • Build Tool: Gradle 8.0+
  • Database: H2 (Embedded)
  • ORM: Exposed
  • Dependency Injection: Koin
  • Task Scheduling: JobRunr

πŸ€– Bot Integration

  • Bot Framework: Mirai + Overflow
  • Integration Service: NapCat (WebSocket)
  • LLM: Google Gemini API / OpenAI Compatible API

πŸ”Œ Extension Architecture

  • Plugin Framework: PF4J
  • SPI Interface: erii-spi module defines extension points

πŸ“¦ Building & Running

Command Description
./gradlew compileKotlin Compile Kotlin code
./gradlew build Build the entire project
./gradlew run Start development server
./gradlew buildFatJar Build fat JAR with all deps
./gradlew buildImage Build Docker image
./gradlew test Run all tests

πŸ“‚ Project Structure

Erii/
β”œβ”€β”€ erii-common/                 # πŸ“¦ Common module
β”‚   └── src/main/kotlin/uesugi/common/
β”‚       β”œβ”€β”€ EventBus.kt          # Async/sync event bus
β”‚       β”œβ”€β”€ BotRole.kt           # Bot role definitions
β”‚       β”œβ”€β”€ ChatToolSet.kt       # Chat toolset
β”‚       └── ...
β”œβ”€β”€ erii-core/                   # 🧠 Core module
β”‚   └── src/main/kotlin/uesugi/
β”‚       β”œβ”€β”€ Application.kt       # Ktor application entry
β”‚       β”œβ”€β”€ config/              # Configuration and DI
β”‚       β”‚   β”œβ”€β”€ IOC.kt          # Koin DI configuration
β”‚       β”‚   β”œβ”€β”€ LLMFactory.kt   # LLM factory
β”‚       β”‚   └── ...
β”‚       β”œβ”€β”€ core/
β”‚       β”‚   β”œβ”€β”€ agent/          # AI Agent
β”‚       β”‚   β”‚   └── BotAgent.kt  # Core AI Agent
β”‚       β”‚   β”œβ”€β”€ route/          # Routing system
β”‚       β”‚   β”‚   └── RoutingAgent.kt  # LLM routing
β”‚       β”‚   β”œβ”€β”€ state/          # Core AI state systems
β”‚       β”‚   β”‚   β”œβ”€β”€ emotion/     # Emotion system
β”‚       β”‚   β”‚   β”œβ”€β”€ memory/      # Memory system
β”‚       β”‚   β”‚   β”œβ”€β”€ flow/        # Flow system
β”‚       β”‚   β”‚   β”œβ”€β”€ volition/    # Volition system
β”‚       β”‚   β”‚   β”œβ”€β”€ evolution/   # Evolution system
β”‚       β”‚   β”‚   └── meme/        # Meme system
β”‚       β”‚   β”œβ”€β”€ bot/            # Bot role management
β”‚       β”‚   β”‚   └── BotRoleManager.kt
β”‚       β”‚   β”œβ”€β”€ message/        # Message handling
β”‚       β”‚   β”‚   └── history/    # History service
β”‚       β”‚   β”œβ”€β”€ plugin/         # Plugin implementations
β”‚       β”‚   β”œβ”€β”€ rule/           # Rule engine
β”‚       β”‚   └── component/      # Components
β”‚       β”‚       β”œβ”€β”€ browser/   # Browser (screenshot/markdown fetching)
β”‚       β”‚       β”œβ”€β”€ embedding/  # Vector embedding
β”‚       β”‚       β”œβ”€β”€ search/     # Search service
β”‚       β”‚       └── storage/    # Storage (vector/object)
β”‚       └── server/             # HTTP API routes
β”œβ”€β”€ erii-spi/                    # πŸ”Œ SPI interface module
β”‚   └── src/main/kotlin/uesugi/spi/
β”‚       β”œβ”€β”€ AgentExtension.kt   # Agent extension interface
β”‚       β”œβ”€β”€ PluginDefinition.kt # Plugin definition annotation
β”‚       └── processor/           # Annotation processor
β”œβ”€β”€ erii-plugins/                # 🎨 Plugin modules
β”‚   β”œβ”€β”€ speech/                  # MiniMax TTS
β”‚   β”œβ”€β”€ lolisuki/                # Anime images
β”‚   β”œβ”€β”€ net-ease-music/          # NetEase music search & cards
β”‚   β”œβ”€β”€ qa/                      # AI web search Q&A
β”‚   β”œβ”€β”€ qq-face/                 # QQ emoji semantic matching
β”‚   β”œβ”€β”€ reminder/                # Scheduled reminders & delayed messages
β”‚   └── seeddream/               # AI image generation
└── build.gradle.kts             # Root build configuration

πŸ—ΊοΈ Architecture

Erii uses an event-driven architecture with EventBus for system decoupling.

Message Received (NapCat/Mirai)
       β”‚
       β–Ό
GroupMessageEventListener
       β”‚
       β–Ό
HistoryService (Save History)
       β”‚
       β–Ό
RoutingAgent (LLM Intent Classification) / CmdRuleRegister (Command Matching)
       β”‚
       β–Ό
RouteCallEvent (Dispatched via EventBus.postAsync)
       β”‚
       β–Ό
BotAgent (Consumes events, executes AI Agent)
       β”‚
       β–Ό
State Updates (Emotion, Memory, Flow, Volition, Evolution, Meme)

Plugin Extension Points

Extension Type Description Matching Method
AgentExtension General Agent extension Combined usage
RouteExtension LLM routing extension RoutingAgent intent classification
CmdExtension Command extension /xxx command matching
PassiveExtension Passive extension Background tasks/event listeners

πŸ“„ License

This project is open source under the MIT license.

Repobeats

Alt

Star History

Star History Chart

About

An AI group chat robot with emotions, memory, flow, and proactive behavior.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors