Commit Graph
2107 Commits
Author SHA1 Message Date
HibiKier ea6759824e refactor: streamline per-key lock creation in AuthSnapshotService using setdefault for atomicity 2025-12-31 10:26:18 +08:00
HibiKier 2542436d5b refactor: enhance concurrency handling in AuthSnapshotService by implementing future-based snapshot building 2025-12-31 10:17:03 +08:00
HibiKier e93b3b998e refactor: adjust concurrency settings and implement per-key locks in AuthSnapshotService 2025-12-31 10:04:57 +08:00
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