fix:修复表情包描述进入prompt问题
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,6 +7,7 @@ logs/
|
|||||||
out/
|
out/
|
||||||
tool_call_benchmark.py
|
tool_call_benchmark.py
|
||||||
run_maibot_core.bat
|
run_maibot_core.bat
|
||||||
|
run_voice.bat
|
||||||
run_napcat_adapter.bat
|
run_napcat_adapter.bat
|
||||||
run_ad.bat
|
run_ad.bat
|
||||||
s4u.s4u
|
s4u.s4u
|
||||||
|
|||||||
@@ -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"
|
|
||||||
@@ -308,7 +308,6 @@ class HeartFChatting:
|
|||||||
return loop_info, reply_text, cycle_timers
|
return loop_info, reply_text, cycle_timers
|
||||||
|
|
||||||
async def _observe(self, message_data: Optional[Dict[str, Any]] = None) -> bool:
|
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:
|
if not message_data:
|
||||||
message_data = {}
|
message_data = {}
|
||||||
action_type = "no_action"
|
action_type = "no_action"
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ class MessageProcessBase(Message):
|
|||||||
return "[图片,网卡了加载不出来]"
|
return "[图片,网卡了加载不出来]"
|
||||||
elif seg.type == "emoji":
|
elif seg.type == "emoji":
|
||||||
if isinstance(seg.data, str):
|
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 "[表情,网卡了加载不出来]"
|
return "[表情,网卡了加载不出来]"
|
||||||
elif seg.type == "voice":
|
elif seg.type == "voice":
|
||||||
if isinstance(seg.data, str):
|
if isinstance(seg.data, str):
|
||||||
@@ -400,34 +400,6 @@ class MessageProcessBase(Message):
|
|||||||
return f"[{timestamp}],{name} 说:{self.processed_plain_text}\n"
|
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
|
@dataclass
|
||||||
class MessageSending(MessageProcessBase):
|
class MessageSending(MessageProcessBase):
|
||||||
"""发送状态的消息类"""
|
"""发送状态的消息类"""
|
||||||
@@ -488,26 +460,6 @@ class MessageSending(MessageProcessBase):
|
|||||||
if self.message_segment:
|
if self.message_segment:
|
||||||
self.processed_plain_text = await self._process_message_segments(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):
|
def to_dict(self):
|
||||||
ret = super().to_dict()
|
ret = super().to_dict()
|
||||||
ret["message_info"]["user_info"] = self.chat_stream.user_info.to_dict()
|
ret["message_info"]["user_info"] = self.chat_stream.user_info.to_dict()
|
||||||
|
|||||||
@@ -92,6 +92,18 @@ class ImageManager:
|
|||||||
desc_obj.save()
|
desc_obj.save()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"保存描述到数据库失败 (Peewee): {str(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:
|
async def get_emoji_description(self, image_base64: str) -> str:
|
||||||
"""获取表情包描述,优先使用Emoji表中的缓存数据"""
|
"""获取表情包描述,优先使用Emoji表中的缓存数据"""
|
||||||
@@ -107,7 +119,6 @@ class ImageManager:
|
|||||||
# 优先使用EmojiManager查询已注册表情包的描述
|
# 优先使用EmojiManager查询已注册表情包的描述
|
||||||
try:
|
try:
|
||||||
from src.chat.emoji_system.emoji_manager import get_emoji_manager
|
from src.chat.emoji_system.emoji_manager import get_emoji_manager
|
||||||
|
|
||||||
emoji_manager = get_emoji_manager()
|
emoji_manager = get_emoji_manager()
|
||||||
cached_emoji_description = await emoji_manager.get_emoji_description_by_hash(image_hash)
|
cached_emoji_description = await emoji_manager.get_emoji_description_by_hash(image_hash)
|
||||||
if cached_emoji_description:
|
if cached_emoji_description:
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ TEMPLATE_DIR = os.path.join(PROJECT_ROOT, "template")
|
|||||||
|
|
||||||
# 考虑到,实际上配置文件中的mai_version是不会自动更新的,所以采用硬编码
|
# 考虑到,实际上配置文件中的mai_version是不会自动更新的,所以采用硬编码
|
||||||
# 对该字段的更新,请严格参照语义化版本规范:https://semver.org/lang/zh-CN/
|
# 对该字段的更新,请严格参照语义化版本规范: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):
|
def get_key_comment(toml_table, key):
|
||||||
|
|||||||
@@ -53,11 +53,6 @@ expression_groups = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
[relationship]
|
|
||||||
enable_relationship = true # 是否启用关系系统
|
|
||||||
relation_frequency = 1 # 关系频率,麦麦构建关系的频率
|
|
||||||
|
|
||||||
|
|
||||||
[chat] #麦麦的聊天通用设置
|
[chat] #麦麦的聊天通用设置
|
||||||
focus_value = 1
|
focus_value = 1
|
||||||
# 麦麦的专注思考能力,越高越容易专注,可能消耗更多token
|
# 麦麦的专注思考能力,越高越容易专注,可能消耗更多token
|
||||||
@@ -96,6 +91,12 @@ talk_frequency_adjust = [
|
|||||||
# - 后续元素是"时间,频率"格式,表示从该时间开始使用该活跃度,直到下一个时间点
|
# - 后续元素是"时间,频率"格式,表示从该时间开始使用该活跃度,直到下一个时间点
|
||||||
# - 优先级:特定聊天流配置 > 全局配置 > 默认 talk_frequency
|
# - 优先级:特定聊天流配置 > 全局配置 > 默认 talk_frequency
|
||||||
|
|
||||||
|
|
||||||
|
[relationship]
|
||||||
|
enable_relationship = true # 是否启用关系系统
|
||||||
|
relation_frequency = 1 # 关系频率,麦麦构建关系的频率
|
||||||
|
|
||||||
|
|
||||||
[message_receive]
|
[message_receive]
|
||||||
# 以下是消息过滤,可以根据规则过滤特定消息,将不会读取这些消息
|
# 以下是消息过滤,可以根据规则过滤特定消息,将不会读取这些消息
|
||||||
ban_words = [
|
ban_words = [
|
||||||
|
|||||||
Reference in New Issue
Block a user