Refactor configuration and enhance AI capabilities
Updated .env.example to improve clarity and added new configuration options for memory and reliability settings. Refactored main.py to streamline the bot's entry point and improved error handling. Enhanced README to reflect new features and command structure. Removed deprecated cmd_zip_skill and skills_creator modules to clean up the codebase. Updated AIClient and MemorySystem for better performance and flexibility in handling user interactions.
This commit is contained in:
131
README.md
131
README.md
@@ -1,14 +1,16 @@
|
||||
# QQbot(AI 聊天机器人)
|
||||
# QQbot (Memory + Persona Core)
|
||||
|
||||
一个基于 `botpy` 的 QQ 机器人项目,支持多模型切换、长期/短期记忆、人设管理、Skills 插件与 MCP 能力。
|
||||
QQ 机器人项目,保留并强化两大核心能力:
|
||||
- `Memory`:短期/长期记忆、检索、清理、会话作用域
|
||||
- `Persona`:角色配置、作用域优先级(session > group > user > global)
|
||||
|
||||
## 功能概览
|
||||
## 主要能力
|
||||
|
||||
- 多模型配置与运行时切换(`/models`)
|
||||
- 人设增删改切换(`/personality`)
|
||||
- 短期/长期记忆管理(`/clear`、`/memory`)
|
||||
- Skills 本地与网络安装/卸载/重载(`/skills`)
|
||||
- 自动去除 Markdown 格式后再回复(适配 QQ 聊天)
|
||||
- 多模型配置与运行时切换:`/models`
|
||||
- 人设管理:`/personality`
|
||||
- 记忆管理:`/memory`、`/clear`
|
||||
- QQ 消息安全输出:自动清理 Markdown/URL
|
||||
- 工程增强:消息去重、失败重试、权限边界、结构化日志
|
||||
|
||||
## 快速开始
|
||||
|
||||
@@ -20,7 +22,9 @@ pip install -r requirements.txt
|
||||
|
||||
2. 配置环境变量
|
||||
|
||||
复制 `.env.example` 为 `.env`,填写 QQ 机器人和 AI 配置。
|
||||
```bash
|
||||
copy .env.example .env
|
||||
```
|
||||
|
||||
3. 启动
|
||||
|
||||
@@ -28,89 +32,42 @@ pip install -r requirements.txt
|
||||
python main.py
|
||||
```
|
||||
|
||||
## 命令说明
|
||||
## 命令
|
||||
|
||||
### 通用
|
||||
- 基础
|
||||
- `/help`
|
||||
- `/clear` `/clear short` `/clear long` `/clear all`
|
||||
- 人设
|
||||
- `/personality`
|
||||
- `/personality list`
|
||||
- `/personality set <key> [global|user|group|session]`
|
||||
- `/personality add <name> <Introduction>`
|
||||
- `/personality remove <key>`
|
||||
- 模型
|
||||
- `/models`
|
||||
- `/models current`
|
||||
- `/models add <model_name>`
|
||||
- `/models add <key> <provider> <model_name> [api_base]`
|
||||
- `/models switch <key|index>`
|
||||
- `/models remove <key|index>`
|
||||
- 记忆
|
||||
- `/memory`
|
||||
- `/memory get <id>`
|
||||
- `/memory add <content|json>`
|
||||
- `/memory update <id> <content|json>`
|
||||
- `/memory delete <id>`
|
||||
- `/memory search <query> [limit]`
|
||||
|
||||
- `/help`
|
||||
- `/clear`(默认等价 `/clear short`)
|
||||
- `/clear short`
|
||||
- `/clear long`
|
||||
- `/clear all`
|
||||
## 关键配置
|
||||
|
||||
### 人设命令
|
||||
|
||||
- `/personality`
|
||||
- `/personality list`
|
||||
- `/personality set <key>`
|
||||
- `/personality add <name> <Introduction>`
|
||||
- `/personality remove <key>`
|
||||
|
||||
说明:
|
||||
- `add` 会新增并切换到该人设
|
||||
- `Introduction` 会作为人设简介与自定义指令
|
||||
|
||||
### Skills 命令
|
||||
|
||||
- `/skills`
|
||||
- `/skills install <source> [skill_name]`
|
||||
- `/skills uninstall <skill_name>`
|
||||
- `/skills reload <skill_name>`
|
||||
|
||||
`source` 支持:
|
||||
- 本地技能名(如 `weather`)
|
||||
- URL(zip 包)
|
||||
- GitHub 简写(`owner/repo` 或 `owner/repo#branch`)
|
||||
- GitHub 仓库 URL(如 `https://github.com/op7418/Humanizer-zh.git`)
|
||||
|
||||
兼容说明:
|
||||
- 若源中包含标准技能结构(`skill.json` + `main.py`),按原方式安装
|
||||
- 若仅包含 `SKILL.md`,会自动生成适配技能并提供 `read_skill_doc` 工具读取文档内容
|
||||
|
||||
### 模型命令
|
||||
|
||||
- `/models`
|
||||
- `/models current`
|
||||
- `/models add <model_name>`
|
||||
- `/models add <key> <provider> <model_name> [api_base]`
|
||||
- `/models switch <key|index>`
|
||||
- `/models remove <key|index>`
|
||||
|
||||
说明:
|
||||
- `/models add <model_name>` 只替换模型名,沿用当前 API Base 和 API Key
|
||||
|
||||
### 长期记忆命令
|
||||
|
||||
- `/memory`
|
||||
- `/memory get <id>`
|
||||
- `/memory add <content|json>`
|
||||
- `/memory update <id> <content|json>`
|
||||
- `/memory delete <id>`
|
||||
- `/memory search <query> [limit]`
|
||||
|
||||
## 目录结构
|
||||
|
||||
```text
|
||||
QQbot/
|
||||
├─ src/
|
||||
│ ├─ ai/
|
||||
│ ├─ handlers/
|
||||
│ ├─ core/
|
||||
│ └─ utils/
|
||||
├─ skills/
|
||||
├─ config/
|
||||
├─ docs/
|
||||
└─ tests/
|
||||
```
|
||||
- `AI_MEMORY_SCOPE=user|session`:记忆作用域
|
||||
- `BOT_ADMIN_IDS`:管理员白名单(逗号分隔)
|
||||
- `AI_CHAT_RETRIES` / `AI_CHAT_RETRY_BACKOFF_SECONDS`:聊天失败重试
|
||||
- `MESSAGE_DEDUP_SECONDS` / `MESSAGE_DEDUP_MAX_SIZE`:消息去重窗口
|
||||
- `LOG_FORMAT=text|json`:日志输出格式
|
||||
|
||||
## 测试
|
||||
|
||||
```bash
|
||||
python -m pytest -q
|
||||
```
|
||||
|
||||
如果你使用 conda 环境,请先执行:
|
||||
|
||||
```bash
|
||||
conda activate qqbot
|
||||
pytest -q
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user