From 58ff4ea76566922595af02406bd8abb8069d9d0b Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Tue, 29 Apr 2025 19:21:03 +0800 Subject: [PATCH] fuk:fucc --- scripts/count.py | 8 ++--- .../heartFC_chat/heartflow_prompt_builder.py | 31 +++++++------------ .../person_info/relationship_manager.py | 5 +-- src/plugins/utils/chat_message_builder.py | 2 +- 4 files changed, 17 insertions(+), 29 deletions(-) diff --git a/scripts/count.py b/scripts/count.py index a0e66dd0c..f7370875a 100644 --- a/scripts/count.py +++ b/scripts/count.py @@ -1,16 +1,16 @@ def 计算字符串长度(输入字符串: str) -> int: """计算输入字符串的长度 - + 参数: 输入字符串: 要计算长度的字符串 - + 返回: 字符串的长度(整数) """ return len(输入字符串) + if __name__ == "__main__": # 测试代码 - 测试字符串 = '''你。''' + 测试字符串 = """你。""" print(f"字符串 '{测试字符串}' 的长度是: {计算字符串长度(测试字符串)}") - diff --git a/src/plugins/heartFC_chat/heartflow_prompt_builder.py b/src/plugins/heartFC_chat/heartflow_prompt_builder.py index 9eb6d6fd3..009474224 100644 --- a/src/plugins/heartFC_chat/heartflow_prompt_builder.py +++ b/src/plugins/heartFC_chat/heartflow_prompt_builder.py @@ -124,7 +124,6 @@ def init_prompt(): "reasoning_prompt_main", ) - Prompt( "你回忆起:{related_memory_info}。\n以上是你的回忆,不一定是目前聊天里的人说的,也不一定是现在发生的事情,请记住。\n", "memory_prompt", @@ -197,24 +196,20 @@ class PromptBuilder: ("给出日常且口语化的回复,平淡一些", 0.4), # 40%概率 ("给出非常简短的回复", 0.4), # 40%概率 ("给出缺失主语的回复,简短", 0.15), # 15%概率 - ("给出带有语病的回复,朴实平淡", 0.05) # 5%概率 + ("给出带有语病的回复,朴实平淡", 0.05), # 5%概率 ] reply_style1_chosen = random.choices( - [style[0] for style in reply_styles1], - weights=[style[1] for style in reply_styles1], - k=1 + [style[0] for style in reply_styles1], weights=[style[1] for style in reply_styles1], k=1 )[0] - + reply_styles2 = [ ("不要回复的太有条理,可以有个性", 0.6), # 60%概率 ("不要回复的太有条理,可以复读", 0.15), # 15%概率 ("回复的认真一些", 0.2), # 20%概率 - ("可以回复单个表情符号", 0.05) # 5%概率 + ("可以回复单个表情符号", 0.05), # 5%概率 ] reply_style2_chosen = random.choices( - [style[0] for style in reply_styles2], - weights=[style[1] for style in reply_styles2], - k=1 + [style[0] for style in reply_styles2], weights=[style[1] for style in reply_styles2], k=1 )[0] if structured_info: @@ -271,29 +266,25 @@ class PromptBuilder: mood_prompt = mood_manager.get_prompt() # logger.info(f"心情prompt: {mood_prompt}") - + reply_styles1 = [ ("然后给出日常且口语化的回复,平淡一些", 0.4), # 40%概率 ("给出非常简短的回复", 0.4), # 40%概率 ("给出缺失主语的回复", 0.15), # 15%概率 - ("给出带有语病的回复", 0.05) # 5%概率 + ("给出带有语病的回复", 0.05), # 5%概率 ] reply_style1_chosen = random.choices( - [style[0] for style in reply_styles1], - weights=[style[1] for style in reply_styles1], - k=1 + [style[0] for style in reply_styles1], weights=[style[1] for style in reply_styles1], k=1 )[0] - + reply_styles2 = [ ("不要回复的太有条理,可以有个性", 0.6), # 60%概率 ("不要回复的太有条理,可以复读", 0.15), # 15%概率 ("回复的认真一些", 0.2), # 20%概率 - ("可以回复单个表情符号", 0.05) # 5%概率 + ("可以回复单个表情符号", 0.05), # 5%概率 ] reply_style2_chosen = random.choices( - [style[0] for style in reply_styles2], - weights=[style[1] for style in reply_styles2], - k=1 + [style[0] for style in reply_styles2], weights=[style[1] for style in reply_styles2], k=1 )[0] # 调取记忆 diff --git a/src/plugins/person_info/relationship_manager.py b/src/plugins/person_info/relationship_manager.py index 5110e2e6d..640c12b8b 100644 --- a/src/plugins/person_info/relationship_manager.py +++ b/src/plugins/person_info/relationship_manager.py @@ -292,10 +292,7 @@ class RelationshipManager: "友善和包容的回复", ] - return ( - f"你{relationship_level[level_num]}{person_name}," - f"打算{relation_prompt2_list[level_num]}。\n" - ) + return f"你{relationship_level[level_num]}{person_name},打算{relation_prompt2_list[level_num]}。\n" @staticmethod def calculate_level_num(relationship_value) -> int: diff --git a/src/plugins/utils/chat_message_builder.py b/src/plugins/utils/chat_message_builder.py index 7844572ab..87ffb2d1f 100644 --- a/src/plugins/utils/chat_message_builder.py +++ b/src/plugins/utils/chat_message_builder.py @@ -284,7 +284,7 @@ async def _build_readable_messages_internal( if not stripped_line.endswith("(内容太长)"): output_lines.append(f"{stripped_line};") else: - output_lines.append(stripped_line) # 直接添加截断后的内容 + output_lines.append(stripped_line) # 直接添加截断后的内容 output_lines.append("\n") # 在每个消息块后添加换行,保持可读性 # 移除可能的多余换行,然后合并