feat:为focus的no_reply决策加入更多信息,可以自定义频率
This commit is contained in:
@@ -20,7 +20,7 @@ class HFCVersionManager:
|
||||
"""HFC版本号管理器"""
|
||||
|
||||
# 默认版本号
|
||||
DEFAULT_VERSION = "v3.0.0"
|
||||
DEFAULT_VERSION = "v3.1.0"
|
||||
|
||||
# 当前运行时版本号
|
||||
_current_version: Optional[str] = None
|
||||
|
||||
@@ -774,7 +774,7 @@ class PersonImpressionpProcessor(BaseProcessor):
|
||||
chat_id: 聊天ID
|
||||
segments: 消息段列表
|
||||
"""
|
||||
logger.info(f"开始为 {person_id} 基于 {len(segments)} 个消息段更新印象")
|
||||
logger.debug(f"开始为 {person_id} 基于 {len(segments)} 个消息段更新印象")
|
||||
try:
|
||||
processed_messages = []
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class MemoryActivator:
|
||||
for working_info_item in working_info:
|
||||
obs_info_text += f"{working_info_item['type']}: {working_info_item['content']}\n"
|
||||
|
||||
logger.info(f"回忆待检索内容:obs_info_text: {obs_info_text}")
|
||||
# logger.info(f"回忆待检索内容:obs_info_text: {obs_info_text}")
|
||||
|
||||
# 将缓存的关键词转换为字符串,用于prompt
|
||||
cached_keywords_str = ", ".join(self.cached_keywords) if self.cached_keywords else "暂无历史关键词"
|
||||
|
||||
@@ -68,7 +68,7 @@ class ActionModifier:
|
||||
hfc_obs = obs
|
||||
if isinstance(obs, ChattingObservation):
|
||||
chat_obs = obs
|
||||
chat_content = obs.talking_message_str_truncate
|
||||
chat_content = obs.talking_message_str_truncate_short
|
||||
|
||||
# 合并所有动作变更
|
||||
merged_action_changes = {"add": [], "remove": []}
|
||||
|
||||
@@ -1008,21 +1008,21 @@ class NormalChat:
|
||||
# 计算回复频率
|
||||
_reply_frequency = bot_reply_count / total_message_count
|
||||
|
||||
differ = global_config.normal_chat.talk_frequency - (bot_reply_count / duration)
|
||||
differ = global_config.chat.talk_frequency - (bot_reply_count / duration)
|
||||
|
||||
# 如果回复频率低于0.5,增加回复概率
|
||||
if differ > 0.1:
|
||||
mapped = 1 + (differ - 0.1) * 4 / 0.9
|
||||
mapped = max(1, min(5, mapped))
|
||||
logger.debug(
|
||||
f"[{self.stream_name}] 回复频率低于{global_config.normal_chat.talk_frequency},增加回复概率,differ={differ:.3f},映射值={mapped:.2f}"
|
||||
f"[{self.stream_name}] 回复频率低于{global_config.chat.talk_frequency},增加回复概率,differ={differ:.3f},映射值={mapped:.2f}"
|
||||
)
|
||||
self.willing_amplifier += mapped * 0.1 # 你可以根据实际需要调整系数
|
||||
elif differ < -0.1:
|
||||
mapped = 1 - (differ + 0.1) * 4 / 0.9
|
||||
mapped = max(1, min(5, mapped))
|
||||
logger.debug(
|
||||
f"[{self.stream_name}] 回复频率高于{global_config.normal_chat.talk_frequency},减少回复概率,differ={differ:.3f},映射值={mapped:.2f}"
|
||||
f"[{self.stream_name}] 回复频率高于{global_config.chat.talk_frequency},减少回复概率,differ={differ:.3f},映射值={mapped:.2f}"
|
||||
)
|
||||
self.willing_amplifier -= mapped * 0.1
|
||||
|
||||
@@ -1120,7 +1120,7 @@ class NormalChat:
|
||||
if not segments:
|
||||
return
|
||||
|
||||
logger.info(f"[{self.stream_name}] 开始为 {person_id} 基于 {len(segments)} 个消息段更新印象")
|
||||
logger.debug(f"[{self.stream_name}] 开始为 {person_id} 基于 {len(segments)} 个消息段更新印象")
|
||||
try:
|
||||
processed_messages = []
|
||||
|
||||
@@ -1132,7 +1132,7 @@ class NormalChat:
|
||||
|
||||
# 获取该段的消息(包含边界)
|
||||
segment_messages = get_raw_msg_by_timestamp_with_chat_inclusive(self.stream_id, start_time, end_time)
|
||||
logger.info(
|
||||
logger.debug(
|
||||
f"[{self.stream_name}] 消息段 {i + 1}: {start_date} - {time.strftime('%Y-%m-%d %H:%M', time.localtime(end_time))}, 消息数: {len(segment_messages)}"
|
||||
)
|
||||
|
||||
@@ -1160,7 +1160,7 @@ class NormalChat:
|
||||
# 按时间排序所有消息(包括间隔标识)
|
||||
processed_messages.sort(key=lambda x: x["time"])
|
||||
|
||||
logger.info(
|
||||
logger.debug(
|
||||
f"[{self.stream_name}] 为 {person_id} 获取到总共 {len(processed_messages)} 条消息(包含间隔标识)用于印象更新"
|
||||
)
|
||||
relationship_manager = get_relationship_manager()
|
||||
@@ -1170,7 +1170,7 @@ class NormalChat:
|
||||
person_id=person_id, timestamp=time.time(), bot_engaged_messages=processed_messages
|
||||
)
|
||||
else:
|
||||
logger.info(f"[{self.stream_name}] 没有找到 {person_id} 的消息段对应的消息,不更新印象")
|
||||
logger.debug(f"[{self.stream_name}] 没有找到 {person_id} 的消息段对应的消息,不更新印象")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"[{self.stream_name}] 为 {person_id} 更新印象时发生错误: {e}")
|
||||
|
||||
@@ -52,7 +52,7 @@ class ClassicalWillingManager(BaseWillingManager):
|
||||
# 检查群组权限(如果是群聊)
|
||||
if (
|
||||
willing_info.group_info
|
||||
and willing_info.group_info.group_id in global_config.normal_chat.talk_frequency_down_groups
|
||||
and willing_info.group_info.group_id in global_config.chat.talk_frequency_down_groups
|
||||
):
|
||||
reply_probability = reply_probability / global_config.normal_chat.down_frequency_rate
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ class MxpWillingManager(BaseWillingManager):
|
||||
if w_info.is_picid:
|
||||
probability = 0 # picid格式消息直接不回复
|
||||
|
||||
if w_info.group_info and w_info.group_info.group_id in global_config.normal_chat.talk_frequency_down_groups:
|
||||
if w_info.group_info and w_info.group_info.group_id in global_config.chat.talk_frequency_down_groups:
|
||||
probability /= global_config.normal_chat.down_frequency_rate
|
||||
|
||||
self.temporary_willing = current_willing
|
||||
|
||||
@@ -487,7 +487,7 @@ def build_pic_mapping_info(pic_id_mapping: Dict[str, str]) -> str:
|
||||
|
||||
for pic_id, display_name in sorted_items:
|
||||
# 从数据库中获取图片描述
|
||||
description = "内容正在阅读"
|
||||
description = "内容正在阅读,请稍等"
|
||||
try:
|
||||
image = Images.get_or_none(Images.image_id == pic_id)
|
||||
if image and image.description:
|
||||
|
||||
Reference in New Issue
Block a user