feat(planner): 优化主动对话决策并记录动作历史
在主动对话规划器中引入最近的动作历史作为决策依据,以避免重复或不合时宜的主动行为。同时,在主动回复后,将该行为作为动作信息存储到数据库中,以便于未来的决策和分析。 - 在 `ActionPlanner` 中,获取并向prompt中添加最近5条动作历史记录 - 在 `ProactiveThinker` 中,当主动回复成功后,调用 `store_action_info` 记录动作 - 移除了 `@user` 插件中已废弃的 `planner_type` 属性
This commit is contained in:
@@ -15,6 +15,7 @@ from src.plugin_system.base.component_types import ComponentType
|
||||
from src.config.config import global_config
|
||||
from src.chat.utils.chat_message_builder import get_raw_msg_before_timestamp_with_chat, build_readable_messages_with_id
|
||||
from src.mood.mood_manager import mood_manager
|
||||
from src.common.database.sqlalchemy_database_api import store_action_info
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..cycle_processor import CycleProcessor
|
||||
@@ -237,6 +238,13 @@ class ProactiveThinker:
|
||||
await self.cycle_processor.response_handler.send_response(
|
||||
response_set, time.time(), action_result.get("action_message")
|
||||
)
|
||||
await store_action_info(
|
||||
chat_stream=self.context.chat_stream,
|
||||
action_name="proactive_reply",
|
||||
action_data={"topic": topic, "response": response_text},
|
||||
action_prompt_display=f"主动发起对话: {topic}",
|
||||
action_done=True,
|
||||
)
|
||||
else:
|
||||
logger.error(f"{self.context.log_prefix} 主动思考生成回复失败。")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user