Commit Graph

265 Commits

Author SHA1 Message Date
Windpicker-owo
a187130613 refactor(chat): 简化SmartPrompt系统架构,移除缓存机制和依赖检查 2025-11-19 22:54:35 +08:00
Windpicker-owo
649a010078 refactor(chat): 重构SmartPrompt系统简化架构并移除缓存机制
- 简化SmartPromptParameters类结构,移除复杂的分层参数架构
- 统一错误处理和降级机制,增强系统稳定性
- 移除缓存相关功能,简化架构并减少复杂性
- 完全继承DefaultReplyer功能,确保功能完整性
- 优化性能和依赖管理,改进并发任务处理
- 增强跨群上下文、关系信息、记忆系统等功能的错误处理
- 统一视频分析结果注入逻辑,避免重复代码
2025-11-19 22:54:35 +08:00
Windpicker-owo
e8e401f656 refactor(chat): 重构SmartPrompt系统使用分层参数架构和共享工具
将SmartPrompt系统从平面参数结构重构为分层架构,引入PromptCoreParams、
PromptFeatureParams和PromptContentParams三个层级,提高代码组织性和可维护性。

主要变更:
- 使用新的分层参数结构替代原有的平面参数系统
- 集成PromptUtils共享工具类,消除代码重复
- 添加性能优化:缓存机制、超时控制和性能监控
- 增强错误处理,提供优雅的降级机制
- 添加SmartPromptHealthChecker用于系统健康检查
- 保持向后兼容性,通过属性访问器维持现有API

此重构显著提升了代码的可维护性、性能和可测试性,同时为未来功能
扩展奠定了更好的架构基础。
2025-11-19 22:54:34 +08:00
Windpicker-owo
202a5016b0 feat(chat): 重构SmartPrompt系统完全继承DefaultReplyer功能
完成SmartPrompt系统的全面重构,现已完整继承原有DefaultReplyer的复杂提示构建逻辑:
- 新增SmartPromptParameters涵盖所有必需参数并向后兼容
- 实现s4u/normal/minimal三种模式的完整支持
- 集成原有的表达式习惯、记忆块、关系信息等构建逻辑
- 重构缓存系统使用统一稳定的缓存键机制
- DefaultReplyer现已完整迁移到SmartPrompt架构且零API变更

BREAKING CHANGE: SmartPrompt系统现在完全可用,可以安全替换原有提示构建系统
2025-11-19 22:54:32 +08:00
Windpicker-owo
dfa2d8a438 feat(chat): 引入SmartPrompt智能提示构建系统
重构DefaultReplyer对话提示构建逻辑,统一使用SmartPrompt抽象组件替代原冗长的模板选择与参数拼装流程。将原160+行的分支式模板处理逻辑压缩为统一的SmartPrompt.build_prompt()调用,实现提示构建策略的可插拔与可维护性提升。

- 新增 src.chat.utils.smart_prompt 模块(SmartPrompt类及参数封装)
- 移除旧的normal/s4u分支硬编码,由SmartPrompt内部按需适配
- 事件管理器仅补充HandlerResult显式导入,无功能变动
2025-11-19 22:54:32 +08:00
tt-P607
2a5513b546 feat(video): 引入Python降级抽帧并重构视频分析逻辑
- 当Rust视频处理模块不可用时,自动降级使用基于OpenCV的Python传统抽帧实现,确保视频分析功能在不同环境下均可用。
- 重构`extract_frames`方法,使其能够根据配置的抽帧模式(keyframe, time_interval, fixed_number)和可用的模块(Rust, Python)智能选择最佳的实现路径。
- 增强了初始化检查逻辑,现在会同时检测Rust和OpenCV的可用性,并根据检测结果提供更准确的日志警告或错误信息。
- 更新了`is_video_analysis_available`和`get_video_analysis_status`函数,以准确反映当前可用的视频处理实现和支持的抽帧模式。
2025-11-19 22:54:23 +08:00
Windpicker-owo
a3c07fb0f1 rust_video依赖检测 2025-11-19 22:53:57 +08:00
雅诺狐
0aabd49375 Remove rust-video keyframe extraction API and related files
Deleted the entire src/chat/utils/rust-video directory, including Rust and Python source files, configuration, and documentation. Updated utils_video.py, official_configs.py, and bot_config_template.toml to remove or adjust references to the removed rust-video module. This cleans up the codebase by removing the integrated Rust-based keyframe extraction API and its supporting infrastructure.
2025-11-19 22:50:03 +08:00
Furina-1013-create
b9e8dbcd9f 初步上传基于rust的后端视频关键帧抽帧处理源文件以及readme
但是api还未完成接入
2025-11-19 22:50:03 +08:00
minecraft1024a
d4ba286855 refactor(core): remove tool history manager and integrate cache into tool executor
Removes the `ToolHistoryManager` and its associated functionalities, including history recording, querying, and prompt generation. This simplifies the architecture by decoupling tool execution history from the core logic.

The tool caching mechanism is now directly integrated into the `ToolExecutor` by wrapping the `execute_tool_call` method. This ensures that caching is applied consistently for all tool executions that have it enabled, improving performance and reducing redundant calls.

- Deletes `src/common/tool_history.py`.
- Removes tool history related functions from `prompt_builder.py` and `tool_api.py`.
- Adds a `wrap_tool_executor` function in `cache_manager.py` to apply caching logic directly to the `ToolExecutor`.
2025-11-19 22:49:38 +08:00
minecraft1024a
e7fa3d79ff Reapply "【迁移】工具系统再完善:工具缓存、ttl支持、自动记录、长期保存、自动清理缓存、将记录与执行分离、api记录查询、时间聊天工具筛选查询..."
This reverts commit 3d93bc4079.
2025-11-19 22:48:31 +08:00
tt-P607
700c8dfa6f fix(chat): 处理截断消息时message为None的情况
在 `truncate_message` 函数中,如果传入的 `message` 参数为 `None`,会导致 `len(message)` 抛出 `TypeError`。本次提交增加了对 `None` 值的检查,确保在处理 `None` 时函数能正常返回空字符串,从而提高代码的健壮性。
2025-11-19 22:48:27 +08:00
Windpicker-owo
e068663ef9 Revert "【迁移】工具系统再完善:工具缓存、ttl支持、自动记录、长期保存、自动清理缓存、将记录与执行分离、api记录查询、时间聊天工具筛选查询..."
This reverts commit 80ab0c687c.
2025-11-19 22:48:24 +08:00
Windpicker-owo
adfacd883c 【迁移】工具系统再完善:工具缓存、ttl支持、自动记录、长期保存、自动清理缓存、将记录与执行分离、api记录查询、时间聊天工具筛选查询... 2025-11-19 22:48:23 +08:00
minecraft1024a
dd9aecea14 feat(maizone): 新增QQ空间互通组功能,根据聊天上下文生成说说
引入了全新的“QQ空间互通组”功能。用户可以配置多个群聊为一个互通组。
在通过指令发布说说时,系统会自动获取这些群聊的近期聊天记录作为上下文,从而生成与当前讨论话题更相关的说说内容。

- 在 `config.toml` 中新增了 `[maizone_intercom]` 配置项用于定义互通组。
- 重构并增强了动态(说说)的拉取逻辑,提高了对不同数据格式的兼容性和解析的稳定性。
- 对项目中的多个文件进行了代码清理,移除了未使用的导入,使代码更加整洁。
2025-11-19 22:48:02 +08:00
雅诺狐
ab3a36bfa7 全面更换orjson 2025-11-19 22:47:10 +08:00
Furina-1013-create
613ef82328 这个不会改视频识别的入来优化了一下视频识别的prompt,狐狐大佬补药鞭挞我呜呜呜~
同步改进bot配置文件模板(这回没有忘记改版本号了)
2025-11-19 22:46:37 +08:00
雅诺狐
82f7ae5d73 更新版本号 2025-11-19 22:46:29 +08:00
雅诺狐
c92e2a4230 feat(video): 添加按时间间隔的帧提取模式并重构配置读取逻辑
- 新增 time_interval 帧提取模式,支持按指定时间间隔提取视频帧
- 重构 VideoAnalyzer 初始化代码,使用 getattr 统一获取配置参数
- 简化配置读取逻辑,移除冗余的 try-catch 结构
- 优化 _extract_frames_worker 函数参数,支持新的提取模式配置
2025-11-19 22:46:28 +08:00
雅诺狐
56efa7a462 Delete video_worker.py 2025-11-19 22:46:27 +08:00
雅诺狐
8735bfbc88 feat: 添加视频处理多线程优化和消息切片重组功能
- 新增视频帧提取的线程池支持,提升大视频文件处理性能
- 集成消息切片重组器,支持长消息的自动重组处理
- 优化视频帧提取算法,使用numpy进行数值计算优化
- 重构权限管理插件,修复属性访问和方法签名问题
- 清理未使用的导入和代码,提升代码质量
- 默认启用插件管理功能
2025-11-19 22:46:27 +08:00
tt-P607
89bee8db90 feat(video): 新增按时间间隔抽帧模式
增加了按时间间隔提取视频帧的新模式,与原有的固定总帧数模式并存。用户现在可以通过配置文件选择最适合其需求的抽帧方式。

- 新增 `frame_extraction_mode` 配置项,可选值为 "fixed_number" (固定总帧数) 或 "time_interval" (按时间间隔)。
- 新增 `frame_interval_seconds` 配置项,用于指定时间间隔模式下的抽帧秒数。
- `max_frames` 配置项现在仅在 "fixed_number" 模式下生效。
- 更新了 `VideoAnalyzer` 类以支持两种抽帧逻辑,并从配置中读取新参数。
- 相应地更新了配置文件模板 `bot_config_template.toml`。
2025-11-19 22:46:19 +08:00
雅诺狐
34252ea4a0 refactor: 清理代码质量和移除未使用文件
- 移除未使用的导入语句和变量
- 修复代码风格问题(空格、格式化等)
- 删除备份文件和测试文件
- 改进异常处理链式调用
- 添加权限系统数据库模型和配置
- 更新版本号至6.4.4
- 优化SQL查询使用正确的布尔表达式
2025-11-19 22:46:18 +08:00
雅诺狐
e39c34f366 fix: 修复视频分析并发处理和数据库存储问题
🔧 修复视频分析模块的关键并发和存储问题

**主要修复:**
1. **并发竞争条件修复**
   - 解决相同视频hash同时处理导致重复分析的问题
   - 重构并发控制机制,使用per-video独立锁和事件
   - 消除30秒超时后多个请求同时执行的竞争条件

2. **数据库存储优化**
   - 移除Videos表path字段的复杂唯一性检查逻辑
   - 简化为基于hash的纯唯一标识存储
   - 修复path字段重复导致的IntegrityError

3. **代码简化和清理**
   - 删除重编码视频检测功能(复杂且用处有限)
   - 移除不必要的特征匹配和计数更新逻辑
   - 简化存储路径生成,统一使用hash前缀

Fixes: 视频并发处理竞争条件、数据库存储冲突、聊天循环变量错误
2025-11-19 22:46:11 +08:00
雅诺狐
1b9c86abef Refactor web search plugin and clean up code
Refactored the web search plugin by removing the old Bing search implementation and reorganizing the plugin structure. Introduced modular search engine classes under 'web_search_tool/engines' and utility tools under 'web_search_tool/tools' and 'web_search_tool/utils'. Updated references and initialization logic to support multiple search engines and improved maintainability. Also performed minor code cleanups and replaced 'except ...: pass' with 'except ...: ...' for brevity.
2025-11-19 22:45:42 +08:00
雅诺狐
90f5e2357e Improve anti-injector status handling and statistics
Moved statistics update to only occur when the anti-injector system is enabled. Enhanced statistics reporting to handle disabled state and improved uptime calculation to use session start time. Updated status command to provide clearer feedback when the anti-injector system is disabled or when errors occur. Also fixed a docstring in prompt_builder.py for clarity.
2025-11-19 22:45:03 +08:00
minecraft1024a
a31ee1ab5f refactor(video): update config key from utils_video to video_analysis 2025-11-19 22:44:56 +08:00
minecraft1024a
7d13d0b6c2 fix(embedding): 彻底解决事件循环冲突导致的嵌入生成异常
通过以下改动修复嵌入生成过程中的事件循环相关问题:
- 在 EmbeddingStore._get_embedding 中,改为同步创建-使用-销毁的新事件循环模式,彻底避免嵌套事件循环问题
- 调整批量嵌入 _get_embeddings_batch_threaded,确保每个线程使用独立、短生命周期的事件循环
- 新增 force_new 参数,LLM 请求嵌入任务时强制创建新的客户端实例,减少跨循环对象复用
- 在 OpenAI 客户端的 embedding 调用处补充详细日志,方便排查网络连接异常
- get_embedding() 每次都重建 LLMRequest,降低实例在多个事件循环中穿梭的概率

此次改动虽然以同步风格“硬掰”异步接口,但对现有接口零破坏,确保了向量数据库及相关知识检索功能的稳定性。(还有就是把的脚本文件夹移回来了)
2025-11-19 22:44:54 +08:00
雅诺狐
bb4592846c Refactor config system to use Pydantic validation
Refactored configuration classes to inherit from a new ValidatedConfigBase using Pydantic for robust validation and error reporting. Updated api_ada_configs.py, config.py, config_base.py, and official_configs.py to replace dataclasses with Pydantic models, add field validation, and improve error messages. This change enhances configuration reliability and developer feedback for misconfigurations. Also includes minor code cleanups and removal of unused variables in other modules.
2025-11-19 22:44:45 +08:00
雅诺狐
383f704b53 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-11-19 22:44:32 +08:00
minecraft1024a
793c6e3817 fix(statistic): 修复统计任务中因数据库记录格式问题导致的异常
在处理来自数据库的记录时,增加对记录类型的检查和时间戳格式的转换。确保即使记录不是预期的字典格式,或者时间戳字段为None或字符串格式,程序也能够安全处理,避免因`TypeError`或`AttributeError`导致整个统计任务中断(说真的这都一天了为什么还没人修)
2025-11-19 22:42:24 +08:00
雅诺狐
875e02d42f 数据库重构 2025-11-19 22:40:23 +08:00
雅诺狐
dfecccfc56 llm统计记录模型反应时间 2025-11-19 22:40:11 +08:00
minecraft1024a
fe43cb3816 将聊天消息构建器中的日志级别从info调整为debug,以减少日志输出的冗余,优化调试信息的记录。 2025-11-19 22:39:16 +08:00
minecraft1024a
80eab4cf1a 在聊天消息构建器中添加日志记录功能,记录函数调用参数和处理过程,优化动作记录的返回格式,确保返回的动作记录包含必要字段。 2025-11-19 22:39:09 +08:00
ikun-11451
0053daffd9 给这个文件的请求session加上一个with上下文管理喵~ 2025-11-19 22:37:46 +08:00
minecraft1024a
1e785a117d 优化图片格式处理,统一将'jpg'格式转换为'jpeg',新增标准化和MIME类型转换功能,以确保API兼容性和提高代码可读性(最主要的还是为了gemini) 2025-11-19 22:36:09 +08:00
雅诺狐
2e6ae2419b 优化项目结构,格式化代码 2025-11-19 22:35:40 +08:00
雅诺狐
23ee3767ef 初始化 2025-11-19 22:34:56 +08:00
SengokuCola
fed0c0fd04 feat:更新记忆系统 2025-08-13 23:17:28 +08:00
SengokuCola
ca69e9af15 fix:修复注册顺序问题
Update person_info.py

Update relationship_manager.py
2025-08-12 15:42:59 +08:00
SengokuCola
ae254de494 better:重构personinfo,使用Person类和类属性 2025-08-12 14:33:13 +08:00
SengokuCola
268b428e8f feat: llm统计现已记录模型反应时间 2025-08-11 21:51:59 +08:00
UnCLAS-Prommer
43190b12d2 防炸 2025-08-11 11:29:05 +08:00
SengokuCola
1515cef487 fix:必要性修复 2025-08-11 01:08:42 +08:00
SengokuCola
3804124df8 fix:优化reply,填补缺失值,youhualog 2025-08-11 00:19:31 +08:00
SengokuCola
b57671b639 fix:修复表情包描述进入prompt问题 2025-08-09 21:16:57 +08:00
Windpicker-owo
b79faf8f86 修复了语音识别一个不太聪明的bug 2025-08-01 15:30:35 +08:00
UnCLAS-Prommer
75689d760d ruff 2025-08-01 14:33:24 +08:00
Windpicker-owo
25cb8d41bb 修复了语音识别功能 2025-08-01 03:32:00 +08:00