Commit Graph

76 Commits

Author SHA1 Message Date
雅诺狐
f3958ef484 Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-18 17:29:32 +08:00
雅诺狐
689aface9d Add LLM anti-prompt injection system
Introduces a comprehensive anti-prompt injection system for LLMs, including rule-based and LLM-based detection, user ban/whitelist management, message shielding, and statistics tracking. Adds new modules under src/chat/antipromptinjector, integrates anti-injection checks into the message receive flow, updates configuration and database models, and provides test scripts. Also updates templates and logger aliases to support the new system.
2025-08-18 17:27:59 +08:00
minecraft1024a
c47d666d07 chore(deps): 移除未使用的 ModelTaskConfig 导入
从 cache_manager.py 文件中删除了对 `src.config.api_ada_configs` 中 `ModelTaskConfig` 的导入,因为它在该文件中并未被使用。

添加了记忆系统的大饼

Co-authored-by: 雅诺狐 <foxcyber907@users.noreply.github.com>
2025-08-18 11:54:00 +08:00
minecraft1024a
51c0d2a1e8 refactor(cache): 重构缓存系统为分层语义缓存
将原有的基于文件的 `ToolCache` 替换为全新的 `CacheManager`,引入了更复杂和高效的分层语义缓存机制。

新系统特性:
- **分层缓存**:
  - L1 缓存: 内存字典 (KV) + FAISS (向量),用于极速访问。
  - L2 缓存: SQLite (KV) + ChromaDB (向量),用于持久化存储。
- **语义缓存**: 利用嵌入模型 (Embedding) 对查询进行向量化,实现基于语义相似度的缓存命中,显著提高了缓存命中率。
- **自动失效**: 缓存键包含工具源代码的哈希值,当工具代码更新时,相关缓存会自动失效,避免了脏数据问题。
- **异步支持**: 缓存的 `get` 和 `set` 方法现在是异步的,以适应项目中异步化的工具调用流程。

`web_search_tool` 已更新以使用新的 `CacheManager`,在调用缓存时传递 `tool_class` 和 `semantic_query` 以充分利用新功能。

Co-Authored-By: tt-P607 <68868379+tt-P607@users.noreply.github.com>
2025-08-17 22:18:26 +08:00
雅诺狐
74ae472005 Add ToolCache class for tool result caching
Introduces a ToolCache class to manage caching of tool invocation results with support for both exact and approximate (similarity-based) query matching. Includes methods for cache retrieval, storage, expiration, cleanup, and statistics. This helps improve efficiency by reusing previous results and reducing redundant tool executions.

Co-Authored-By: tt-P607 <68868379+tt-P607@users.noreply.github.com>
2025-08-17 21:06:25 +08:00
雅诺狐
cb65d91c7a Refactor antiprompt flowchart and fix indentation
Updated the antipromptinjector flowchart for improved clarity and logic. Fixed indentation in expression_selector.py to correct code structure. Removed obsolete db_migration_plan.md documentation.
2025-08-17 20:51:52 +08:00
minecraft1024a
cd3ccba8ad refactor(core): 调整数据库初始化时机
将数据库的初始化、表结构创建和自动迁移逻辑从配置文件加载时移动到主程序 `raw_main` 函数中。

这一改动旨在解决循环导入问题,并确保数据库在所有配置和核心模块加载完毕后才进行初始化,提高了程序的启动鲁棒性和模块独立性。
2025-08-17 15:59:56 +08:00
雅诺狐
9665d83399 Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-17 15:07:56 +08:00
minecraft1024a
f12cc68d04 refactor(db): 使用迁移函数替代 create_all 初始化数据库
将数据库初始化过程从直接调用 `Base.metadata.create_all` 修改为调用新的 `check_and_migrate_database` 函数。

这一更改旨在实现更灵活的数据库模式管理,允许在不丢失现有数据的情况下,自动检查并添加新的列或表,从而增强了数据库迁移的健壮性。
2025-08-17 14:31:58 +08:00
雅诺狐
2b61110dd8 Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-17 14:17:46 +08:00
雅诺狐
78417e254a 移除遥测 2025-08-17 14:17:41 +08:00
Furina-1013-create
c09536bf76 增加videoid修复同一个视频重复识别的问题
ps:通过数据库检查的去重:
视频hash计算:使用SHA256算法计算视频文件的唯一标识
数据库去重检查:在分析前先检查数据库中是否已存在相同hash的视频
结果缓存:将分析结果存储到Videos表中,避免重复分析
2025-08-17 14:00:00 +08:00
minecraft1024a
19f7fa15ac chore(logger): 更新日志模块颜色与别名配置
为多个新模块和重构后的模块添加了对应的日志颜色和别名,以增强日志的可读性和区分度。具体包括:
- SQLAlchemy 相关模块
- OpenAI 和 Gemini 客户端
- 多个插件和管理器
- 重构后的 MaiZone 服务和操作
- 新增的网络工具插件
2025-08-17 12:50:49 +08:00
雅诺狐
d46d689c43 数据库重构 2025-08-16 23:43:45 +08:00
雅诺狐
7dfaf54c9c llm统计记录模型反应时间 2025-08-16 14:26:18 +08:00
雅诺狐
0400804056 移除了MCP 2025-08-14 23:13:11 +08:00
雅诺狐
d5777c2980 添加了MCP SEE支持
能不能用我不知道,先加进来。主要我没有服务,无法测试
2025-08-14 17:22:07 +08:00
雅诺狐
c38be26bbb 添加Unix socket连接方法 2025-08-14 16:37:54 +08:00
minecraft1024a
3129655949 添加日程管理相关模型Schedule和MaiZoneScheduleStatus,并在调度管理器中实现日程处理状态的检查与更新逻辑,优化了基于日程的发送功能。 2025-08-14 15:19:35 +08:00
minecraft1024a
5f7f68f640 重构日程管理模块,将原有的schedule_manager模块迁移至manager目录,并更新相关引用。同时优化了定时任务管理逻辑,确保基于日程的发送功能正常运作,改进了日志记录和活动处理机制(OK兄弟们全体目光向我看齐,看我看我,我是个sb) 2025-08-14 12:40:58 +08:00
minecraft1024a
dcb916e0a3 优化日程管理逻辑,增加日程数据格式验证,处理JSON解析错误,确保日程事件字段完整性,改进日志记录。 2025-08-14 11:27:59 +08:00
minecraft1024a
ed7ae5dca4 只是一个测试提交 2025-08-13 16:19:10 +08:00
minecraft1024a
340570b47f 更新logger.py文件,新增多个模块的颜色和别名映射,优化代码结构以支持API、插件系统、工具和依赖管理等扩展功能(这上了色是真的好看吧) 2025-08-13 13:02:33 +08:00
雅诺狐
fe97d897ef 优化项目结构,格式化代码 2025-08-13 09:49:39 +08:00
minecraft1024a
3bbb6de450 feat: 添加日程管理功能,包括日程模型、配置和初始化逻辑,增强聊天回复中对当前活动的动态反馈。 2025-08-12 16:59:21 +08:00
雅诺狐
2d4745cd58 初始化 2025-08-11 19:34:18 +08:00