fix: 修改 db_id 生成逻辑,限制哈希长度为 32 字符 #499

This commit is contained in:
Wenjie Zhang 2026-01-26 16:33:49 +08:00
parent 3d43aa1d0e
commit b08ae33678

View File

@ -404,7 +404,7 @@ class KnowledgeBase(ABC):
# 从 kwargs 中获取 is_private 配置
is_private = kwargs.get("is_private", False)
prefix = "kb_private_" if is_private else "kb_"
db_id = f"{prefix}{hashstr(database_name, with_salt=True)}"
db_id = f"{prefix}{hashstr(database_name, with_salt=True, length=32)}"
# 创建数据库记录
# 确保 Pydantic 模型被转换为字典,以便 JSON 序列化