🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -693,7 +693,6 @@ class NormalChat:
|
||||
f"[{self.stream_name}] 用户 {person_id} 消息次数更新: {self.engaging_persons[person_id]['receive_count']}"
|
||||
)
|
||||
|
||||
|
||||
async def _check_relation_building_conditions(self):
|
||||
"""检查engaging_persons中是否有满足关系构建条件的用户"""
|
||||
current_time = time.time()
|
||||
@@ -701,9 +700,7 @@ class NormalChat:
|
||||
for person_id, stats in list(self.engaging_persons.items()):
|
||||
# 计算时间差和消息数量
|
||||
time_elapsed = current_time - stats["first_time"]
|
||||
total_messages = self._get_total_messages_in_timerange(
|
||||
stats["first_time"], stats["last_time"]
|
||||
)
|
||||
total_messages = self._get_total_messages_in_timerange(stats["first_time"], stats["last_time"])
|
||||
|
||||
print(f"person_id: {person_id}, total_messages: {total_messages}, time_elapsed: {time_elapsed}")
|
||||
|
||||
@@ -729,7 +726,6 @@ class NormalChat:
|
||||
del self.engaging_persons[person_id]
|
||||
logger.info(f"[{self.stream_name}] 用户 {person_id} 评估完成,已移除记录,将重新开始统计")
|
||||
|
||||
|
||||
def _get_total_messages_in_timerange(self, start_time: float, end_time: float) -> int:
|
||||
"""获取指定时间范围内的总消息数量"""
|
||||
try:
|
||||
@@ -752,14 +748,22 @@ class NormalChat:
|
||||
# k=7时,0.05比率对应约0.4概率,0.1比率对应约0.6概率,0.2比率对应约0.8概率
|
||||
k_reply = 7
|
||||
base_reply_prob = 0.1 # 基础概率10%
|
||||
reply_build_probability = (math.log(1 + reply_ratio * k_reply) / math.log(1 + k_reply)) * 0.9 + base_reply_prob if reply_ratio > 0 else base_reply_prob
|
||||
reply_build_probability = (
|
||||
(math.log(1 + reply_ratio * k_reply) / math.log(1 + k_reply)) * 0.9 + base_reply_prob
|
||||
if reply_ratio > 0
|
||||
else base_reply_prob
|
||||
)
|
||||
|
||||
# 计算接收概率(receive_count的影响)
|
||||
receive_ratio = receive_count / total_messages if total_messages > 0 else 0
|
||||
# 接收概率使用更温和的对数曲线,最大0.5,基础0.08
|
||||
k_receive = 6
|
||||
base_receive_prob = 0.08 # 基础概率8%
|
||||
receive_build_probability = (math.log(1 + receive_ratio * k_receive) / math.log(1 + k_receive)) * 0.42 + base_receive_prob if receive_ratio > 0 else base_receive_prob
|
||||
receive_build_probability = (
|
||||
(math.log(1 + receive_ratio * k_receive) / math.log(1 + k_receive)) * 0.42 + base_receive_prob
|
||||
if receive_ratio > 0
|
||||
else base_receive_prob
|
||||
)
|
||||
|
||||
# 取最高概率
|
||||
final_probability = max(reply_build_probability, receive_build_probability)
|
||||
|
||||
Reference in New Issue
Block a user