Commit Graph
2104 Commits
Author SHA1 Message Date
HibiKier 401fc5e203 refactor: simplify superuser permission checks in OptimizedAuthChecker 2025-12-31 09:40:10 +08:00
HibiKier 4a103f5675 fix: update snapshot caching to store the entire snapshot object instead of its model dump 2025-12-31 09:23:51 +08:00
HibiKier 46a924ca46 feat: warmup now writes to both memory and Redis cache for cross-process sharing 2025-12-31 09:14:41 +08:00
HibiKier 40a81efa24 perf: fix lock ordering issue - acquire semaphore before checking building status 2025-12-31 09:05:32 +08:00
HibiKier 6ddfbe2ac1 fix: add explicit NULL type casting for PostgreSQL UNION ALL compatibility 2025-12-30 16:44:54 +08:00
HibiKier 2ccd05f4cf fix: remove duplicate prefix in cache keys (CacheType already provides prefix) 2025-12-30 15:16:40 +08:00
HibiKier 358c7f502c fix: use AUTH_SNAPSHOT and PLUGIN_SNAPSHOT cache types instead of TEMP/PLUGINS 2025-12-30 15:10:14 +08:00
HibiKier ae4aa5c29c refactor: replace legacy auth checker with optimized auth checker for improved performance 2025-12-29 17:03:25 +08:00
HibiKier 7ec11474f8 feat: add multi-database support (MySQL, PostgreSQL, SQLite) with parameterized queries 2025-12-29 16:49:49 +08:00
HibiKier 601738c421 perf: use single SQL query to reduce DB calls from 5-7 to 1-3 2025-12-29 16:44:57 +08:00
HibiKier 94939d4665 feat: add global semaphore to limit concurrent snapshot builds 2025-12-29 16:35:12 +08:00
HibiKier cd2fd77789 refactor: use CacheDict from CacheRoot instead of custom dict for memory cache 2025-12-29 09:41:17 +08:00
HibiKier ea8d874f0c fix: add asyncio.Lock to prevent concurrent snapshot building race condition 2025-12-29 09:29:32 +08:00
HibiKier 96ba8d5a21 feat: add permission snapshot system to optimize auth checks 2025-12-29 09:20:07 +08:00
HibiKier f86beb928f refactor: enhance UserConsole UID management and remove mute plugin 2025-12-25 09:47:01 +08:00
HibiKier 52b32915cc refactor: optimize MuteManager data source 2025-12-24 15:09:24 +08:00
HibiKier be316a5caf refactor: extract is_ban_cached method to BanConsole 2025-12-24 14:54:39 +08:00
HibiKier ff0b37123e refactor(fudu1): optimize enhanced repeater plugin 2025-12-24 10:31:49 +08:00
HibiKier 82dbdb91a4 refactor(fudu): 浼樺寲澶嶈鎻掍欢浠g爜 2025-12-24 10:15:34 +08:00
HibiKier 5e8ce3239e Merge branch 'bugfix/fix-timeout-k' of https://github.com/zhenxun-org/zhenxun_bot into bugfix/fix-timeout-k 2025-12-24 03:40:47 +08:00
HibiKier 587396eb49 refactor: remove enable_lock attribute and enhance locking mechanism in Model class 2025-12-23 23:23:58 +08:00
HibiKier a9ceb33adb chore: remove outdated comment from cancel_pending_tasks function 2025-12-23 17:23:38 +08:00
HibiKier af75d7fc5a perf: use keyed create locks for ban/group and add tuple support 2025-12-23 17:22:41 +08:00
HibiKier a8251165fa perf: support keyed create locks and use user_id lock for UserConsole 2025-12-23 17:19:01 +08:00
HibiKier ed23ad319a perf: lock user creation to reduce timeout under load 2025-12-23 17:11:35 +08:00
HibiKier cb9c5834df chore: cancel only zhenxun tasks on shutdown 2025-12-23 17:07:36 +08:00
HibiKier 93ad6b354c chore: log task states and elapsed on auth ctx timeout 2025-12-23 16:57:30 +08:00
HibiKier 420f7e2bfc refactor(user_console): simplify user creation logic by removing retry mechanism for uid generation 2025-12-23 16:48:34 +08:00
HibiKier 4fd816fa3b fix: avoid null uid when creating user 2025-12-23 16:47:33 +08:00
HibiKier 47a40492ae refactor(bot): remove cancel_pending_tasks function and adjust shutdown behavior 2025-12-23 16:40:26 +08:00
HibiKier 142afde336 fix(user_console): ensure uid returns a valid value by defaulting to 1 2025-12-23 16:38:08 +08:00
HibiKier 36667f9e19 chore: cancel pending tasks before db disconnect on shutdown 2025-12-23 16:33:51 +08:00
HibiKier 564e1b07b2 chore: log pending tasks on auth context timeout 2025-12-23 16:26:42 +08:00
HibiKier c89e75e268 refactor(user_console): improve user retrieval logic by checking existence before creation 2025-12-23 16:20:37 +08:00
HibiKier e6fd27018d refactor(user_console): streamline user retrieval and creation logic 2025-12-23 16:20:07 +08:00
HibiKier 2c457b7595 refactor(user_console): simplify user creation and remove uid from save operations 2025-12-23 16:17:38 +08:00
HibiKier 6f139b3afa fix: ensure uid unique without null 2025-12-23 16:11:11 +08:00
HibiKier b74f8dfd33 fix: avoid uid unique conflict on user create 2025-12-23 16:08:40 +08:00
HibiKier 4a76c86e2e fix(auth_ban): prevent processing of null results in ban handling logic 2025-12-23 15:26:32 +08:00
HibiKier 47ec5bc7b9 refactor: enhance ban handling with caching and optimize user/group ban checks 2025-12-23 15:15:35 +08:00
HibiKier a3cbfefaa1 feat: add TEMP cache type and enhance user and bot management with improved error handling and caching mechanisms 2025-12-22 10:16:02 +08:00
HibiKier 632dff3bad perf: optimize timeout handling for database and cache operations 2025-12-18 09:05:33 +08:00
HibiKier e5ea00eb1a chore: record load_context time in auth checker hooks detail 2025-12-17 16:27:27 +08:00
HibiKier 4b225a3be9 refactor: update auth checker with optimized design and remove deprecated file 2025-12-17 16:01:08 +08:00
HibiKier 26150c2924 refactor: align auth checker optimization with DataAccess caching 2025-12-17 15:03:44 +08:00
HibiKier 0939013a89 feat: add retry mechanism and cache fallback for auth timeout 2025-12-17 10:52:15 +08:00
c9f0a8b9d9 ♻️ refactor(llm): 重构 LLM 服务架构,引入中间件与组件化适配器 (#2073)
检查bot是否运行正常 / bot check (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Sequential Lint and Type Check / ruff-call (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Force Sync to Aliyun / sync (push) Has been cancelled
Update Version / update-version (push) Has been cancelled
Sequential Lint and Type Check / pyright-call (push) Has been cancelled
* ♻️ refactor(llm): 重构 LLM 服务架构,引入中间件与组件化适配器

- 【重构】LLM 服务核心架构:
    - 引入中间件管道,统一处理请求生命周期(重试、密钥选择、日志、网络请求)。
    - 适配器重构为组件化设计,分离配置映射、消息转换、响应解析和工具序列化逻辑。
    - 移除 `with_smart_retry` 装饰器,其功能由中间件接管。
    - 移除 `LLMToolExecutor`,工具执行逻辑集成到 `ToolInvoker`。
- 【功能】增强配置系统:
    - `LLMGenerationConfig` 采用组件化结构(Core, Reasoning, Visual, Output, Safety, ToolConfig)。
    - 新增 `GenConfigBuilder` 提供语义化配置构建方式。
    - 新增 `LLMEmbeddingConfig` 用于嵌入专用配置。
    - `CommonOverrides` 迁移并更新至新配置结构。
- 【功能】强化工具系统:
    - 引入 `ToolInvoker` 实现更灵活的工具执行,支持回调与结构化错误。
    - `function_tool` 装饰器支持动态 Pydantic 模型创建和依赖注入 (`ToolParam`, `RunContext`)。
    - 平台原生工具支持 (`GeminiCodeExecution`, `GeminiGoogleSearch`, `GeminiUrlContext`)。
- 【功能】高级生成与嵌入:
    - `generate_structured` 方法支持 In-Context Validation and Repair (IVR) 循环和 AutoCoT (思维链) 包装。
    - 新增 `embed_query` 和 `embed_documents` 便捷嵌入 API。
    - `OpenAIImageAdapter` 支持 OpenAI 兼容的图像生成。
    - `SmartAdapter` 实现模型名称智能路由。
- 【重构】消息与类型系统:
    - `LLMContentPart` 扩展支持更多模态和代码执行相关内容。
    - `LLMMessage` 和 `LLMResponse` 结构更新,支持 `content_parts` 和思维链签名。
    - 统一 `LLMErrorCode` 和用户友好错误消息,提供更详细的网络/代理错误提示。
    - `pyproject.toml` 移除 `bilireq`,新增 `json_repair`。
- 【优化】日志与调试:
    - 引入 `DebugLogOptions`,提供细粒度日志脱敏控制。
    - 增强日志净化器,处理更多敏感数据和长字符串。
- 【清理】删除废弃模块:
    - `zhenxun/services/llm/memory.py`
    - `zhenxun/services/llm/executor.py`
    - `zhenxun/services/llm/config/presets.py`
    - `zhenxun/services/llm/types/content.py`
    - `zhenxun/services/llm/types/enums.py`
    - `zhenxun/services/llm/tools/__init__.py`
    - `zhenxun/services/llm/tools/manager.py`

* 📦️ build(deps): 移除 bilireq 并添加 json_repair 依赖

* 🐛 (llm): 移除图片生成模型能力预检查

* ♻️ refactor(llm.session): 重构记忆系统以分离存储和策略

* 🐛 fix(reload_setting): 重载配置时清除LLM缓存

* ✨ feat(llm): 支持结构化生成函数接收 UniMessage

* ✨ feat(search): 为搜索功能默认启用 Gemini Google Search 工具

* 🚨 auto fix by pre-commit hooks

---------

Co-authored-by: webjoin111 <455457521@qq.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-12-14 20:27:02 +08:00
Rumioandwebjoin111 e5b2a872d3 ✨ feat(group-settings): 实现群插件配置管理系统 (#2072)
检查bot是否运行正常 / bot check (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Sequential Lint and Type Check / ruff-call (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Force Sync to Aliyun / sync (push) Has been cancelled
Update Version / update-version (push) Has been cancelled
Sequential Lint and Type Check / pyright-call (push) Has been cancelled
* ✨ feat(group-settings): 实现群插件配置管理系统

- 引入 GroupSettingsService 服务,提供统一的群插件配置管理接口
- 新增 GroupPluginSetting 模型,用于持久化存储插件在不同群组的配置
- 插件扩展数据 PluginExtraData 增加 group_config_model 字段,用于注册分群配置模型
- 新增 GetGroupConfig 依赖注入,允许插件轻松获取和解析当前群组的配置

【核心服务 GroupSettingsService】
- 支持按群组、插件名和键设置、获取和删除配置项
- 实现配置聚合缓存机制,提升配置读取效率,减少数据库查询
- 支持配置继承与覆盖逻辑(群配置覆盖全局默认值)
- 提供批量设置功能 set_bulk,方便为多个群组同时更新配置

【管理与缓存】
- 新增超级用户命令 pconf (plugin_config_manager),用于命令行管理插件的分群和全局配置
- 新增 CacheType.GROUP_PLUGIN_SETTINGS 缓存类型并注册
- 增加 Pydantic model_construct 兼容函数

* 🐛 fix(codeql): 移除对 JavaScript 和 TypeScript 的分析支持

---------

Co-authored-by: webjoin111 <455457521@qq.com>
2025-12-01 14:52:36 +08:00
68460d18cc ✨ Feat: 增强 LLM、渲染与广播功能并优化性能 (#2071)
检查bot是否运行正常 / bot check (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Sequential Lint and Type Check / ruff-call (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Force Sync to Aliyun / sync (push) Has been cancelled
Update Version / update-version (push) Has been cancelled
Sequential Lint and Type Check / pyright-call (push) Has been cancelled
* ⚡️ perf(image_utils): 优化图片哈希获取避免阻塞异步

* ✨ feat(llm): 增强 LLM 管理功能,支持纯文本列表输出,优化模型能力识别并新增提供商

- 【LLM 管理器】为 `llm list` 命令添加 `--text` 选项,支持以纯文本格式输出模型列表。
- 【LLM 配置】新增 `OpenRouter` LLM 提供商的默认配置。
- 【模型能力】增强 `get_model_capabilities` 函数的查找逻辑,支持模型名称分段匹配和更灵活的通配符匹配。
- 【模型能力】为 `Gemini` 模型能力注册表使用更通用的通配符模式。
- 【模型能力】新增 `GPT` 系列模型的详细能力定义,包括多模态输入输出和工具调用支持。

* ✨ feat(renderer): 添加 Jinja2 `inline_asset` 全局函数

- 新增 `RendererService._inline_asset_global` 方法,并注册为 Jinja2 全局函数 `inline_asset`。
- 允许模板通过 `{{ inline_asset('@namespace/path/to/asset.svg') }}` 直接内联已注册命名空间下的资源文件内容。
- 主要用于解决内联 SVG 时可能遇到的跨域安全问题。
- 【重构】优化 `ResourceResolver.resolve_asset_uri` 中对命名空间资源 (以 `@` 开头) 的解析逻辑,确保能够正确获取文件绝对路径并返回 URI。
- 改进 `RenderableComponent.get_extra_css`,使其在组件定义 `component_css` 时自动返回该 CSS 内容。
- 清理 `Renderable` 协议和 `RenderableComponent` 基类中已存在方法的 `[新增]` 标记。

* ✨ feat(tag): 添加标签克隆功能

- 新增 `tag clone <源标签名> <新标签名>` 命令,用于复制现有标签。
- 【优化】在 `tag create`, `tag edit --add`, `tag edit --set` 命令中,自动去重传入的群组ID,避免重复关联。

* ✨ feat(broadcast): 实现标签定向广播、强制发送及并发控制

- 【新功能】
  - 新增标签定向广播功能,支持通过 `-t <标签名>` 或 `广播到 <标签名>` 命令向指定标签的群组发送消息
  - 引入广播强制发送模式,允许绕过群组的任务阻断设置
  - 实现广播并发控制,通过配置限制同时发送任务数量,避免API速率限制
  - 优化视频消息处理,支持从URL下载视频内容并作为原始数据发送,提高跨平台兼容性
- 【配置】
  - 添加 `DEFAULT_BROADCAST` 配置项,用于设置群组进群时广播功能的默认开关状态
  - 添加 `BROADCAST_CONCURRENCY_LIMIT` 配置项,用于控制广播时的最大并发任务数

* ✨ feat(renderer): 支持组件变体样式收集

* ✨ feat(tag): 实现群组标签自动清理及手动清理功能

* 🐛 fix(gemini): 增加响应验证以处理内容过滤(promptFeedback)

* 🐛 fix(codeql): 移除对 JavaScript 和 TypeScript 的分析支持

* 🚨 auto fix by pre-commit hooks

---------

Co-authored-by: webjoin111 <455457521@qq.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-11-26 14:13:19 +08:00
ThelevenFDandHibiKier c839b44256 转换specify_probability为float 增加鉴权配置 (#2067)
检查bot是否运行正常 / bot check (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL Code Security Analysis / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Sequential Lint and Type Check / ruff-call (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Force Sync to Aliyun / sync (push) Has been cancelled
Update Version / update-version (push) Has been cancelled
Sequential Lint and Type Check / pyright-call (push) Has been cancelled
* 转换specify_probability为float

* 解决#2045 添加密钥配置

* Revise access token configuration in .env.example

Updated comments and modified access token configuration.

---------

Co-authored-by: HibiKier <45528451+HibiKier@users.noreply.github.com>
2025-11-03 16:36:43 +08:00