feat:mcp
This commit is contained in:
@@ -180,6 +180,33 @@ class ContextStore:
|
||||
pass
|
||||
self.memory_fallback.pop(chat_id, None)
|
||||
|
||||
async def clear_group_history(self, chat_id: str) -> None:
|
||||
"""
|
||||
清空群聊历史记录
|
||||
|
||||
同时清除 Redis 和本地文件中的群聊历史
|
||||
"""
|
||||
# 清除 Redis 中的群聊历史
|
||||
if self._use_redis_for_group_history():
|
||||
redis_cache = get_cache()
|
||||
try:
|
||||
key = f"group_history:{_safe_chat_id(chat_id)}"
|
||||
redis_cache.delete(key)
|
||||
logger.debug(f"[ContextStore] 已清除 Redis 群聊历史: {chat_id}")
|
||||
except Exception as e:
|
||||
logger.debug(f"[ContextStore] 清除 Redis 群聊历史失败: {e}")
|
||||
|
||||
# 清除本地文件中的群聊历史
|
||||
history_file = self._get_history_file(chat_id)
|
||||
if history_file and history_file.exists():
|
||||
lock = self._get_history_lock(chat_id)
|
||||
async with lock:
|
||||
try:
|
||||
history_file.unlink()
|
||||
logger.debug(f"[ContextStore] 已清除本地群聊历史文件: {history_file}")
|
||||
except Exception as e:
|
||||
logger.debug(f"[ContextStore] 清除本地群聊历史文件失败: {e}")
|
||||
|
||||
# ------------------ 群聊 history ------------------
|
||||
|
||||
def _use_redis_for_group_history(self) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user