feat(chat): 增强prompt构建功能并优化回复逻辑
- 为HfcContext和ChatStream添加focus_energy配置支持 - 修复默认回复生成器中识别自身消息的逻辑 - 完整实现prompt构建中的表达习惯、记忆、工具信息和知识模块 - 优化错误处理,使用原生异常链式传递 - 确保数据库操作中focus_energy字段的持久化 这些改进提升了聊天系统的上下文感知能力和回复质量,同时增强了模块的健壮性和可维护性。
This commit is contained in:
committed by
Windpicker-owo
parent
bd8b6232ca
commit
14a70496f7
@@ -139,8 +139,6 @@ def init_prompt():
|
||||
--------------------------------
|
||||
{time_block}
|
||||
|
||||
{reply_target_block}
|
||||
|
||||
注意不要复读你前面发过的内容,意思相近也不行。
|
||||
|
||||
请注意不要输出多余内容(包括前后缀,冒号和引号,at或 @等 )。只输出回复内容。
|
||||
@@ -878,16 +876,22 @@ class DefaultReplyer:
|
||||
reply_message.get("user_id"), # type: ignore
|
||||
)
|
||||
person_name = await person_info_manager.get_value(person_id, "person_name")
|
||||
sender = person_name
|
||||
|
||||
# 检查是否是bot自己的名字,如果是则替换为"(你)"
|
||||
bot_user_id = str(global_config.bot.qq_account)
|
||||
current_user_id = person_info_manager.get_value_sync(person_id, "user_id")
|
||||
current_platform = reply_message.get("chat_info_platform")
|
||||
|
||||
if current_user_id == bot_user_id and current_platform == global_config.bot.platform:
|
||||
sender = f"{person_name}(你)"
|
||||
else:
|
||||
# 如果不是bot自己,直接使用person_name
|
||||
sender = person_name
|
||||
target = reply_message.get("processed_plain_text")
|
||||
|
||||
person_info_manager = get_person_info_manager()
|
||||
person_id = person_info_manager.get_person_id_by_person_name(sender)
|
||||
user_id = person_info_manager.get_value_sync(person_id, "user_id")
|
||||
platform = chat_stream.platform
|
||||
if user_id == global_config.bot.qq_account and platform == global_config.bot.platform:
|
||||
logger.warning("选取了自身作为回复对象,跳过构建prompt")
|
||||
return ""
|
||||
|
||||
target = replace_user_references_sync(target, chat_stream.platform, replace_bot_name=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user