Merge branch 'dev' of https://github.com/MaiM-with-u/MaiBot into dev
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import time
|
||||
import os
|
||||
from typing import Optional, Dict, Any
|
||||
from src.common.logger_manager import get_logger
|
||||
|
||||
logger = get_logger("hfc") # Logger Name Changed
|
||||
|
||||
log_dir = "log/log_cycle_debug/"
|
||||
|
||||
@@ -81,17 +84,24 @@ class CycleDetail:
|
||||
"""完成循环,记录结束时间"""
|
||||
self.end_time = time.time()
|
||||
|
||||
# 处理 prefix,只保留中英文字符
|
||||
# 处理 prefix,只保留中英文字符和基本标点
|
||||
if not self.prefix:
|
||||
self.prefix = "group"
|
||||
else:
|
||||
# 只保留中文和英文字符
|
||||
self.prefix = "".join(char for char in self.prefix if "\u4e00" <= char <= "\u9fff" or char.isascii())
|
||||
if not self.prefix:
|
||||
self.prefix = "group"
|
||||
# 只保留中文、英文字母、数字和基本标点
|
||||
allowed_chars = set("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_")
|
||||
self.prefix = (
|
||||
"".join(char for char in self.prefix if "\u4e00" <= char <= "\u9fff" or char in allowed_chars)
|
||||
or "group"
|
||||
)
|
||||
|
||||
current_time_minute = time.strftime("%Y%m%d_%H%M", time.localtime())
|
||||
self.log_cycle_to_file(log_dir + self.prefix + f"/{current_time_minute}_cycle_" + str(self.cycle_id) + ".json")
|
||||
try:
|
||||
self.log_cycle_to_file(
|
||||
log_dir + self.prefix + f"/{current_time_minute}_cycle_" + str(self.cycle_id) + ".json"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"写入文件日志,可能是群名称包含非法字符: {e}")
|
||||
|
||||
def log_cycle_to_file(self, file_path: str):
|
||||
"""将循环信息写入文件"""
|
||||
|
||||
@@ -40,7 +40,7 @@ install(extra_lines=3)
|
||||
# 如果配置键名为 None,则该处理器默认启用且不能通过 focus_chat_processor 配置禁用
|
||||
PROCESSOR_CLASSES = {
|
||||
"ChattingInfoProcessor": (ChattingInfoProcessor, None),
|
||||
"MindProcessor": (MindProcessor, None),
|
||||
"MindProcessor": (MindProcessor, "mind_processor"),
|
||||
"ToolProcessor": (ToolProcessor, "tool_use_processor"),
|
||||
"WorkingMemoryProcessor": (WorkingMemoryProcessor, "working_memory_processor"),
|
||||
"SelfProcessor": (SelfProcessor, "self_identify_processor"),
|
||||
|
||||
@@ -23,7 +23,6 @@ logger = get_logger("processor")
|
||||
|
||||
def init_prompt():
|
||||
group_prompt = """
|
||||
你的名字是{bot_name}
|
||||
{memory_str}{extra_info}{relation_prompt}
|
||||
{cycle_info_block}
|
||||
现在是{time_now},你正在上网,和qq群里的网友们聊天,以下是正在进行的聊天内容:
|
||||
@@ -37,9 +36,8 @@ def init_prompt():
|
||||
现在请你继续输出观察和规划,输出要求:
|
||||
1. 先关注未读新消息的内容和近期回复历史
|
||||
2. 根据新信息,修改和删除之前的观察和规划
|
||||
3. 根据聊天内容继续输出观察和规划
|
||||
4. 注意群聊的时间线索,话题由谁发起,进展状况如何,思考聊天的时间线。
|
||||
6. 语言简洁自然,不要分点,不要浮夸,不要修辞,仅输出思考内容就好"""
|
||||
3. 注意群聊的时间线索,话题由谁发起,进展状况如何。
|
||||
4. 语言简洁自然,不要分点,不要浮夸,不要修辞,仅输出内容就好"""
|
||||
Prompt(group_prompt, "sub_heartflow_prompt_before")
|
||||
|
||||
private_prompt = """
|
||||
|
||||
@@ -60,7 +60,7 @@ class HFCloopObservation:
|
||||
|
||||
if action_type == "reply":
|
||||
consecutive_text_replies += 1
|
||||
response_text = cycle.loop_plan_info["action_result"]["action_data"].get("text", "[空回复]")
|
||||
response_text = cycle.loop_action_info["reply_text"]
|
||||
responses_for_prompt.append(response_text)
|
||||
|
||||
if is_taken:
|
||||
@@ -68,9 +68,10 @@ class HFCloopObservation:
|
||||
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"
|
||||
# )
|
||||
pass
|
||||
else:
|
||||
if is_taken:
|
||||
action_detailed_str += (
|
||||
|
||||
@@ -122,7 +122,9 @@ class TelemetryHeartBeatTask(AsyncTask):
|
||||
timeout=5, # 设置超时时间为5秒
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"心跳发送失败: {e}")
|
||||
# 你知道为什么设置成debug吗?
|
||||
# 因为我不想看到群里天天报错
|
||||
logger.debug(f"心跳发送失败: {e}")
|
||||
|
||||
logger.debug(response)
|
||||
|
||||
|
||||
@@ -158,6 +158,9 @@ class FocusChatConfig(ConfigBase):
|
||||
class FocusChatProcessorConfig(ConfigBase):
|
||||
"""专注聊天处理器配置类"""
|
||||
|
||||
mind_processor: bool = True
|
||||
"""是否启用思维处理器"""
|
||||
|
||||
self_identify_processor: bool = True
|
||||
"""是否启用自我识别处理器"""
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[inner]
|
||||
version = "2.7.0"
|
||||
version = "2.8.0"
|
||||
|
||||
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
|
||||
#如果你想要修改配置文件,请在修改后将version的值进行变更
|
||||
@@ -103,6 +103,7 @@ compressed_length = 8 # 不能大于observation_context_size,心流上下文压
|
||||
compress_length_limit = 4 #最多压缩份数,超过该数值的压缩上下文会被删除
|
||||
|
||||
[focus_chat_processor] # 专注聊天处理器,打开可以实现更多功能,但是会增加token消耗
|
||||
mind_processor = false # 是否启用思维处理器
|
||||
self_identify_processor = true # 是否启用自我识别处理器
|
||||
tool_use_processor = false # 是否启用工具使用处理器
|
||||
working_memory_processor = false # 是否启用工作记忆处理器,不稳定,消耗量大
|
||||
|
||||
Reference in New Issue
Block a user