This commit is contained in:
minecraft1024a
2025-08-22 12:17:16 +08:00
28 changed files with 1368 additions and 1113 deletions

View File

@@ -18,10 +18,6 @@ logger = get_logger("anti_injector.counter_attack")
class CounterAttackGenerator:
"""反击消息生成器"""
def __init__(self):
"""初始化反击消息生成器"""
pass
def get_personality_context(self) -> str:
"""获取人格上下文信息

View File

@@ -18,9 +18,6 @@ logger = get_logger("anti_injector.counter_attack")
class CounterAttackGenerator:
"""反击消息生成器"""
def __init__(self):
"""初始化反击消息生成器"""
pass
def get_personality_context(self) -> str:
"""获取人格上下文信息

View File

@@ -17,10 +17,6 @@ logger = get_logger("anti_injector.message_processor")
class MessageProcessor:
"""消息内容处理器"""
def __init__(self):
"""初始化消息处理器"""
pass
def extract_text_content(self, message: MessageRecv) -> str:
"""提取消息中的文本内容,过滤掉引用的历史内容

View File

@@ -144,8 +144,7 @@ class EmbeddingStore:
# 确保事件循环被正确关闭
try:
loop.close()
except Exception:
pass
except Exception: ...
def _get_embeddings_batch_threaded(self, strs: List[str], chunk_size: int = 10, max_workers: int = 10, progress_callback=None) -> List[Tuple[str, List[float]]]:
"""使用多线程批量获取嵌入向量

View File

@@ -58,8 +58,7 @@ def fix_broken_generated_json(json_str: str) -> str:
# Try to load the JSON to see if it is valid
json.loads(json_str)
return json_str # Return as-is if valid
except json.JSONDecodeError:
pass
except json.JSONDecodeError: ...
# Step 1: Remove trailing content after the last comma.
last_comma_index = json_str.rfind(",")

View File

@@ -25,14 +25,6 @@ class MemoryItem:
self.keywords: list[str] = keywords
self.create_time: float = time.time()
self.last_view_time: float = time.time()
class MemoryManager:
def __init__(self):
# self.memory_items:list[MemoryItem] = []
pass
class InstantMemory:
def __init__(self, chat_id):
self.chat_id = chat_id
@@ -219,14 +211,12 @@ class InstantMemory:
try:
dt = datetime.strptime(time_str, "%Y-%m-%d %H:%M:%S")
return dt, dt + timedelta(hours=1)
except Exception:
pass
except Exception: ...
# 具体日期
try:
dt = datetime.strptime(time_str, "%Y-%m-%d")
return dt, dt + timedelta(days=1)
except Exception:
pass
except Exception: ...
# 相对时间
if time_str == "今天":
start = now.replace(hour=0, minute=0, second=0, microsecond=0)

View File

@@ -170,7 +170,7 @@ class ChatBot:
logger.error(f"处理命令时出错: {e}")
return False, None, True # 出错时继续处理消息
async def hanle_notice_message(self, message: MessageRecv):
async def handle_notice_message(self, message: MessageRecv):
if message.message_info.message_id == "notice":
message.is_notify = True
logger.info("notice消息")
@@ -265,9 +265,7 @@ class ChatBot:
# logger.debug(str(message_data))
message = MessageRecv(message_data)
if await self.hanle_notice_message(message):
# return
pass
if await self.handle_notice_message(message): ...
group_info = message.message_info.group_info
user_info = message.message_info.user_info

View File

@@ -791,9 +791,8 @@ def build_pic_mapping_info(pic_id_mapping: Dict[str, str]) -> str:
image = session.execute(select(Images).where(Images.image_id == pic_id)).scalar()
if image and image.description:
description = image.description
except Exception:
except Exception: ...
# 如果查询失败,保持默认描述
pass
mapping_lines.append(f"[{display_name}] 的内容:{description}")

View File

@@ -70,8 +70,8 @@ class PromptContext:
# 如果reset失败尝试直接设置
try:
self._current_context = previous_context
except Exception:
pass # 静默忽略恢复失败
except Exception: ...
# 静默忽略恢复失败
async def get_prompt_async(self, name: str) -> Optional["Prompt"]:
"""异步获取当前作用域中的提示模板"""

View File

@@ -381,8 +381,7 @@ class ImageManager:
# 确保是RGB格式方便比较
frame = gif.convert("RGB")
all_frames.append(frame.copy())
except EOFError:
pass # 读完啦
except EOFError: ... # 读完啦
if not all_frames:
logger.warning("GIF中没有找到任何帧")

View File

@@ -44,7 +44,7 @@ class ClassicalWillingManager(BaseWillingManager):
return reply_probability
async def before_generate_reply_handle(self, message_id):
async def before_generate_reply_handle(self, message_id):
pass
async def after_generate_reply_handle(self, message_id):