ruff format
This commit is contained in:
@@ -42,5 +42,5 @@ class ActionObservation:
|
||||
"observe_id": self.observe_id,
|
||||
"last_observe_time": self.last_observe_time,
|
||||
"all_actions": self.all_actions,
|
||||
"all_using_actions": self.all_using_actions
|
||||
"all_using_actions": self.all_using_actions,
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class ChattingObservation(Observation):
|
||||
"person_list": self.person_list,
|
||||
"oldest_messages_str": self.oldest_messages_str,
|
||||
"compressor_prompt": self.compressor_prompt,
|
||||
"last_observe_time": self.last_observe_time
|
||||
"last_observe_time": self.last_observe_time,
|
||||
}
|
||||
|
||||
async def initialize(self):
|
||||
|
||||
@@ -39,7 +39,7 @@ class HFCloopObservation:
|
||||
responses_for_prompt = []
|
||||
|
||||
cycle_last_reason = ""
|
||||
|
||||
|
||||
# 检查这最近的活动循环中有多少是连续的文本回复 (从最近的开始看)
|
||||
for cycle in recent_active_cycles:
|
||||
action_type = cycle.loop_plan_info["action_result"]["action_type"]
|
||||
@@ -57,29 +57,33 @@ class HFCloopObservation:
|
||||
action_reasoning_str = f"你选择这个action的原因是:{action_reasoning}"
|
||||
else:
|
||||
action_reasoning_str = ""
|
||||
|
||||
|
||||
if action_type == "reply":
|
||||
consecutive_text_replies += 1
|
||||
response_text = cycle.loop_plan_info["action_result"]["action_data"].get("text", "[空回复]")
|
||||
responses_for_prompt.append(response_text)
|
||||
|
||||
|
||||
if is_taken:
|
||||
action_detailed_str += f"{action_taken_time_str}时,你选择回复(action:{action_type},内容是:'{response_text}')。{action_reasoning_str}\n"
|
||||
else:
|
||||
action_detailed_str += f"{action_taken_time_str}时,你选择回复(action:{action_type},内容是:'{response_text}'),但是动作失败了。{action_reasoning_str}\n"
|
||||
elif action_type == "no_reply":
|
||||
action_detailed_str += f"{action_taken_time_str}时,你选择不回复(action:{action_type}),{action_reasoning_str}\n"
|
||||
action_detailed_str += (
|
||||
f"{action_taken_time_str}时,你选择不回复(action:{action_type}),{action_reasoning_str}\n"
|
||||
)
|
||||
else:
|
||||
if is_taken:
|
||||
action_detailed_str += f"{action_taken_time_str}时,你选择执行了(action:{action_type}),{action_reasoning_str}\n"
|
||||
action_detailed_str += (
|
||||
f"{action_taken_time_str}时,你选择执行了(action:{action_type}),{action_reasoning_str}\n"
|
||||
)
|
||||
else:
|
||||
action_detailed_str += f"{action_taken_time_str}时,你选择执行了(action:{action_type}),但是动作失败了。{action_reasoning_str}\n"
|
||||
|
||||
|
||||
if action_detailed_str:
|
||||
cycle_info_block = f"\n你最近做的事:\n{action_detailed_str}\n"
|
||||
else:
|
||||
cycle_info_block = "\n"
|
||||
|
||||
|
||||
# 根据连续文本回复的数量构建提示信息
|
||||
if consecutive_text_replies >= 3: # 如果最近的三个活动都是文本回复
|
||||
cycle_info_block = f'你已经连续回复了三条消息(最近: "{responses_for_prompt[0]}",第二近: "{responses_for_prompt[1]}",第三近: "{responses_for_prompt[2]}")。你回复的有点多了,请注意'
|
||||
@@ -116,5 +120,5 @@ class HFCloopObservation:
|
||||
"observe_id": self.observe_id,
|
||||
"last_observe_time": self.last_observe_time,
|
||||
# 不序列化history_loop,避免循环引用
|
||||
"history_loop_count": len(self.history_loop)
|
||||
"history_loop_count": len(self.history_loop),
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class Observation:
|
||||
return {
|
||||
"observe_info": self.observe_info,
|
||||
"observe_id": self.observe_id,
|
||||
"last_observe_time": self.last_observe_time
|
||||
"last_observe_time": self.last_observe_time,
|
||||
}
|
||||
|
||||
async def observe(self):
|
||||
|
||||
@@ -22,7 +22,7 @@ class StructureObservation:
|
||||
"observe_id": self.observe_id,
|
||||
"last_observe_time": self.last_observe_time,
|
||||
"history_loop": self.history_loop,
|
||||
"structured_info": self.structured_info
|
||||
"structured_info": self.structured_info,
|
||||
}
|
||||
|
||||
def get_observe_info(self):
|
||||
|
||||
@@ -39,6 +39,10 @@ class WorkingMemoryObservation:
|
||||
"observe_info": self.observe_info,
|
||||
"observe_id": self.observe_id,
|
||||
"last_observe_time": self.last_observe_time,
|
||||
"working_memory": self.working_memory.to_dict() if hasattr(self.working_memory, 'to_dict') else str(self.working_memory),
|
||||
"retrieved_working_memory": [item.to_dict() if hasattr(item, 'to_dict') else str(item) for item in self.retrieved_working_memory]
|
||||
"working_memory": self.working_memory.to_dict()
|
||||
if hasattr(self.working_memory, "to_dict")
|
||||
else str(self.working_memory),
|
||||
"retrieved_working_memory": [
|
||||
item.to_dict() if hasattr(item, "to_dict") else str(item) for item in self.retrieved_working_memory
|
||||
],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user