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

This commit is contained in:
github-actions[bot]
2025-06-25 09:20:20 +00:00
parent f40194516b
commit 8ba8aa7b2c
7 changed files with 49 additions and 39 deletions

View File

@@ -146,7 +146,9 @@ class ExpressionSelector:
except Exception as e:
logger.error(f"更新表达方式count失败: {e}")
async def select_suitable_expressions_llm(self, chat_id: str, chat_info: str, max_num: int = 10, min_num: int = 5) -> List[Dict[str, str]]:
async def select_suitable_expressions_llm(
self, chat_id: str, chat_info: str, max_num: int = 10, min_num: int = 5
) -> List[Dict[str, str]]:
"""使用LLM选择适合的表达方式"""
# 1. 获取35个随机表达方式现在按权重抽取
@@ -195,7 +197,6 @@ class ExpressionSelector:
max_num=max_num,
)
# 4. 调用LLM
try:
content, (_, _) = await self.llm_model.generate_response_async(prompt=prompt)

View File

@@ -181,7 +181,9 @@ class HeartFCMessageReceiver:
mes_name = chat.group_info.group_name if chat.group_info else "私聊"
# current_time = time.strftime("%H:%M:%S", time.localtime(message.message_info.time))
current_talk_frequency = global_config.chat.get_current_talk_frequency(chat.stream_id)
logger.info(f"[{mes_name}]{userinfo.user_nickname}:{message.processed_plain_text}[当前回复频率: {current_talk_frequency}]")
logger.info(
f"[{mes_name}]{userinfo.user_nickname}:{message.processed_plain_text}[当前回复频率: {current_talk_frequency}]"
)
# 8. 关系处理
if global_config.relationship.enable_relationship:

View File

@@ -71,7 +71,9 @@ class ExpressionSelectorProcessor(BaseProcessor):
try:
# LLM模式调用LLM选择5-10个然后随机选5个
selected_expressions = await expression_selector.select_suitable_expressions_llm(self.subheartflow_id, chat_info, max_num=12, min_num=2)
selected_expressions = await expression_selector.select_suitable_expressions_llm(
self.subheartflow_id, chat_info, max_num=12, min_num=2
)
cache_size = len(selected_expressions) if selected_expressions else 0
mode_desc = f"LLM模式已缓存{cache_size}个)"

View File

@@ -293,7 +293,6 @@ class PersonImpressionpProcessor(BaseProcessor):
}
segments.append(new_segment)
person_name = get_person_info_manager().get_value(person_id, "person_name")
logger.info(
f"{self.log_prefix} 眼熟用户 {person_name}{time.strftime('%H:%M:%S', time.localtime(potential_start_time))} - {time.strftime('%H:%M:%S', time.localtime(message_time))} 之间有 {new_segment['message_count']} 条消息"

View File

@@ -1000,7 +1000,9 @@ class NormalChat:
"""
# --- 1. 定义参数 ---
evaluation_minutes = 10.0
target_replies_per_min = global_config.chat.get_current_talk_frequency(self.stream_id) # 目标频率e.g. 1条/分钟
target_replies_per_min = global_config.chat.get_current_talk_frequency(
self.stream_id
) # 目标频率e.g. 1条/分钟
target_replies_in_window = target_replies_per_min * evaluation_minutes # 10分钟内的目标回复数
if target_replies_in_window <= 0:

View File

@@ -163,7 +163,9 @@ class PromptBuilder:
show_actions=True,
)
expressions = await expression_selector.select_suitable_expressions_llm(chat_stream.stream_id, chat_talking_prompt_half, max_num=8, min_num=3)
expressions = await expression_selector.select_suitable_expressions_llm(
chat_stream.stream_id, chat_talking_prompt_half, max_num=8, min_num=3
)
style_habbits = []
grammar_habbits = []
if expressions:

View File

@@ -136,6 +136,7 @@ class ChatConfig(ConfigBase):
float: 频率值,如果没有配置则返回 None
"""
from datetime import datetime
current_time = datetime.now().strftime("%H:%M")
current_hour, current_minute = map(int, current_time.split(":"))
current_minutes = current_hour * 60 + current_minute
@@ -227,6 +228,7 @@ class ChatConfig(ConfigBase):
# 使用与 ChatStream.get_stream_id 相同的逻辑生成 chat_id
import hashlib
if is_group:
components = [platform, str(id_str)]
else: