mirror of https://github.com/Mai-with-u/MaiBot.git
添加了一个控制最低回复概率的设置项
parent
dfdae33f92
commit
28a775c249
|
|
@ -20,6 +20,7 @@ class BotConfig:
|
|||
MIN_TEXT_LENGTH: int = 2 # 最小处理文本长度
|
||||
MAX_CONTEXT_SIZE: int = 15 # 上下文最大消息数
|
||||
emoji_chance: float = 0.2 # 发送表情包的基础概率
|
||||
MIN_RESPONSE_RATE: float = 0.0 # 最小回复概率
|
||||
|
||||
ENABLE_PIC_TRANSLATE: bool = True # 是否启用图片翻译
|
||||
|
||||
|
|
@ -266,6 +267,7 @@ class BotConfig:
|
|||
config.MAX_CONTEXT_SIZE = msg_config.get("max_context_size", config.MAX_CONTEXT_SIZE)
|
||||
config.emoji_chance = msg_config.get("emoji_chance", config.emoji_chance)
|
||||
config.ban_words=msg_config.get("ban_words",config.ban_words)
|
||||
config.MIN_RESPONSE_RATE = msg_config.get("min_response_rate", config.MIN_RESPONSE_RATE)
|
||||
|
||||
if config.INNER_VERSION in SpecifierSet(">=0.0.2"):
|
||||
config.thinking_timeout = msg_config.get("thinking_timeout", config.thinking_timeout)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ class WillingManager:
|
|||
while True:
|
||||
await asyncio.sleep(5)
|
||||
for group_id in self.group_reply_willing:
|
||||
self.group_reply_willing[group_id] = max(0, self.group_reply_willing[group_id] * 0.6)
|
||||
self.group_reply_willing[group_id] = max(
|
||||
0, self.group_reply_willing[group_id] * 0.6
|
||||
)
|
||||
|
||||
def get_willing(self, group_id: int) -> float:
|
||||
"""获取指定群组的回复意愿"""
|
||||
|
|
@ -23,7 +25,16 @@ class WillingManager:
|
|||
"""设置指定群组的回复意愿"""
|
||||
self.group_reply_willing[group_id] = willing
|
||||
|
||||
def change_reply_willing_received(self, group_id: int, topic: str, is_mentioned_bot: bool, config, user_id: int = None, is_emoji: bool = False, interested_rate: float = 0) -> float:
|
||||
def change_reply_willing_received(
|
||||
self,
|
||||
group_id: int,
|
||||
topic: str,
|
||||
is_mentioned_bot: bool,
|
||||
config,
|
||||
user_id: int = None,
|
||||
is_emoji: bool = False,
|
||||
interested_rate: float = 0,
|
||||
) -> float:
|
||||
"""改变指定群组的回复意愿并返回回复概率"""
|
||||
current_willing = self.group_reply_willing.get(group_id, 0)
|
||||
|
||||
|
|
@ -39,13 +50,17 @@ class WillingManager:
|
|||
current_willing *= 0.1
|
||||
print(f"表情包, 当前意愿: {current_willing}")
|
||||
|
||||
print(f"放大系数_interested_rate: {global_config.response_interested_rate_amplifier}")
|
||||
interested_rate *= global_config.response_interested_rate_amplifier #放大回复兴趣度
|
||||
print(
|
||||
f"放大系数_interested_rate: {global_config.response_interested_rate_amplifier}"
|
||||
)
|
||||
interested_rate *= (
|
||||
global_config.response_interested_rate_amplifier
|
||||
) # 放大回复兴趣度
|
||||
if interested_rate > 0.4:
|
||||
# print(f"兴趣度: {interested_rate}, 当前意愿: {current_willing}")
|
||||
current_willing += interested_rate-0.4
|
||||
current_willing += interested_rate - 0.4
|
||||
|
||||
current_willing *= global_config.response_willing_amplifier #放大回复意愿
|
||||
current_willing *= global_config.response_willing_amplifier # 放大回复意愿
|
||||
# print(f"放大系数_willing: {global_config.response_willing_amplifier}, 当前意愿: {current_willing}")
|
||||
|
||||
reply_probability = max((current_willing - 0.45) * 2, 0)
|
||||
|
|
@ -56,11 +71,11 @@ class WillingManager:
|
|||
if group_id in config.talk_frequency_down_groups:
|
||||
reply_probability = reply_probability / global_config.down_frequency_rate
|
||||
|
||||
reply_probability += global_config.MIN_RESPONSE_RATE
|
||||
reply_probability = min(reply_probability, 1)
|
||||
if reply_probability < 0:
|
||||
reply_probability = 0
|
||||
|
||||
|
||||
self.group_reply_willing[group_id] = min(current_willing, 3.0)
|
||||
return reply_probability
|
||||
|
||||
|
|
@ -82,5 +97,6 @@ class WillingManager:
|
|||
self._decay_task = asyncio.create_task(self._decay_reply_willing())
|
||||
self._started = True
|
||||
|
||||
|
||||
# 创建全局实例
|
||||
willing_manager = WillingManager()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ min_text_length = 2 # 与麦麦聊天时麦麦只会回答文本大于等于此
|
|||
max_context_size = 15 # 麦麦获得的上文数量
|
||||
emoji_chance = 0.2 # 麦麦使用表情包的概率
|
||||
thinking_timeout = 120 # 麦麦思考时间
|
||||
min_response_rate = 0.1 # 最低回复概率
|
||||
|
||||
response_willing_amplifier = 1 # 麦麦回复意愿放大系数,一般为1
|
||||
response_interested_rate_amplifier = 1 # 麦麦回复兴趣度放大系数,听到记忆里的内容时放大系数
|
||||
|
|
|
|||
Loading…
Reference in New Issue