better:继续优化
This commit is contained in:
@@ -234,9 +234,8 @@ class DefaultExpressor:
|
||||
|
||||
# logger.info(f"{self.log_prefix}\nPrompt:\n{prompt}\n---------------------------\n")
|
||||
|
||||
logger.info(f"想要表达:{in_mind_reply}")
|
||||
logger.info(f"理由:{reason}")
|
||||
logger.info(f"生成回复: {content}\n")
|
||||
logger.info(f"想要表达:{in_mind_reply}||理由:{reason}")
|
||||
logger.info(f"最终回复: {content}\n")
|
||||
|
||||
info_catcher.catch_after_llm_generated(
|
||||
prompt=prompt, response=content, reasoning_content=reasoning_content, model_name=model_name
|
||||
|
||||
@@ -54,7 +54,7 @@ CONSECUTIVE_NO_REPLY_THRESHOLD = 3 # 连续不回复的阈值
|
||||
logger = get_logger("hfc") # Logger Name Changed
|
||||
|
||||
# 设定处理器超时时间(秒)
|
||||
PROCESSOR_TIMEOUT = 20
|
||||
PROCESSOR_TIMEOUT = 40
|
||||
|
||||
|
||||
async def _handle_cycle_delay(action_taken_this_cycle: bool, cycle_start_time: float, log_prefix: str):
|
||||
@@ -407,14 +407,14 @@ class HeartFChatting:
|
||||
# 使用 await task 来获取结果或触发异常
|
||||
result_list = await task
|
||||
logger.info(
|
||||
f"{self.log_prefix} 处理器 {processor_name} 已完成,信息已处理: {duration_since_parallel_start:.2f}秒"
|
||||
f"{self.log_prefix} 处理器 {processor_name} 已完成!"
|
||||
)
|
||||
if result_list is not None:
|
||||
all_plan_info.extend(result_list)
|
||||
else:
|
||||
logger.warning(f"{self.log_prefix} 处理器 {processor_name} 返回了 None")
|
||||
except asyncio.TimeoutError:
|
||||
logger.error(f"{self.log_prefix} 处理器 {processor_name} 超时(>{PROCESSOR_TIMEOUT}s),已跳过")
|
||||
logger.info(f"{self.log_prefix} 处理器 {processor_name} 超时(>{PROCESSOR_TIMEOUT}s),已跳过")
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
f"{self.log_prefix} 处理器 {processor_name} 执行失败,耗时 (自并行开始): {duration_since_parallel_start:.2f}秒. 错误: {e}",
|
||||
@@ -493,7 +493,7 @@ class HeartFChatting:
|
||||
else:
|
||||
action_str = action_type
|
||||
|
||||
logger.info(f"{self.log_prefix} 麦麦决定'{action_str}', 原因'{reasoning}'")
|
||||
logger.debug(f"{self.log_prefix} 麦麦想要:'{action_str}', 原因'{reasoning}'")
|
||||
|
||||
success, reply_text, command = await self._handle_action(
|
||||
action_type, reasoning, action_data, cycle_timers, thinking_id
|
||||
@@ -576,8 +576,8 @@ class HeartFChatting:
|
||||
else:
|
||||
success, reply_text = result
|
||||
command = ""
|
||||
logger.info(
|
||||
f"{self.log_prefix} 麦麦决定'{action}', 原因'{reasoning}',返回结果'{success}', '{reply_text}', '{command}'"
|
||||
logger.debug(
|
||||
f"{self.log_prefix} 麦麦执行了'{action}', 原因'{reasoning}',返回结果'{success}', '{reply_text}', '{command}'"
|
||||
)
|
||||
return success, reply_text, command
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ class MindProcessor(BaseProcessor):
|
||||
|
||||
# 记录初步思考结果
|
||||
logger.debug(f"{self.log_prefix} 思考prompt: \n{prompt}\n")
|
||||
logger.info(f"{self.log_prefix} 思考结果: {content}")
|
||||
logger.info(f"{self.log_prefix} 聊天规划: {content}")
|
||||
self.update_current_mind(content)
|
||||
|
||||
return content
|
||||
|
||||
@@ -186,7 +186,7 @@ class SelfProcessor(BaseProcessor):
|
||||
content = ""
|
||||
# 记录初步思考结果
|
||||
logger.debug(f"{self.log_prefix} 自我识别prompt: \n{prompt}\n")
|
||||
logger.info(f"{self.log_prefix} 自我识别结果: {content}")
|
||||
logger.info(f"{self.log_prefix} 自我认知: {content}")
|
||||
|
||||
return content
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class WorkingMemoryProcessor(BaseProcessor):
|
||||
# chat_info_truncate = observation.talking_message_str_truncate
|
||||
|
||||
if not working_memory:
|
||||
logger.warning(f"{self.log_prefix} 没有找到工作记忆对象")
|
||||
logger.debug(f"{self.log_prefix} 没有找到工作记忆对象")
|
||||
mind_info = MindInfo()
|
||||
return [mind_info]
|
||||
except Exception as e:
|
||||
@@ -180,7 +180,7 @@ class WorkingMemoryProcessor(BaseProcessor):
|
||||
working_memory_info.add_working_memory(memory_str)
|
||||
logger.debug(f"{self.log_prefix} 取得工作记忆: {memory_str}")
|
||||
else:
|
||||
logger.warning(f"{self.log_prefix} 没有找到工作记忆")
|
||||
logger.debug(f"{self.log_prefix} 没有找到工作记忆")
|
||||
|
||||
# 根据聊天内容添加新记忆
|
||||
if new_memory:
|
||||
|
||||
@@ -100,6 +100,7 @@ class ReplyAction(BaseAction):
|
||||
"emojis": "微笑" # 表情关键词列表(可选)
|
||||
}
|
||||
"""
|
||||
logger.info(f"{self.log_prefix} 决定回复: {self.reasoning}")
|
||||
|
||||
# 从聊天观察获取锚定消息
|
||||
chatting_observation: ChattingObservation = next(
|
||||
|
||||
@@ -230,17 +230,32 @@ NORMAL_CHAT_RESPONSE_STYLE_CONFIG = {
|
||||
"console_format": (
|
||||
"<white>{time:YYYY-MM-DD HH:mm:ss}</white> | "
|
||||
"<level>{level: <8}</level> | "
|
||||
"<light-yellow>普通聊天回复</light-yellow> | "
|
||||
"<light-yellow>普通水群回复</light-yellow> | "
|
||||
"<level>{message}</level>"
|
||||
),
|
||||
"file_format": "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {extra[module]: <15} | 普通聊天回复 | {message}",
|
||||
"file_format": "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {extra[module]: <15} | 普通水群回复 | {message}",
|
||||
},
|
||||
"simple": {
|
||||
"console_format": "<level>{time:HH:mm:ss}</level> | <light-green>普通聊天回复</light-green> | {message}",
|
||||
"file_format": "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {extra[module]: <15} | 普通聊天回复 | {message}",
|
||||
"console_format": "<level>{time:HH:mm:ss}</level> | <light-green>普通水群回复</light-green> | {message}",
|
||||
"file_format": "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {extra[module]: <15} | 普通水群回复 | {message}",
|
||||
},
|
||||
}
|
||||
|
||||
EXPRESS_STYLE_CONFIG = {
|
||||
"advanced": {
|
||||
"console_format": (
|
||||
"<white>{time:YYYY-MM-DD HH:mm:ss}</white> | "
|
||||
"<level>{level: <8}</level> | "
|
||||
"<light-yellow>麦麦表达</light-yellow> | "
|
||||
"<level>{message}</level>"
|
||||
),
|
||||
"file_format": "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {extra[module]: <15} | 麦麦表达 | {message}",
|
||||
},
|
||||
"simple": {
|
||||
"console_format": "<level>{time:HH:mm:ss}</level> | <fg #E595FF>麦麦表达</fg #E595FF> | {message}",
|
||||
"file_format": "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {extra[module]: <15} | 麦麦表达 | {message}",
|
||||
},
|
||||
}
|
||||
|
||||
# Topic日志样式配置
|
||||
TOPIC_STYLE_CONFIG = {
|
||||
@@ -975,7 +990,7 @@ INTEREST_CHAT_STYLE_CONFIG = (
|
||||
)
|
||||
NORMAL_CHAT_STYLE_CONFIG = NORMAL_CHAT_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else NORMAL_CHAT_STYLE_CONFIG["advanced"]
|
||||
FOCUS_CHAT_STYLE_CONFIG = FOCUS_CHAT_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else FOCUS_CHAT_STYLE_CONFIG["advanced"]
|
||||
|
||||
EXPRESS_STYLE_CONFIG = EXPRESS_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else EXPRESS_STYLE_CONFIG["advanced"]
|
||||
|
||||
def is_registered_module(record: dict) -> bool:
|
||||
"""检查是否为已注册的模块"""
|
||||
|
||||
@@ -47,6 +47,7 @@ from src.common.logger import (
|
||||
INTEREST_CHAT_STYLE_CONFIG,
|
||||
API_SERVER_STYLE_CONFIG,
|
||||
NORMAL_CHAT_RESPONSE_STYLE_CONFIG,
|
||||
EXPRESS_STYLE_CONFIG,
|
||||
)
|
||||
|
||||
# 可根据实际需要补充更多模块配置
|
||||
@@ -98,6 +99,7 @@ MODULE_LOGGER_CONFIGS = {
|
||||
"api": API_SERVER_STYLE_CONFIG, # API服务器
|
||||
"normal_chat": NORMAL_CHAT_STYLE_CONFIG, # 一般水群
|
||||
"focus_chat": FOCUS_CHAT_STYLE_CONFIG, # 专注水群
|
||||
"expressor": EXPRESS_STYLE_CONFIG, # 麦麦表达
|
||||
# ...如有更多模块,继续添加...
|
||||
}
|
||||
|
||||
|
||||
12
src/main.py
12
src/main.py
@@ -142,29 +142,29 @@ class MainSystem:
|
||||
"""记忆遗忘任务"""
|
||||
while True:
|
||||
await asyncio.sleep(global_config.memory.forget_memory_interval)
|
||||
print("\033[1;32m[记忆遗忘]\033[0m 开始遗忘记忆...")
|
||||
logger.info("[记忆遗忘] 开始遗忘记忆...")
|
||||
await HippocampusManager.get_instance().forget_memory(
|
||||
percentage=global_config.memory.memory_forget_percentage
|
||||
)
|
||||
print("\033[1;32m[记忆遗忘]\033[0m 记忆遗忘完成")
|
||||
logger.info("[记忆遗忘] 记忆遗忘完成")
|
||||
|
||||
@staticmethod
|
||||
async def consolidate_memory_task():
|
||||
"""记忆整合任务"""
|
||||
while True:
|
||||
await asyncio.sleep(global_config.memory.consolidate_memory_interval)
|
||||
print("\033[1;32m[记忆整合]\033[0m 开始整合记忆...")
|
||||
logger.info("[记忆整合] 开始整合记忆...")
|
||||
await HippocampusManager.get_instance().consolidate_memory()
|
||||
print("\033[1;32m[记忆整合]\033[0m 记忆整合完成")
|
||||
logger.info("[记忆整合] 记忆整合完成")
|
||||
|
||||
@staticmethod
|
||||
async def learn_and_store_expression_task():
|
||||
"""学习并存储表达方式任务"""
|
||||
while True:
|
||||
await asyncio.sleep(global_config.expression.learning_interval)
|
||||
print("\033[1;32m[表达方式学习]\033[0m 开始学习表达方式...")
|
||||
logger.info("[表达方式学习] 开始学习表达方式...")
|
||||
await expression_learner.learn_and_store_expression()
|
||||
print("\033[1;32m[表达方式学习]\033[0m 表达方式学习完成")
|
||||
logger.info("[表达方式学习] 表达方式学习完成")
|
||||
|
||||
# async def print_mood_task(self):
|
||||
# """打印情绪状态"""
|
||||
|
||||
Reference in New Issue
Block a user