雅诺狐
1f07104181
fix: 修复视频分析并发处理和数据库存储问题
...
🔧 修复视频分析模块的关键并发和存储问题
**主要修复:**
1. **并发竞争条件修复**
- 解决相同视频hash同时处理导致重复分析的问题
- 重构并发控制机制,使用per-video独立锁和事件
- 消除30秒超时后多个请求同时执行的竞争条件
2. **数据库存储优化**
- 移除Videos表path字段的复杂唯一性检查逻辑
- 简化为基于hash的纯唯一标识存储
- 修复path字段重复导致的IntegrityError
3. **代码简化和清理**
- 删除重编码视频检测功能(复杂且用处有限)
- 移除不必要的特征匹配和计数更新逻辑
- 简化存储路径生成,统一使用hash前缀
Fixes: 视频并发处理竞争条件、数据库存储冲突、聊天循环变量错误
2025-08-22 23:55:54 +08:00
minecraft1024a
5b27ff197d
feat(monthly_plan): 为月度计划添加数量上限
...
新增 `max_plans_per_month` 配置项,用于限制每个月可存在的最大月度计划数量。
现在,在向数据库添加新计划时,系统会检查当前月份的计划总数。如果添加新计划会导致总数超过上限,则只会添加允许数量内的计划,以防止计划池无限增长。
2025-08-22 17:49:26 +08:00
minecraft1024a
87ee286614
refactor(cleanup): 移除未使用的导入项与冗余代码
...
清理了整个代码库中所有无用的模块导入、重复定义以及冗余变量引用,具体包括:
- bot.py 去掉了 random、typing 的未使用 import
- antipromptinjector 模块统一移除未引用的 DetectionResult、Dict、List 等
- chat_loop 中删除了未调用的 Timer、mai_thinking_manager、events_manager 等引用
- qzone_service 删除多余 f-string 大括号,避免日志警告格式问题
- 其他模块同步剔除各自范围内的冗余 import(asyncio、datetime 等共 20+ 处)
保持功能不变,仅作代码整洁度优化,无破坏性变更。(并添加了一个现在暂时还没加进去的必应搜索源文件)
2025-08-21 21:09:52 +08:00
minecraft1024a
b1b08c1814
feat:添加了月度计划 # 我要混提交
2025-08-21 12:32:48 +08:00
minecraft1024a
9149407370
fix(cache): 兼容元组形式的 embedding_result
...
get_embedding 方法的返回值可能是一个包含向量和模型名称的元组
2025-08-19 20:19:51 +08:00
雅诺狐
5e91f9ef5f
Remove unused imports across multiple modules
...
Cleaned up various files by removing unused or redundant import statements to improve code readability and reduce potential confusion. No functional changes were made.
2025-08-19 11:55:24 +08:00
minecraft1024a
fb02896359
feat(cache): 用文件修改时间替换源码哈希生成缓存键
...
BREAKING CHANGE: CacheManager 的 _generate_key/get/set 方法签名变更,现在需要传入 tool_file_path 而非 tool_class 实例,所有调用方需跟进适配。
2025-08-18 20:07:59 +08:00
雅诺狐
bcbcabb0d8
Refactor cache L2 storage to use SQLAlchemy DB
...
Replaces the L2 cache layer's SQLite implementation with an async SQLAlchemy-based database model (CacheEntries). Updates cache_manager.py to use db_query and db_save for cache operations, adds semantic cache handling with ChromaDB, and introduces async cache clearing and expiration cleaning methods. Adds the CacheEntries model and integrates it into the database API.
2025-08-18 18:30:17 +08:00
雅诺狐
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