Merge branch 'debug' of https://github.com/Pliosauroidea/MaiMBot into debug
This commit is contained in:
@@ -13,6 +13,7 @@ from ..memory_system.memory import hippocampus
|
||||
from ..moods.moods import MoodManager # 导入情绪管理器
|
||||
from .config import global_config
|
||||
from .cq_code import CQCode, cq_code_tool # 导入CQCode模块
|
||||
from .cq_code import CQCode, cq_code_tool # 导入CQCode模块
|
||||
from .emoji_manager import emoji_manager # 导入表情包管理器
|
||||
from .llm_generator import ResponseGenerator
|
||||
from .message import MessageSending, MessageRecv, MessageThinking, MessageSet
|
||||
@@ -30,6 +31,7 @@ from .willing_manager import willing_manager # 导入意愿管理器
|
||||
from .message_base import UserInfo, GroupInfo, Seg
|
||||
|
||||
|
||||
|
||||
class ChatBot:
|
||||
def __init__(self):
|
||||
self.storage = MessageStorage()
|
||||
@@ -95,6 +97,7 @@ class ChatBot:
|
||||
# group_info = await bot.get_group_info(group_id=event.group_id)
|
||||
# sender_info = await bot.get_group_member_info(group_id=event.group_id, user_id=event.user_id, no_cache=True)
|
||||
|
||||
message_cq = MessageRecvCQ(
|
||||
message_cq = MessageRecvCQ(
|
||||
message_id=event.message_id,
|
||||
user_info=user_info,
|
||||
@@ -102,18 +105,29 @@ class ChatBot:
|
||||
group_info=group_info,
|
||||
reply_message=event.reply,
|
||||
platform="qq",
|
||||
platform="qq",
|
||||
)
|
||||
message_json = message_cq.to_dict()
|
||||
message_json = message_cq.to_dict()
|
||||
|
||||
# 进入maimbot
|
||||
message = MessageRecv(message_json)
|
||||
|
||||
groupinfo = message.message_info.group_info
|
||||
userinfo = message.message_info.user_info
|
||||
messageinfo = message.message_info
|
||||
message = MessageRecv(message_json)
|
||||
|
||||
groupinfo = message.message_info.group_info
|
||||
userinfo = message.message_info.user_info
|
||||
messageinfo = message.message_info
|
||||
|
||||
# 消息过滤,涉及到config有待更新
|
||||
|
||||
chat = await chat_manager.get_or_create_stream(
|
||||
platform=messageinfo.platform, user_info=userinfo, group_info=groupinfo
|
||||
)
|
||||
|
||||
chat = await chat_manager.get_or_create_stream(
|
||||
platform=messageinfo.platform, user_info=userinfo, group_info=groupinfo
|
||||
)
|
||||
@@ -150,6 +164,7 @@ class ChatBot:
|
||||
|
||||
# topic=await topic_identifier.identify_topic_llm(message.processed_plain_text)
|
||||
topic = ""
|
||||
topic = ""
|
||||
interested_rate = 0
|
||||
interested_rate = (
|
||||
await hippocampus.memory_activate_value(message.processed_plain_text) / 100
|
||||
@@ -159,6 +174,8 @@ class ChatBot:
|
||||
|
||||
await self.storage.store_message(message, chat, topic[0] if topic else None)
|
||||
|
||||
await self.storage.store_message(message, chat, topic[0] if topic else None)
|
||||
|
||||
is_mentioned = is_mentioned_bot_in_message(message)
|
||||
reply_probability = await willing_manager.change_reply_willing_received(
|
||||
chat_stream=chat,
|
||||
@@ -167,9 +184,11 @@ class ChatBot:
|
||||
config=global_config,
|
||||
is_emoji=message.is_emoji,
|
||||
interested_rate=interested_rate,
|
||||
interested_rate=interested_rate,
|
||||
)
|
||||
current_willing = willing_manager.get_willing(chat_stream=chat)
|
||||
|
||||
|
||||
logger.info(
|
||||
f"[{current_time}][{chat.group_info.group_name if chat.group_info.group_id else '私聊'}]{chat.user_info.user_nickname}:"
|
||||
f"{message.processed_plain_text}[回复意愿:{current_willing:.2f}][概率:{reply_probability * 100:.1f}%]"
|
||||
@@ -177,6 +196,7 @@ class ChatBot:
|
||||
|
||||
response = None
|
||||
|
||||
|
||||
if random() < reply_probability:
|
||||
bot_user_info = UserInfo(
|
||||
user_id=global_config.BOT_QQ,
|
||||
@@ -192,12 +212,16 @@ class ChatBot:
|
||||
reply=message,
|
||||
)
|
||||
|
||||
|
||||
message_manager.add_message(thinking_message)
|
||||
|
||||
willing_manager.change_reply_willing_sent(chat)
|
||||
|
||||
response, raw_content = await self.gpt.generate_response(message)
|
||||
|
||||
|
||||
response, raw_content = await self.gpt.generate_response(message)
|
||||
|
||||
# print(f"response: {response}")
|
||||
if response:
|
||||
# print(f"有response: {response}")
|
||||
@@ -257,7 +281,7 @@ class ChatBot:
|
||||
print(f"添加message_set到message_manager")
|
||||
message_manager.add_message(message_set)
|
||||
|
||||
bot_response_time = tinking_time_point
|
||||
bot_response_time = thinking_time_point
|
||||
|
||||
if random() < global_config.emoji_chance:
|
||||
emoji_raw = await emoji_manager.get_emoji_for_text(response)
|
||||
@@ -269,7 +293,7 @@ class ChatBot:
|
||||
emoji_cq = image_path_to_base64(emoji_path)
|
||||
|
||||
if random() < 0.5:
|
||||
bot_response_time = tinking_time_point - 1
|
||||
bot_response_time = thinking_time_point - 1
|
||||
else:
|
||||
bot_response_time = bot_response_time + 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user