refactor: 清理代码质量和移除未使用文件
- 移除未使用的导入语句和变量 - 修复代码风格问题(空格、格式化等) - 删除备份文件和测试文件 - 改进异常处理链式调用 - 添加权限系统数据库模型和配置 - 更新版本号至6.4.4 - 优化SQL查询使用正确的布尔表达式
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import asyncio
|
||||
import time
|
||||
import traceback
|
||||
import re
|
||||
from typing import Optional
|
||||
|
||||
from src.common.logger import get_logger
|
||||
|
||||
@@ -142,11 +142,10 @@ class ResponseHandler:
|
||||
|
||||
# 修正:正确处理元组格式 (格式为: (type, content))
|
||||
if isinstance(reply_seg, tuple) and len(reply_seg) >= 2:
|
||||
reply_type, data = reply_seg
|
||||
_, data = reply_seg
|
||||
else:
|
||||
# 向下兼容:如果已经是字符串,则直接使用
|
||||
data = str(reply_seg)
|
||||
reply_type = "text"
|
||||
|
||||
reply_text += data
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ class ActionDiagnostics:
|
||||
raise Exception("注册失败")
|
||||
|
||||
except Exception as e:
|
||||
raise Exception(f"手动注册no_reply Action失败: {e}")
|
||||
raise Exception(f"手动注册no_reply Action失败: {e}") from e
|
||||
|
||||
def run_full_diagnosis(self) -> Dict[str, Any]:
|
||||
"""运行完整诊断"""
|
||||
|
||||
@@ -131,7 +131,7 @@ class AsyncMemoryQueue:
|
||||
await task.callback(None)
|
||||
else:
|
||||
task.callback(None)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
async def _handle_store_task(self, task: MemoryTask) -> Any:
|
||||
|
||||
@@ -271,7 +271,7 @@ class VectorInstantMemoryV2:
|
||||
return f"{int(diff/3600)}小时前"
|
||||
else:
|
||||
return f"{int(diff/86400)}天前"
|
||||
except:
|
||||
except Exception:
|
||||
return "时间格式错误"
|
||||
|
||||
async def get_memory_for_context(self, current_message: str, context_size: int = 3) -> str:
|
||||
@@ -318,7 +318,7 @@ class VectorInstantMemoryV2:
|
||||
try:
|
||||
result = self.collection.count()
|
||||
stats["total_messages"] = result
|
||||
except:
|
||||
except Exception:
|
||||
stats["total_messages"] = "查询失败"
|
||||
|
||||
return stats
|
||||
|
||||
@@ -16,11 +16,9 @@ from src.chat.utils.prompt_builder import Prompt, global_prompt_manager
|
||||
from src.plugin_system.core import component_registry, events_manager, global_announcement_manager
|
||||
from src.plugin_system.base import BaseCommand, EventType
|
||||
from src.mais4u.mais4u_chat.s4u_msg_processor import S4UMessageProcessor
|
||||
from src.plugin_system.apis import send_api
|
||||
|
||||
# 导入反注入系统
|
||||
from src.chat.antipromptinjector import get_anti_injector, initialize_anti_injector
|
||||
from src.chat.antipromptinjector.types import ProcessResult
|
||||
from src.chat.antipromptinjector import initialize_anti_injector
|
||||
|
||||
# 定义日志配置
|
||||
|
||||
|
||||
@@ -458,7 +458,7 @@ class VideoAnalyzer:
|
||||
try:
|
||||
# 等待处理完成的事件信号,最多等待60秒
|
||||
await asyncio.wait_for(video_event.wait(), timeout=60.0)
|
||||
logger.info(f"✅ 等待结束,检查是否有处理结果")
|
||||
logger.info("✅ 等待结束,检查是否有处理结果")
|
||||
|
||||
# 检查是否有结果了
|
||||
existing_video = self._check_video_exists(video_hash)
|
||||
@@ -466,9 +466,9 @@ class VideoAnalyzer:
|
||||
logger.info(f"✅ 找到了处理结果,直接返回 (id: {existing_video.id})")
|
||||
return {"summary": existing_video.description}
|
||||
else:
|
||||
logger.warning(f"⚠️ 等待完成但未找到结果,可能处理失败")
|
||||
logger.warning("⚠️ 等待完成但未找到结果,可能处理失败")
|
||||
except asyncio.TimeoutError:
|
||||
logger.warning(f"⚠️ 等待超时(60秒),放弃等待")
|
||||
logger.warning("⚠️ 等待超时(60秒),放弃等待")
|
||||
|
||||
# 获取锁开始处理
|
||||
async with video_lock:
|
||||
|
||||
Reference in New Issue
Block a user