🤖 自动格式化代码 [skip ci]

This commit is contained in:
github-actions[bot]
2025-07-03 04:26:17 +00:00
parent c3588a707c
commit fbe8f08862
7 changed files with 15 additions and 18 deletions

View File

@@ -170,7 +170,7 @@ class ExpressionSelector:
"""使用LLM选择适合的表达方式"""
# 1. 获取35个随机表达方式现在按权重抽取
style_exprs, grammar_exprs= self.get_random_expressions(chat_id, 50, 0.5, 0.5)
style_exprs, grammar_exprs = self.get_random_expressions(chat_id, 50, 0.5, 0.5)
# 2. 构建所有表达方式的索引和情境列表
all_expressions = []
@@ -192,7 +192,6 @@ class ExpressionSelector:
all_expressions.append(expr_with_type)
all_situations.append(f"{len(all_expressions)}.{expr['situation']}")
if not all_expressions:
logger.warning("没有找到可用的表达方式")
return []

View File

@@ -74,9 +74,7 @@ class ExpressionLearner:
)
self.llm_model = None
def get_expression_by_chat_id(
self, chat_id: str
) -> Tuple[List[Dict[str, str]], List[Dict[str, str]]]:
def get_expression_by_chat_id(self, chat_id: str) -> Tuple[List[Dict[str, str]], List[Dict[str, str]]]:
"""
获取指定chat_id的style和grammar表达方式
返回的每个表达方式字典中都包含了source_id, 用于后续的更新操作
@@ -110,7 +108,6 @@ class ExpressionLearner:
except Exception as e:
logger.error(f"读取grammar表达方式失败: {e}")
return learnt_style_expressions, learnt_grammar_expressions
def is_similar(self, s1: str, s2: str) -> bool:

View File

@@ -88,9 +88,6 @@ async def _calculate_interest(message: MessageRecv) -> Tuple[float, bool]:
return interested_rate, is_mentioned
class HeartFCMessageReceiver:
"""心流处理器,负责处理接收到的消息并计算兴趣度"""

View File

@@ -32,6 +32,7 @@ if ENABLE_S4U_CHAT:
# 配置主程序日志格式
logger = get_logger("chat")
def _check_ban_words(text: str, chat: ChatStream, userinfo: UserInfo) -> bool:
"""检查消息是否包含过滤词
@@ -71,6 +72,7 @@ def _check_ban_regex(text: str, chat: ChatStream, userinfo: UserInfo) -> bool:
return True
return False
class ChatBot:
def __init__(self):
self.bot = None # bot 实例引用

View File

@@ -196,7 +196,7 @@ class S4UChat:
async def add_message(self, message: MessageRecv) -> None:
"""根据VIP状态和中断逻辑将消息放入相应队列。"""
is_vip = self._is_vip(message)
new_priority = self._get_message_priority(message)
self._get_message_priority(message)
should_interrupt = False
if self._current_generation_task and not self._current_generation_task.done():
@@ -245,7 +245,9 @@ class S4UChat:
if self._normal_queue.qsize() >= self.normal_queue_max_size:
# 队列已满,简单忽略新消息
# 更复杂的逻辑(如替换掉队列中优先级最低的)对于 asyncio.PriorityQueue 来说实现复杂
logger.debug(f"[{self.stream_name}] Normal queue is full, ignoring new message from {message.message_info.user_info.user_id}")
logger.debug(
f"[{self.stream_name}] Normal queue is full, ignoring new message from {message.message_info.user_info.user_id}"
)
return
await self._normal_queue.put(item)