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