diff --git a/changelogs/changelog.md b/changelogs/changelog.md index 5eb93dc82..160d21a81 100644 --- a/changelogs/changelog.md +++ b/changelogs/changelog.md @@ -3,6 +3,9 @@ ## [0.7.1] -2025-6-2 - 修复关键词功能,并且在focus中可用 - 更新planner架构,大大加快速度和表现效果,建议使用simple规划器 +- 为normal加入使用action的能力 +- 修复emoji配置项无效问题 + - 修复log出错问题 - 修复focus吞第一条消息问题 diff --git a/src/api/config_api.py b/src/api/config_api.py index d28b1e809..9af2a30ea 100644 --- a/src/api/config_api.py +++ b/src/api/config_api.py @@ -71,7 +71,6 @@ class APIBotConfig: max_emoji_num: int # 最大表情符号数量 max_reach_deletion: bool # 达到最大数量时是否删除 check_interval: int # 检查表情包的时间间隔(分钟) - save_pic: bool # 是否保存图片 save_emoji: bool # 是否保存表情包 steal_emoji: bool # 是否偷取表情包 enable_check: bool # 是否启用表情包过滤 diff --git a/src/chat/focus_chat/replyer/default_replyer.py b/src/chat/focus_chat/replyer/default_replyer.py index 88f78d1fd..759236511 100644 --- a/src/chat/focus_chat/replyer/default_replyer.py +++ b/src/chat/focus_chat/replyer/default_replyer.py @@ -30,6 +30,11 @@ logger = get_logger("expressor") def init_prompt(): Prompt( """ +你可以参考以下的语言习惯,如果情景合适就使用,不要盲目使用,不要生硬使用,而是结合到表达中: +{style_habbits} +请你根据情景使用以下句法: +{grammar_habbits} + {extra_info_block} {time_block} @@ -40,11 +45,7 @@ def init_prompt(): {chat_target} {identity},在这聊天中,"{target_message}"引起了你的注意,你想要在群里发言或者回复这条消息。 -你需要使用合适的语法和句法,参考聊天内容,组织一条日常且口语化的回复。注意不要复读你说过的话。 -你可以参考以下的语言习惯,如果情景合适就使用,不要盲目使用,不要生硬使用,而是结合到表达中: -{style_habbits} -请你根据情景使用以下句法: -{grammar_habbits} +你需要使用合适的语言习惯和句法,参考聊天内容,组织一条日常且口语化的回复。注意不要复读你说过的话。 {config_expression_style},请注意不要输出多余内容(包括前后缀,冒号和引号,括号(),表情包,at或 @等 )。只输出回复内容。 {keywords_reaction_prompt} 请不要输出违法违规内容,不要输出色情,暴力,政治相关内容,如有敏感内容,请规避。 diff --git a/src/chat/focus_chat/working_memory/memory_manager.py b/src/chat/focus_chat/working_memory/memory_manager.py index 19fef5e7a..cccb213b2 100644 --- a/src/chat/focus_chat/working_memory/memory_manager.py +++ b/src/chat/focus_chat/working_memory/memory_manager.py @@ -234,7 +234,7 @@ class MemoryManager: 请按以下JSON格式输出: {{ "brief": "记忆内容主题", - "content": [ + "points": [ "内容", "内容" ] @@ -243,7 +243,7 @@ class MemoryManager: """ default_summary = { "brief": "主题未知的记忆", - "content": ["未知的要点"], + "points": ["未知的要点"], } try: @@ -276,13 +276,13 @@ class MemoryManager: json_result["brief"] = "主题未知的记忆" # 处理关键要点 - if "content" not in json_result or not isinstance(json_result["content"], list): - json_result["content"] = ["未知的要点"] + if "points" not in json_result or not isinstance(json_result["points"], list): + json_result["points"] = ["未知的要点"] else: - # 确保content中的每个项目都是字符串 - json_result["content"] = [str(point) for point in json_result["content"] if point is not None] - if not json_result["content"]: - json_result["content"] = ["未知的要点"] + # 确保points中的每个项目都是字符串 + json_result["points"] = [str(point) for point in json_result["points"] if point is not None] + if not json_result["points"]: + json_result["points"] = ["未知的要点"] return json_result @@ -327,15 +327,15 @@ class MemoryManager: 目前主题:{summary["brief"]} 目前关键要点: -{chr(10).join([f"- {point}" for point in summary.get("content", [])])} +{chr(10).join([f"- {point}" for point in summary.get("points", [])])} 请生成修改后的主题和关键要点,遵循以下格式: ```json {{ "brief": "修改后的主题(20字以内)", - "content": [ - "修改后的要点1:解释或描述", - "修改后的要点2:解释或描述" + "points": [ + "修改后的要点", + "修改后的要点" ] }} ``` @@ -344,7 +344,7 @@ class MemoryManager: # 定义默认的精简结果 default_refined = { "brief": summary["brief"], - "content": summary.get("content", ["未知的要点"])[:1], # 默认只保留第一个要点 + "points": summary.get("points", ["未知的要点"])[:1], # 默认只保留第一个要点 } try: @@ -376,13 +376,13 @@ class MemoryManager: summary["brief"] = refined_data.get("brief", "主题未知的记忆") # 更新关键要点 - content = refined_data.get("content", []) - if isinstance(content, list) and content: + points = refined_data.get("points", []) + if isinstance(points, list) and points: # 确保所有要点都是字符串 - summary["content"] = [str(point) for point in content if point is not None] + summary["points"] = [str(point) for point in points if point is not None] else: - # 如果content不是列表或为空,使用默认值 - summary["content"] = ["主要要点已遗忘"] + # 如果points不是列表或为空,使用默认值 + summary["points"] = ["主要要点已遗忘"] except Exception as e: logger.error(f"精简记忆出错: {str(e)}") @@ -390,7 +390,7 @@ class MemoryManager: # 出错时使用简化的默认精简 summary["brief"] = summary["brief"] + " (已简化)" - summary["content"] = summary.get("content", ["未知的要点"])[:1] + summary["points"] = summary.get("points", ["未知的要点"])[:1] except Exception as e: logger.error(f"精简记忆调用LLM出错: {str(e)}") @@ -509,11 +509,11 @@ class MemoryManager: # 如果有摘要信息,添加到提示中 if summary1: prompt += f"记忆1主题:{summary1['brief']}\n" - prompt += "记忆1关键要点:\n" + "\n".join([f"- {point}" for point in summary1.get("content", [])]) + "\n\n" + prompt += "记忆1关键要点:\n" + "\n".join([f"- {point}" for point in summary1.get("points", [])]) + "\n\n" if summary2: prompt += f"记忆2主题:{summary2['brief']}\n" - prompt += "记忆2关键要点:\n" + "\n".join([f"- {point}" for point in summary2.get("content", [])]) + "\n\n" + prompt += "记忆2关键要点:\n" + "\n".join([f"- {point}" for point in summary2.get("points", [])]) + "\n\n" # 添加记忆原始内容 prompt += f""" @@ -528,10 +528,9 @@ class MemoryManager: {{ "content": "合并后的记忆内容文本(尽可能保留原信息,但去除重复)", "brief": "合并后的主题(20字以内)", - "content": [ - "合并后的要点1:解释或描述", - "合并后的要点2:解释或描述", - "合并后的要点3:解释或描述" + "points": [ + "合并后的要点", + "合并后的要点" ] }} ``` @@ -542,18 +541,18 @@ class MemoryManager: default_merged = { "content": f"{content1}\n\n{content2}", "brief": f"合并:{summary1['brief']} + {summary2['brief']}", - "content": [], + "points": [], } - # 合并content - if "content" in summary1: - default_merged["content"].extend(summary1["content"]) - if "content" in summary2: - default_merged["content"].extend(summary2["content"]) + # 合并points + if "points" in summary1: + default_merged["points"].extend(summary1["points"]) + if "points" in summary2: + default_merged["points"].extend(summary2["points"]) # 确保列表不为空 - if not default_merged["content"]: - default_merged["content"] = ["合并的要点"] + if not default_merged["points"]: + default_merged["points"] = ["合并的要点"] try: # 调用LLM合并记忆 @@ -588,13 +587,13 @@ class MemoryManager: merged_data["brief"] = default_merged["brief"] # 处理关键要点 - if "content" not in merged_data or not isinstance(merged_data["content"], list): - merged_data["content"] = default_merged["content"] + if "points" not in merged_data or not isinstance(merged_data["points"], list): + merged_data["points"] = default_merged["points"] else: - # 确保content中的每个项目都是字符串 - merged_data["content"] = [str(point) for point in merged_data["content"] if point is not None] - if not merged_data["content"]: - merged_data["content"] = ["合并的要点"] + # 确保points中的每个项目都是字符串 + merged_data["points"] = [str(point) for point in merged_data["points"] if point is not None] + if not merged_data["points"]: + merged_data["points"] = ["合并的要点"] except Exception as e: logger.error(f"合并记忆时处理JSON出错: {str(e)}") @@ -622,7 +621,7 @@ class MemoryManager: # 设置合并后的摘要 summary = { "brief": merged_data["brief"], - "content": merged_data["content"], + "points": merged_data["points"], } merged_memory.set_summary(summary)