feat:处理器处理时间上限,处理并行模式,planner和思考prompt,循环观察器大优化
feat:增加了处理器处理时间上限,记忆处理并行模式,优化了planner和思考prompt,优化了循环观察器
This commit is contained in:
@@ -26,8 +26,8 @@ class NoReplyAction(BaseAction):
|
||||
action_parameters = {}
|
||||
action_require = [
|
||||
"话题无关/无聊/不感兴趣/不懂",
|
||||
"最后一条消息是你自己发的且无人回应你",
|
||||
"你发送了太多消息,且无人回复",
|
||||
"聊天记录中最新一条消息是你自己发的且无人回应你",
|
||||
"你连续发送了太多消息,且无人回复",
|
||||
]
|
||||
default = True
|
||||
|
||||
|
||||
@@ -28,11 +28,8 @@ class ActionModifier:
|
||||
async def modify_actions(
|
||||
self,
|
||||
observations: Optional[List[Observation]] = None,
|
||||
running_memorys: Optional[List[Dict]] = None,
|
||||
**kwargs: Any,
|
||||
):
|
||||
# print(f"observations: {observations}")
|
||||
# processed_infos = []
|
||||
|
||||
# 处理Observation对象
|
||||
if observations:
|
||||
|
||||
@@ -26,9 +26,8 @@ def init_prompt():
|
||||
"""
|
||||
你的自我认知是:
|
||||
{self_info_block}
|
||||
|
||||
{extra_info_block}
|
||||
|
||||
{memory_str}
|
||||
你需要基于以下信息决定如何参与对话
|
||||
这些信息可能会有冲突,请你整合这些信息,并选择一个最合适的action:
|
||||
{chat_content_block}
|
||||
@@ -49,7 +48,7 @@ def init_prompt():
|
||||
请你以下面格式输出你选择的action:
|
||||
{{
|
||||
"action": "action_name",
|
||||
"reasoning": "你的决策理由",
|
||||
"reasoning": "说明你做出该action的原因",
|
||||
"参数1": "参数1的值",
|
||||
"参数2": "参数2的值",
|
||||
"参数3": "参数3的值",
|
||||
@@ -84,13 +83,13 @@ class ActionPlanner:
|
||||
|
||||
self.action_manager = action_manager
|
||||
|
||||
async def plan(self, all_plan_info: List[InfoBase], cycle_timers: dict) -> Dict[str, Any]:
|
||||
async def plan(self, all_plan_info: List[InfoBase], running_memorys: List[Dict[str, Any]]) -> Dict[str, Any]:
|
||||
"""
|
||||
规划器 (Planner): 使用LLM根据上下文决定做出什么动作。
|
||||
|
||||
参数:
|
||||
all_plan_info: 所有计划信息
|
||||
cycle_timers: 计时器字典
|
||||
running_memorys: 回忆信息
|
||||
"""
|
||||
|
||||
action = "no_reply" # 默认动作
|
||||
@@ -169,6 +168,7 @@ class ActionPlanner:
|
||||
current_available_actions=current_available_actions, # <-- Pass determined actions
|
||||
cycle_info=cycle_info, # <-- Pass cycle info
|
||||
extra_info=extra_info,
|
||||
running_memorys=running_memorys,
|
||||
)
|
||||
|
||||
# --- 调用 LLM (普通文本生成) ---
|
||||
@@ -259,10 +259,22 @@ class ActionPlanner:
|
||||
current_available_actions: Dict[str, ActionInfo],
|
||||
cycle_info: Optional[str],
|
||||
extra_info: list[str],
|
||||
running_memorys: List[Dict[str, Any]],
|
||||
) -> str:
|
||||
"""构建 Planner LLM 的提示词 (获取模板并填充数据)"""
|
||||
try:
|
||||
# --- Determine chat context ---
|
||||
|
||||
memory_str = ""
|
||||
if global_config.focus_chat.parallel_processing:
|
||||
memory_str = ""
|
||||
if running_memorys:
|
||||
memory_str = "以下是当前在聊天中,你回忆起的记忆:\n"
|
||||
for running_memory in running_memorys:
|
||||
memory_str += f"{running_memory['topic']}: {running_memory['content']}\n"
|
||||
|
||||
|
||||
|
||||
|
||||
chat_context_description = "你现在正在一个群聊中"
|
||||
chat_target_name = None # Only relevant for private
|
||||
if not is_group_chat and chat_target_info:
|
||||
@@ -324,6 +336,7 @@ class ActionPlanner:
|
||||
planner_prompt_template = await global_prompt_manager.get_prompt_async("planner_prompt")
|
||||
prompt = planner_prompt_template.format(
|
||||
self_info_block=self_info_block,
|
||||
memory_str=memory_str,
|
||||
# bot_name=global_config.bot.nickname,
|
||||
prompt_personality=personality_block,
|
||||
chat_context_description=chat_context_description,
|
||||
|
||||
Reference in New Issue
Block a user