This commit is contained in:
SengokuCola
2025-05-29 10:16:36 +08:00
7 changed files with 29 additions and 126 deletions

View File

@@ -212,7 +212,7 @@ class ExpressionLearner:
# random_msg_str: str = await build_readable_messages(random_msg, timestamp_mode="normal")
random_msg_str: str = await build_anonymous_messages(random_msg)
# print(f"random_msg_str:{random_msg_str}")
prompt: str = await global_prompt_manager.format_prompt(
prompt,
chat_str=random_msg_str,

View File

@@ -339,7 +339,9 @@ class HeartFChatting:
for pname, ptime in processor_time_costs.items():
formatted_ptime = f"{ptime * 1000:.2f}毫秒" if ptime < 1 else f"{ptime:.2f}"
processor_time_strings.append(f"{pname}: {formatted_ptime}")
processor_time_log = ("\n各处理器耗时: " + "; ".join(processor_time_strings)) if processor_time_strings else ""
processor_time_log = (
("\n各处理器耗时: " + "; ".join(processor_time_strings)) if processor_time_strings else ""
)
logger.info(
f"{self.log_prefix}{self._current_cycle.cycle_id}次思考,"
@@ -481,7 +483,9 @@ class HeartFChatting:
observations.append(self.action_observation)
with Timer("执行 信息处理器", cycle_timers):
all_plan_info, processor_time_costs = await self._process_processors(observations, running_memorys, cycle_timers)
all_plan_info, processor_time_costs = await self._process_processors(
observations, running_memorys, cycle_timers
)
loop_processor_info = {
"all_plan_info": all_plan_info,

View File

@@ -451,13 +451,13 @@ async def build_anonymous_messages(messages: List[Dict[str, Any]]) -> str:
def get_anon_name(platform, user_id):
# print(f"get_anon_name: platform:{platform}, user_id:{user_id}")
# print(f"global_config.bot.qq_account:{global_config.bot.qq_account}")
if user_id == global_config.bot.qq_account:
# print("SELF11111111111111")
return "SELF"
try:
person_id = person_info_manager.get_person_id(platform, user_id)
except Exception as e:
except Exception as _e:
person_id = None
if not person_id:
return "?"
@@ -472,7 +472,7 @@ async def build_anonymous_messages(messages: List[Dict[str, Any]]) -> str:
# user_info = msg.get("user_info", {})
platform = msg.get("chat_info_platform")
user_id = msg.get("user_id")
timestamp = msg.get("time")
_timestamp = msg.get("time")
# print(f"msg:{msg}")
# print(f"platform:{platform}")
# print(f"user_id:{user_id}")
@@ -488,11 +488,11 @@ async def build_anonymous_messages(messages: List[Dict[str, Any]]) -> str:
content = content.replace("", "")
# if not all([platform, user_id, timestamp is not None]):
# continue
# continue
anon_name = get_anon_name(platform, user_id)
# print(f"anon_name:{anon_name}")
# 处理 回复<aaa:bbb>
reply_pattern = r"回复<([^:<>]+):([^:<>]+)>"
match = re.search(reply_pattern, content)
@@ -514,7 +514,7 @@ async def build_anonymous_messages(messages: List[Dict[str, Any]]) -> str:
new_content = ""
last_end = 0
for m in at_matches:
new_content += content[last_end:m.start()]
new_content += content[last_end : m.start()]
bbb = m.group(2)
try:
anon_at = get_anon_name(platform, bbb)