初始化:记忆系统源代码上传(已脱敏)
- 排除 .env / *.bak / 内部运维文档(README_INTERNAL.html) - config.py 默认密码已替换为占位符 CHANGE_ME_* - init_db.sql 移除生产数据库用户 GRANT 段 - README.html 数据库用户名已脱敏 - 保留:源码 + 公网 API 文档 + 建表 SQL(无授权语句)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
"""Memory Cleaner - Periodic cleanup of old/low-importance memories"""
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MemoryCleaner:
|
||||
"""Clean up old, low-importance memories."""
|
||||
|
||||
def __init__(self, mysql_store):
|
||||
self.mysql = mysql_store
|
||||
|
||||
def cleanup(self, team_id: str = None, max_age_days: int = 90,
|
||||
min_importance: float = 0.2) -> dict:
|
||||
"""
|
||||
Remove old memories with low importance scores.
|
||||
|
||||
Args:
|
||||
team_id: If set, only clean this team's memories
|
||||
max_age_days: Remove memories older than this
|
||||
min_importance: Remove memories with importance below this
|
||||
|
||||
Returns:
|
||||
Dict with counts of deleted memories
|
||||
"""
|
||||
personal_deleted = self.mysql.cleanup_personal_memories(
|
||||
team_id=team_id,
|
||||
max_age_days=max_age_days,
|
||||
min_importance=min_importance,
|
||||
)
|
||||
team_deleted = self.mysql.cleanup_team_memories(
|
||||
team_id=team_id,
|
||||
max_age_days=max_age_days,
|
||||
min_importance=min_importance,
|
||||
)
|
||||
|
||||
result = {
|
||||
"personal_deleted": personal_deleted,
|
||||
"team_deleted": team_deleted,
|
||||
"total_deleted": personal_deleted + team_deleted,
|
||||
}
|
||||
logger.info(f"Cleanup result: {result}")
|
||||
return result
|
||||
Reference in New Issue
Block a user