fix:优化prompt和Logger

This commit is contained in:
SengokuCola
2025-06-03 18:15:31 +08:00
parent 4cb3850d0c
commit b3744528e5
10 changed files with 20 additions and 14 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 657 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 884 KiB

View File

@@ -412,7 +412,7 @@ class EmojiManager:
except Exception as e:
logger.error(f"记录表情使用失败: {str(e)}")
async def get_emoji_for_text(self, text_emotion: str) -> Optional[Tuple[str, str]]:
async def get_emoji_for_text(self, text_emotion: str) -> Optional[Tuple[str, str, str]]:
"""根据文本内容获取相关表情包
Args:
text_emotion: 输入的情感描述文本
@@ -478,7 +478,7 @@ class EmojiManager:
f"为[{text_emotion}]找到表情包: {matched_emotion} ({selected_emoji.filename}), Similarity: {similarity:.4f}"
)
# 返回完整文件路径和描述
return selected_emoji.full_path, f"[ {selected_emoji.description} ]"
return selected_emoji.full_path, f"[ {selected_emoji.description} ]", matched_emotion
except Exception as e:
logger.error(f"[错误] 获取表情包失败: {str(e)}")

View File

@@ -476,7 +476,7 @@ class DefaultExpressor:
emoji_base64 = ""
emoji_raw = await emoji_manager.get_emoji_for_text(send_emoji)
if emoji_raw:
emoji_path, _description = emoji_raw
emoji_path, _description, _emotion = emoji_raw
emoji_base64 = image_path_to_base64(emoji_path)
return emoji_base64

View File

@@ -527,7 +527,7 @@ class HeartFChatting:
else:
action_str = action_type
logger.debug(f"{self.log_prefix} 麦麦想要:'{action_str}', 原因'{reasoning}'")
logger.debug(f"{self.log_prefix} 麦麦想要:'{action_str}'")
success, reply_text, command = await self._handle_action(
action_type, reasoning, action_data, cycle_timers, thinking_id

View File

@@ -31,6 +31,7 @@ def init_prompt():
现在请你根据现有的信息,总结你和群里的人的关系
1. 当聊天记录中提到你时,请输出你和这个人之间的关系
2. 当聊天记录中提到其他人时,请输出你和这个人之间的关系
3. 如果没有特别需要提及的关系,请输出“没有特别在意的人”
输出内容平淡一些,说中文。
请注意不要输出多余内容(包括前后缀,括号()表情包at或 @等 )。只输出关系内容,记得明确说明这是你的关系。
@@ -130,9 +131,10 @@ class RelationshipProcessor(BaseProcessor):
name_block = f"你的名字是{global_config.bot.nickname},你的昵称有{nickname_str},有人也会用这些昵称称呼你。"
if is_group_chat:
relation_prompt_init = "在这个群聊中,你\n"
relation_prompt_init = "你对群聊里的人的印象是\n"
else:
relation_prompt_init = ""
relation_prompt_init = "你对对方的印象是:\n"
for person in person_list:
relation_prompt += await relationship_manager.build_relationship_info(person, is_id=True)
if relation_prompt:

View File

@@ -163,7 +163,7 @@ class SelfProcessor(BaseProcessor):
if content == "None":
content = ""
# 记录初步思考结果
logger.debug(f"{self.log_prefix} 自我识别prompt: \n{prompt}\n")
# logger.debug(f"{self.log_prefix} 自我识别prompt: \n{prompt}\n")
logger.info(f"{self.log_prefix} 自我认知: {content}")
return content

View File

@@ -120,7 +120,7 @@ class WorkingMemoryProcessor(BaseProcessor):
memory_str=memory_choose_str,
)
print(f"prompt: {prompt}")
# print(f"prompt: {prompt}")
# 调用LLM处理记忆
content = ""
@@ -197,7 +197,7 @@ class WorkingMemoryProcessor(BaseProcessor):
"""
try:
await working_memory.add_memory(content=content, from_source="chat_text")
logger.debug(f"{self.log_prefix} 异步添加新记忆成功: {content[:30]}...")
# logger.debug(f"{self.log_prefix} 异步添加新记忆成功: {content[:30]}...")
except Exception as e:
logger.error(f"{self.log_prefix} 异步添加新记忆失败: {e}")
logger.error(traceback.format_exc())
@@ -211,7 +211,7 @@ class WorkingMemoryProcessor(BaseProcessor):
"""
try:
merged_memory = await working_memory.merge_memory(memory_id1, memory_id2)
logger.debug(f"{self.log_prefix} 异步合并记忆成功: {memory_id1}{memory_id2}...")
# logger.debug(f"{self.log_prefix} 异步合并记忆成功: {memory_id1} 和 {memory_id2}...")
logger.debug(f"{self.log_prefix} 合并后的记忆梗概: {merged_memory.summary.get('brief')}")
logger.debug(f"{self.log_prefix} 合并后的记忆要点: {merged_memory.summary.get('points')}")

View File

@@ -19,11 +19,15 @@ class EmojiAction(BaseAction):
"""
action_name: str = "emoji"
action_description: str = "当你想单独发送一个表情辅助你的回复表达"
action_description: str = "当你想单独发送一个表情辅助你的回复表达"
action_parameters: dict[str:str] = {
"description": "文字描述你想要发送的表情",
"description": "文字描述你想要发送的表情包内容",
}
action_require: list[str] = ["你想要发送一个表情", "表达情绪时可以选择使用", "一般在你回复之后可以选择性使用"]
action_require: list[str] = [
"你想要发送一个表情",
"表达情绪时可以选择使用",
"一般在你回复之后可以选择性使用",
"重点:不要连续发,不要发太多[表情包]"]
associated_types: list[str] = ["emoji"]

View File

@@ -136,7 +136,7 @@ class LLMRequest:
try:
# 使用 Peewee 创建表safe=True 表示如果表已存在则不会抛出错误
db.create_tables([LLMUsage], safe=True)
logger.debug("LLMUsage 表已初始化/确保存在。")
# logger.debug("LLMUsage 表已初始化/确保存在。")
except Exception as e:
logger.error(f"创建 LLMUsage 表失败: {str(e)}")