From b57671b6390df9af2d39db8e38f3bcb3aafc8c9c Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Sat, 9 Aug 2025 21:16:57 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E8=A1=A8?= =?UTF-8?q?=E6=83=85=E5=8C=85=E6=8F=8F=E8=BF=B0=E8=BF=9B=E5=85=A5prompt?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + run_voice.bat | 2 -- src/chat/chat_loop/heartFC_chat.py | 1 - src/chat/message_receive/message.py | 50 +---------------------------- src/chat/utils/utils_image.py | 13 +++++++- src/config/config.py | 2 +- template/bot_config_template.toml | 11 ++++--- 7 files changed, 21 insertions(+), 59 deletions(-) delete mode 100644 run_voice.bat diff --git a/.gitignore b/.gitignore index f51b8d6f9..61ce5df22 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ logs/ out/ tool_call_benchmark.py run_maibot_core.bat +run_voice.bat run_napcat_adapter.bat run_ad.bat s4u.s4u diff --git a/run_voice.bat b/run_voice.bat deleted file mode 100644 index d4c8b0c64..000000000 --- a/run_voice.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -start "Voice Adapter" cmd /k "call conda activate maicore && cd /d C:\GitHub\maimbot_tts_adapter && echo Running Napcat Adapter... && python maimbot_pipeline.py" \ No newline at end of file diff --git a/src/chat/chat_loop/heartFC_chat.py b/src/chat/chat_loop/heartFC_chat.py index c0266d410..988705d01 100644 --- a/src/chat/chat_loop/heartFC_chat.py +++ b/src/chat/chat_loop/heartFC_chat.py @@ -308,7 +308,6 @@ class HeartFChatting: return loop_info, reply_text, cycle_timers async def _observe(self, message_data: Optional[Dict[str, Any]] = None) -> bool: - # sourcery skip: hoist-statement-from-if, merge-comparisons, reintroduce-else if not message_data: message_data = {} action_type = "no_action" diff --git a/src/chat/message_receive/message.py b/src/chat/message_receive/message.py index 5c7e0940e..3ac962d54 100644 --- a/src/chat/message_receive/message.py +++ b/src/chat/message_receive/message.py @@ -370,7 +370,7 @@ class MessageProcessBase(Message): return "[图片,网卡了加载不出来]" elif seg.type == "emoji": if isinstance(seg.data, str): - return await get_image_manager().get_emoji_description(seg.data) + return await get_image_manager().get_emoji_tag(seg.data) return "[表情,网卡了加载不出来]" elif seg.type == "voice": if isinstance(seg.data, str): @@ -400,34 +400,6 @@ class MessageProcessBase(Message): return f"[{timestamp}],{name} 说:{self.processed_plain_text}\n" -@dataclass -class MessageThinking(MessageProcessBase): - """思考状态的消息类""" - - def __init__( - self, - message_id: str, - chat_stream: "ChatStream", - bot_user_info: UserInfo, - reply: Optional["MessageRecv"] = None, - thinking_start_time: float = 0, - timestamp: Optional[float] = None, - ): - # 调用父类初始化,传递时间戳 - super().__init__( - message_id=message_id, - chat_stream=chat_stream, - bot_user_info=bot_user_info, - message_segment=None, # 思考状态不需要消息段 - reply=reply, - thinking_start_time=thinking_start_time, - timestamp=timestamp, - ) - - # 思考状态特有属性 - self.interrupt = False - - @dataclass class MessageSending(MessageProcessBase): """发送状态的消息类""" @@ -488,26 +460,6 @@ class MessageSending(MessageProcessBase): if self.message_segment: self.processed_plain_text = await self._process_message_segments(self.message_segment) - # @classmethod - # def from_thinking( - # cls, - # thinking: MessageThinking, - # message_segment: Seg, - # is_head: bool = False, - # is_emoji: bool = False, - # ) -> "MessageSending": - # """从思考状态消息创建发送状态消息""" - # return cls( - # message_id=thinking.message_info.message_id, - # chat_stream=thinking.chat_stream, - # message_segment=message_segment, - # bot_user_info=thinking.message_info.user_info, - # reply=thinking.reply, - # is_head=is_head, - # is_emoji=is_emoji, - # sender_info=None, - # ) - def to_dict(self): ret = super().to_dict() ret["message_info"]["user_info"] = self.chat_stream.user_info.to_dict() diff --git a/src/chat/utils/utils_image.py b/src/chat/utils/utils_image.py index fcf1c717c..b03df6ad1 100644 --- a/src/chat/utils/utils_image.py +++ b/src/chat/utils/utils_image.py @@ -92,6 +92,18 @@ class ImageManager: desc_obj.save() except Exception as e: logger.error(f"保存描述到数据库失败 (Peewee): {str(e)}") + + async def get_emoji_tag(self, image_base64: str) -> str: + from src.chat.emoji_system.emoji_manager import get_emoji_manager + emoji_manager = get_emoji_manager() + if isinstance(image_base64, str): + image_base64 = image_base64.encode("ascii", errors="ignore").decode("ascii") + image_bytes = base64.b64decode(image_base64) + image_hash = hashlib.md5(image_bytes).hexdigest() + emoji = await emoji_manager.get_emoji_from_manager(image_hash) + emotion_list = emoji.emotion + tag_str = ",".join(emotion_list) + return f"[表情包:{tag_str}]" async def get_emoji_description(self, image_base64: str) -> str: """获取表情包描述,优先使用Emoji表中的缓存数据""" @@ -107,7 +119,6 @@ class ImageManager: # 优先使用EmojiManager查询已注册表情包的描述 try: from src.chat.emoji_system.emoji_manager import get_emoji_manager - emoji_manager = get_emoji_manager() cached_emoji_description = await emoji_manager.get_emoji_description_by_hash(image_hash) if cached_emoji_description: diff --git a/src/config/config.py b/src/config/config.py index 368adaa57..a9f926b58 100644 --- a/src/config/config.py +++ b/src/config/config.py @@ -57,7 +57,7 @@ TEMPLATE_DIR = os.path.join(PROJECT_ROOT, "template") # 考虑到,实际上配置文件中的mai_version是不会自动更新的,所以采用硬编码 # 对该字段的更新,请严格参照语义化版本规范:https://semver.org/lang/zh-CN/ -MMC_VERSION = "0.10.0-snapshot.4" +MMC_VERSION = "0.10.0-snapshot.5" def get_key_comment(toml_table, key): diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index efeb631d7..626d552f0 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -53,11 +53,6 @@ expression_groups = [ ] -[relationship] -enable_relationship = true # 是否启用关系系统 -relation_frequency = 1 # 关系频率,麦麦构建关系的频率 - - [chat] #麦麦的聊天通用设置 focus_value = 1 # 麦麦的专注思考能力,越高越容易专注,可能消耗更多token @@ -96,6 +91,12 @@ talk_frequency_adjust = [ # - 后续元素是"时间,频率"格式,表示从该时间开始使用该活跃度,直到下一个时间点 # - 优先级:特定聊天流配置 > 全局配置 > 默认 talk_frequency + +[relationship] +enable_relationship = true # 是否启用关系系统 +relation_frequency = 1 # 关系频率,麦麦构建关系的频率 + + [message_receive] # 以下是消息过滤,可以根据规则过滤特定消息,将不会读取这些消息 ban_words = [