feat:接入mongodb
This commit is contained in:
@@ -59,7 +59,21 @@ class Settings:
|
||||
default_factory=lambda: int(os.getenv("CONVERSATION_HISTORY_TURNS", "6"))
|
||||
)
|
||||
|
||||
# MongoDB 连接串,未配置时会话记录和检查点回退为进程内存实现
|
||||
mongodb_uri: str | None = field(
|
||||
default_factory=lambda: os.getenv("MONGODB_URI") or None, repr=False
|
||||
)
|
||||
mongodb_db: str = field(
|
||||
default_factory=lambda: os.getenv("MONGODB_DB") or "screen_agent"
|
||||
)
|
||||
# 检查点保留时长(秒),超时由 MongoDB TTL 索引清理,0 表示永久保留
|
||||
mongodb_checkpoint_ttl: int = field(
|
||||
default_factory=lambda: int(os.getenv("MONGODB_CHECKPOINT_TTL", "604800"))
|
||||
)
|
||||
|
||||
def __post_init__(self):
|
||||
if self.mongodb_checkpoint_ttl < 0:
|
||||
raise ValueError("MONGODB_CHECKPOINT_TTL 必须是非负整数")
|
||||
if self.conversation_empty_ttl <= 0:
|
||||
raise ValueError("CONVERSATION_EMPTY_TTL 必须是正整数")
|
||||
if self.conversation_history_turns < 0:
|
||||
|
||||
Reference in New Issue
Block a user