@@ -42,13 +42,38 @@ def is_mentioned_bot_in_message(message: MessageRecv) -> bool:
|
|||||||
"""检查消息是否提到了机器人"""
|
"""检查消息是否提到了机器人"""
|
||||||
keywords = [global_config.BOT_NICKNAME]
|
keywords = [global_config.BOT_NICKNAME]
|
||||||
nicknames = global_config.BOT_ALIAS_NAMES
|
nicknames = global_config.BOT_ALIAS_NAMES
|
||||||
|
reply_probability = 0
|
||||||
|
is_at = False
|
||||||
|
is_mentioned = False
|
||||||
|
|
||||||
|
# 判断是否被@
|
||||||
|
if re.search(f"@[\s\S]*?(id:{global_config.BOT_QQ})", message.processed_plain_text):
|
||||||
|
is_at = True
|
||||||
|
is_mentioned = True
|
||||||
|
|
||||||
|
if is_at and global_config.at_bot_inevitable_reply:
|
||||||
|
reply_probability = 1
|
||||||
|
logger.info("被@,回复概率设置为100%")
|
||||||
|
else:
|
||||||
|
if not is_mentioned:
|
||||||
|
|
||||||
|
# 判断是否被回复
|
||||||
|
if re.match(f"回复[\s\S]*?\({global_config.BOT_QQ}\)的消息,说:", message.processed_plain_text):
|
||||||
|
is_mentioned = True
|
||||||
|
|
||||||
|
# 判断内容中是否被提及
|
||||||
|
message_content = re.sub(r'\@[\s\S]*?((\d+))','', message.processed_plain_text)
|
||||||
|
message_content = re.sub(r'回复[\s\S]*?\((\d+)\)的消息,说: ','', message_content)
|
||||||
for keyword in keywords:
|
for keyword in keywords:
|
||||||
if keyword in message.processed_plain_text:
|
if keyword in message_content:
|
||||||
return True
|
is_mentioned = True
|
||||||
for nickname in nicknames:
|
for nickname in nicknames:
|
||||||
if nickname in message.processed_plain_text:
|
if nickname in message_content:
|
||||||
return True
|
is_mentioned = True
|
||||||
return False
|
if is_mentioned and global_config.mentioned_bot_inevitable_reply:
|
||||||
|
reply_probability = 1
|
||||||
|
logger.info("被提及,回复概率设置为100%")
|
||||||
|
return is_mentioned, reply_probability
|
||||||
|
|
||||||
|
|
||||||
async def get_embedding(text, request_type="embedding"):
|
async def get_embedding(text, request_type="embedding"):
|
||||||
|
|||||||
@@ -186,7 +186,8 @@ class ReasoningChat:
|
|||||||
logger.info("触发缓冲,已炸飞消息列")
|
logger.info("触发缓冲,已炸飞消息列")
|
||||||
return
|
return
|
||||||
|
|
||||||
is_mentioned = is_mentioned_bot_in_message(message)
|
# 处理提及
|
||||||
|
is_mentioned, reply_probability = is_mentioned_bot_in_message(message)
|
||||||
|
|
||||||
# 计算回复意愿
|
# 计算回复意愿
|
||||||
current_willing = willing_manager.get_willing(chat_stream=chat)
|
current_willing = willing_manager.get_willing(chat_stream=chat)
|
||||||
@@ -194,7 +195,7 @@ class ReasoningChat:
|
|||||||
|
|
||||||
# 意愿激活
|
# 意愿激活
|
||||||
timer1 = time.time()
|
timer1 = time.time()
|
||||||
reply_probability = await willing_manager.change_reply_willing_received(
|
real_reply_probability = await willing_manager.change_reply_willing_received(
|
||||||
chat_stream=chat,
|
chat_stream=chat,
|
||||||
is_mentioned_bot=is_mentioned,
|
is_mentioned_bot=is_mentioned,
|
||||||
config=global_config,
|
config=global_config,
|
||||||
@@ -202,6 +203,8 @@ class ReasoningChat:
|
|||||||
interested_rate=interested_rate,
|
interested_rate=interested_rate,
|
||||||
sender_id=str(message.message_info.user_info.user_id),
|
sender_id=str(message.message_info.user_info.user_id),
|
||||||
)
|
)
|
||||||
|
if reply_probability != 1 or (groupinfo and (groupinfo.group_id not in global_config.talk_allowed_groups)):
|
||||||
|
reply_probability = real_reply_probability
|
||||||
timer2 = time.time()
|
timer2 = time.time()
|
||||||
timing_results["意愿激活"] = timer2 - timer1
|
timing_results["意愿激活"] = timer2 - timer1
|
||||||
|
|
||||||
|
|||||||
@@ -211,7 +211,8 @@ class ThinkFlowChat:
|
|||||||
logger.info("触发缓冲,已炸飞消息列")
|
logger.info("触发缓冲,已炸飞消息列")
|
||||||
return
|
return
|
||||||
|
|
||||||
is_mentioned = is_mentioned_bot_in_message(message)
|
# 处理提及
|
||||||
|
is_mentioned, reply_probability = is_mentioned_bot_in_message(message)
|
||||||
|
|
||||||
|
|
||||||
# 计算回复意愿
|
# 计算回复意愿
|
||||||
@@ -226,7 +227,7 @@ class ThinkFlowChat:
|
|||||||
|
|
||||||
# 意愿激活
|
# 意愿激活
|
||||||
timer1 = time.time()
|
timer1 = time.time()
|
||||||
reply_probability = await willing_manager.change_reply_willing_received(
|
real_reply_probability = await willing_manager.change_reply_willing_received(
|
||||||
chat_stream=chat,
|
chat_stream=chat,
|
||||||
is_mentioned_bot=is_mentioned,
|
is_mentioned_bot=is_mentioned,
|
||||||
config=global_config,
|
config=global_config,
|
||||||
@@ -234,6 +235,8 @@ class ThinkFlowChat:
|
|||||||
interested_rate=interested_rate,
|
interested_rate=interested_rate,
|
||||||
sender_id=str(message.message_info.user_info.user_id),
|
sender_id=str(message.message_info.user_info.user_id),
|
||||||
)
|
)
|
||||||
|
if reply_probability != 1 or (groupinfo and (groupinfo.group_id not in global_config.talk_allowed_groups)):
|
||||||
|
reply_probability = real_reply_probability
|
||||||
timer2 = time.time()
|
timer2 = time.time()
|
||||||
timing_results["意愿激活"] = timer2 - timer1
|
timing_results["意愿激活"] = timer2 - timer1
|
||||||
logger.debug(f"意愿激活: {reply_probability}")
|
logger.debug(f"意愿激活: {reply_probability}")
|
||||||
|
|||||||
@@ -195,6 +195,8 @@ class BotConfig:
|
|||||||
response_interested_rate_amplifier: float = 1.0 # 回复兴趣度放大系数
|
response_interested_rate_amplifier: float = 1.0 # 回复兴趣度放大系数
|
||||||
down_frequency_rate: float = 3 # 降低回复频率的群组回复意愿降低系数
|
down_frequency_rate: float = 3 # 降低回复频率的群组回复意愿降低系数
|
||||||
emoji_response_penalty: float = 0.0 # 表情包回复惩罚
|
emoji_response_penalty: float = 0.0 # 表情包回复惩罚
|
||||||
|
mentioned_bot_inevitable_reply: bool = False # 提及 bot 必然回复
|
||||||
|
at_bot_inevitable_reply: bool = False # @bot 必然回复
|
||||||
|
|
||||||
# response
|
# response
|
||||||
response_mode: str = "heart_flow" # 回复策略
|
response_mode: str = "heart_flow" # 回复策略
|
||||||
@@ -439,6 +441,12 @@ class BotConfig:
|
|||||||
config.emoji_response_penalty = willing_config.get(
|
config.emoji_response_penalty = willing_config.get(
|
||||||
"emoji_response_penalty", config.emoji_response_penalty
|
"emoji_response_penalty", config.emoji_response_penalty
|
||||||
)
|
)
|
||||||
|
config.mentioned_bot_inevitable_reply = willing_config.get(
|
||||||
|
"mentioned_bot_inevitable_reply", config.mentioned_bot_inevitable_reply
|
||||||
|
)
|
||||||
|
config.at_bot_inevitable_reply = willing_config.get(
|
||||||
|
"at_bot_inevitable_reply", config.at_bot_inevitable_reply
|
||||||
|
)
|
||||||
|
|
||||||
def model(parent: dict):
|
def model(parent: dict):
|
||||||
# 加载模型配置
|
# 加载模型配置
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ response_willing_amplifier = 1 # 麦麦回复意愿放大系数,一般为1
|
|||||||
response_interested_rate_amplifier = 1 # 麦麦回复兴趣度放大系数,听到记忆里的内容时放大系数
|
response_interested_rate_amplifier = 1 # 麦麦回复兴趣度放大系数,听到记忆里的内容时放大系数
|
||||||
down_frequency_rate = 3 # 降低回复频率的群组回复意愿降低系数 除法
|
down_frequency_rate = 3 # 降低回复频率的群组回复意愿降低系数 除法
|
||||||
emoji_response_penalty = 0.1 # 表情包回复惩罚系数,设为0为不回复单个表情包,减少单独回复表情包的概率
|
emoji_response_penalty = 0.1 # 表情包回复惩罚系数,设为0为不回复单个表情包,减少单独回复表情包的概率
|
||||||
|
mentioned_bot_inevitable_reply = false # 提及 bot 必然回复
|
||||||
|
at_bot_inevitable_reply = false # @bot 必然回复
|
||||||
|
|
||||||
[emoji]
|
[emoji]
|
||||||
max_emoji_num = 120 # 表情包最大数量
|
max_emoji_num = 120 # 表情包最大数量
|
||||||
|
|||||||
Reference in New Issue
Block a user