From 8f3338f8451d21d3d82e119f0973a7a938d4d807 Mon Sep 17 00:00:00 2001 From: Gardel Date: Sat, 6 Dec 2025 07:53:10 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E8=AE=B0=E5=BF=86=E6=8F=90=E5=8F=96?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9C=AB=E5=B0=BE=E9=80=97=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/memory_graph/short_term_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/memory_graph/short_term_manager.py b/src/memory_graph/short_term_manager.py index cc75cd5c7..47e874ad8 100644 --- a/src/memory_graph/short_term_manager.py +++ b/src/memory_graph/short_term_manager.py @@ -186,8 +186,8 @@ class ShortTermMemoryManager: "importance": 0.7, "attributes": {{ "time": "时间信息", - "attribute1": "其他属性1" - "attribute2": "其他属性2" + "attribute1": "其他属性1", + "attribute2": "其他属性2", ... }} }} From eac1ef28699b2dabd72b2dc70be6e179a3312e43 Mon Sep 17 00:00:00 2001 From: Gardel Date: Sun, 7 Dec 2025 17:52:41 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E5=88=86=E6=9E=90=E8=AE=B0=E5=BF=86?= =?UTF-8?q?=E6=97=B6=E4=BF=AE=E5=A4=8D=E5=BC=95=E5=8F=B7=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/memory_graph/short_term_manager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/memory_graph/short_term_manager.py b/src/memory_graph/short_term_manager.py index 47e874ad8..2f94059ec 100644 --- a/src/memory_graph/short_term_manager.py +++ b/src/memory_graph/short_term_manager.py @@ -11,6 +11,7 @@ import asyncio import json import re import uuid +import json_repair from pathlib import Path from typing import Any @@ -530,7 +531,7 @@ class ShortTermMemoryManager: json_str = re.sub(r"//.*", "", json_str) json_str = re.sub(r"/\*.*?\*/", "", json_str, flags=re.DOTALL) - data = json.loads(json_str) + data = json_repair.loads(json_str) return data except json.JSONDecodeError as e: From c870af768dcf367d8baeeee838adcd90862bb779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=85=E8=AF=BA=E7=8B=90?= <212194964+foxcyber907@users.noreply.github.com> Date: Wed, 10 Dec 2025 15:06:01 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix=EF=BC=88redis=EF=BC=89=EF=BC=9A?= =?UTF-8?q?=E6=9B=B4=E6=96=B0Redis=E8=BF=9E=E6=8E=A5=E6=B1=A0=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=EF=BC=8C=E4=BB=A5=E5=85=BC=E5=AE=B9redis-py?= =?UTF-8?q?=207.x=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新Redis连接池创建方式,使用connection_class参数替代已弃用的ssl参数,以适配redis-py 7.x及以上版本 --- src/common/database/optimization/redis_cache.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/database/optimization/redis_cache.py b/src/common/database/optimization/redis_cache.py index 8dd00a44c..558ec8544 100644 --- a/src/common/database/optimization/redis_cache.py +++ b/src/common/database/optimization/redis_cache.py @@ -20,6 +20,7 @@ from src.common.logger import get_logger logger = get_logger("redis_cache") import redis.asyncio as aioredis +from redis.asyncio.connection import Connection, SSLConnection class RedisCache(CacheBackend): @@ -98,7 +99,11 @@ class RedisCache(CacheBackend): return self._client try: - # 创建连接池 (使用 aioredis 模块确保类型安全) + # redis-py 7.x+ 使用 connection_class 来指定 SSL 连接 + # 不再支持直接传递 ssl=True/False 给 ConnectionPool + connection_class = SSLConnection if self.ssl else Connection + + # 创建连接池 self._pool = aioredis.ConnectionPool( host=self.host, port=self.port, @@ -108,7 +113,7 @@ class RedisCache(CacheBackend): socket_timeout=self.socket_timeout, socket_connect_timeout=self.socket_timeout, decode_responses=False, # 我们自己处理序列化 - ssl=self.ssl, + connection_class=connection_class, ) # 创建客户端 From 4592e37c108acfb5efd6b7cd9ebb95e49958608d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=85=E8=AF=BA=E7=8B=90?= <212194964+foxcyber907@users.noreply.github.com> Date: Wed, 10 Dec 2025 15:11:25 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix(config):=20=E4=BF=AE=E5=A4=8D=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8A=A0=E8=BD=BD=E4=B8=AD=E7=9A=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E9=97=AE=E9=A2=98=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?Pydantic=E4=B8=A5=E6=A0=BC=E6=A8=A1=E5=BC=8F=E4=B8=8B=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/config.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/config/config.py b/src/config/config.py index 43b0d2229..cf2c0387d 100644 --- a/src/config/config.py +++ b/src/config/config.py @@ -506,24 +506,16 @@ def load_config(config_path: str) -> Config: with open(config_path, encoding="utf-8") as f: config_data = tomlkit.load(f) + # 将 tomlkit 对象转换为纯 Python 字典,避免 Pydantic 严格模式下的类型验证问题 + # tomlkit 返回的是特殊类型(如 Array、String 等),虽然继承自 Python 标准类型, + # 但在 Pydantic 严格模式下可能导致类型验证失败 + config_dict = config_data.unwrap() + # 创建Config对象(各个配置类会自动进行 Pydantic 验证) try: logger.debug("正在解析和验证配置文件...") - config = Config.from_dict(config_data) + config = Config.from_dict(config_dict) logger.debug("配置文件解析和验证完成") - - # 【临时修复】在验证后,手动从原始数据重新加载 master_users - try: - # 先将 tomlkit 对象转换为纯 Python 字典 - config_dict = config_data.unwrap() - if "permission" in config_dict and "master_users" in config_dict["permission"]: - raw_master_users = config_dict["permission"]["master_users"] - # 现在 raw_master_users 就是一个标准的 Python 列表了 - config.permission.master_users = raw_master_users - logger.debug(f"【临时修复】已手动将 master_users 设置为: {config.permission.master_users}") - except Exception as patch_exc: - logger.error(f"【临时修复】手动设置 master_users 失败: {patch_exc}") - return config except Exception as e: logger.critical(f"配置文件解析失败: {e}") @@ -581,4 +573,4 @@ def initialize_configs_once() -> tuple[Config, APIAdapterConfig]: # 同一进程只执行一次初始化,避免重复生成或覆盖配置 global_config, model_config = initialize_configs_once() -logger.debug("非常的新鲜,非常的美味!") \ No newline at end of file +logger.debug("非常的新鲜,非常的美味!")