临时的energy方式, fix ActivationType
This commit is contained in:
@@ -212,10 +212,14 @@ class HeartFChatting:
|
||||
return True
|
||||
|
||||
if new_messages_data:
|
||||
self.energy_value += 2 * len(new_messages_data) / global_config.chat.focus_value
|
||||
earliest_messages_data = new_messages_data[0]
|
||||
self.last_read_time = earliest_messages_data.get("time")
|
||||
|
||||
await self.normal_response(earliest_messages_data)
|
||||
if await self.normal_response(earliest_messages_data):
|
||||
self.energy_value += 8 / global_config.chat.focus_value
|
||||
if self.energy_value >= 100:
|
||||
self.loop_mode = ChatMode.FOCUS
|
||||
return True
|
||||
|
||||
await asyncio.sleep(1)
|
||||
@@ -531,12 +535,12 @@ class HeartFChatting:
|
||||
f"意愿放大器更新为: {self.willing_amplifier:.2f}"
|
||||
)
|
||||
|
||||
async def normal_response(self, message_data: dict) -> None:
|
||||
async def normal_response(self, message_data: dict) -> bool:
|
||||
"""
|
||||
处理接收到的消息。
|
||||
在"兴趣"模式下,判断是否回复并生成内容。
|
||||
"""
|
||||
|
||||
responded = False
|
||||
is_mentioned = message_data.get("is_mentioned", False)
|
||||
interested_rate = message_data.get("interest_rate", 0.0) * self.willing_amplifier
|
||||
|
||||
@@ -573,10 +577,11 @@ class HeartFChatting:
|
||||
|
||||
if random.random() < reply_probability:
|
||||
await self.willing_manager.before_generate_reply_handle(message_data.get("message_id", ""))
|
||||
await self._observe(message_data=message_data)
|
||||
responded = await self._observe(message_data=message_data)
|
||||
|
||||
# 意愿管理器:注销当前message信息 (无论是否回复,只要处理过就删除)
|
||||
self.willing_manager.delete(message_data.get("message_id", ""))
|
||||
return responded
|
||||
|
||||
async def _generate_response(
|
||||
self, message_data: dict, available_actions: Optional[Dict[str, ActionInfo]], reply_to: str
|
||||
|
||||
@@ -24,8 +24,8 @@ class NoReplyAction(BaseAction):
|
||||
2. 累计新消息数量达到随机阈值 (默认5-10条) 则结束等待
|
||||
"""
|
||||
|
||||
focus_activation_type = ActionActivationType.NEVER
|
||||
normal_activation_type = ActionActivationType.NEVER
|
||||
focus_activation_type = ActionActivationType.ALWAYS
|
||||
normal_activation_type = ActionActivationType.ALWAYS
|
||||
mode_enable = ChatMode.FOCUS
|
||||
parallel_action = False
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ class ReplyAction(BaseAction):
|
||||
"""回复动作 - 参与聊天回复"""
|
||||
|
||||
# 激活设置
|
||||
focus_activation_type = ActionActivationType.NEVER
|
||||
normal_activation_type = ActionActivationType.NEVER
|
||||
focus_activation_type = ActionActivationType.ALWAYS
|
||||
normal_activation_type = ActionActivationType.ALWAYS
|
||||
mode_enable = ChatMode.FOCUS
|
||||
parallel_action = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user