修改配置文件

pull/1232/head
SengokuCola 2025-09-11 15:03:15 +08:00
parent 460c469dc9
commit 9fafa3478e
7 changed files with 45 additions and 113 deletions

View File

@ -109,7 +109,7 @@ class HeartFChatting:
self.last_read_time = time.time() - 10
self.talk_threshold = global_config.chat.talk_value
self.no_reply_until_call = False
@ -172,6 +172,16 @@ class HeartFChatting:
f"耗时: {self._current_cycle_detail.end_time - self._current_cycle_detail.start_time:.1f}" # type: ignore
+ (f"\n详情: {'; '.join(timer_strings)}" if timer_strings else "")
)
def get_talk_threshold(self):
talk_value = global_config.chat.talk_value
# 处理talk_value取整数部分和小数部分
base_value = int(talk_value)
probability = talk_value - base_value
# 根据概率决定是否+1
think_len = base_value + 1 if random.random() < probability else base_value
self.talk_threshold = think_len
logger.info(f"{self.log_prefix} 思考频率阈值: {self.talk_threshold}")
async def _loopbody(self):
recent_messages_list = message_api.get_messages_by_time_in_chat(
@ -184,7 +194,7 @@ class HeartFChatting:
filter_command=True,
)
if recent_messages_list:
if len(recent_messages_list) >= self.talk_threshold:
# !处理no_reply_until_call逻辑
if self.no_reply_until_call:
@ -203,6 +213,7 @@ class HeartFChatting:
await self._observe(
recent_messages_list=recent_messages_list,
)
self.get_talk_threshold()
else:
# Normal模式消息数量不足等待
await asyncio.sleep(0.2)

View File

@ -6,7 +6,6 @@ import traceback
from typing import Tuple, TYPE_CHECKING
from src.config.config import global_config
from src.chat.memory_system.Hippocampus import hippocampus_manager
from src.chat.message_receive.message import MessageRecv
from src.chat.message_receive.storage import MessageStorage
from src.chat.heart_flow.heartflow import heartflow
@ -38,16 +37,16 @@ async def _calculate_interest(message: MessageRecv) -> Tuple[float, list[str]]:
is_mentioned, is_at, reply_probability_boost = is_mentioned_bot_in_message(message)
interested_rate = 0.0
with Timer("记忆激活"):
interested_rate, keywords, keywords_lite = await hippocampus_manager.get_activate_from_text(
message.processed_plain_text,
max_depth=4,
fast_retrieval=global_config.chat.interest_rate_mode == "fast",
)
message.key_words = keywords
message.key_words_lite = keywords_lite
logger.debug(f"记忆激活率: {interested_rate:.2f}, 关键词: {keywords}")
keywords = []
# with Timer("记忆激活"):
# interested_rate, keywords, keywords_lite = await hippocampus_manager.get_activate_from_text(
# message.processed_plain_text,
# max_depth=4,
# fast_retrieval=global_config.chat.interest_rate_mode == "fast",
# )
# message.key_words = keywords
# message.key_words_lite = keywords_lite
# logger.debug(f"记忆激活率: {interested_rate:.2f}, 关键词: {keywords}")
text_len = len(message.processed_plain_text)
# 根据文本长度分布调整兴趣度,采用分段函数实现更精确的兴趣度计算

View File

@ -25,7 +25,7 @@ from src.chat.utils.chat_message_builder import (
replace_user_references,
)
from src.chat.express.expression_selector import expression_selector
from src.chat.memory_system.memory_activator import MemoryActivator
# from src.chat.memory_system.memory_activator import MemoryActivator
from src.mood.mood_manager import mood_manager
from src.person_info.person_info import Person, is_person_known
from src.plugin_system.base.component_types import ActionInfo, EventType
@ -143,7 +143,7 @@ class DefaultReplyer:
self.chat_stream = chat_stream
self.is_group_chat, self.chat_target_info = get_chat_type_and_target_info(self.chat_stream.stream_id)
self.heart_fc_sender = UniversalMessageSender()
self.memory_activator = MemoryActivator()
# self.memory_activator = MemoryActivator()
from src.plugin_system.core.tool_use import ToolExecutor # 延迟导入ToolExecutor不然会循环依赖
@ -1019,9 +1019,6 @@ class DefaultReplyer:
async def llm_generate_content(self, prompt: str):
with Timer("LLM生成", {}): # 内部计时器,可选保留
# 直接使用已初始化的模型实例
logger.info(f"使用模型集生成回复: {', '.join(map(str, self.express_model.model_for_task.model_list))}")
logger.info(f"\n{prompt}\n")
if global_config.debug.show_prompt:
logger.info(f"\n{prompt}\n")

View File

@ -18,7 +18,6 @@ from src.config.official_configs import (
ExpressionConfig,
ChatConfig,
EmojiConfig,
MemoryConfig,
MoodConfig,
KeywordReactionConfig,
ChineseTypoConfig,
@ -347,7 +346,6 @@ class Config(ConfigBase):
message_receive: MessageReceiveConfig
emoji: EmojiConfig
expression: ExpressionConfig
memory: MemoryConfig
mood: MoodConfig
keyword_reaction: KeywordReactionConfig
chinese_typo: ChineseTypoConfig

View File

@ -77,6 +77,9 @@ class ChatConfig(ConfigBase):
talk_frequency: float = 0.5
"""回复频率阈值"""
talk_value: float = 1
"""思考频率"""
# 合并后的时段频率配置
talk_frequency_adjust: list[list[str]] = field(default_factory=lambda: [])
@ -321,26 +324,6 @@ class EmojiConfig(ConfigBase):
"""表情包过滤要求"""
@dataclass
class MemoryConfig(ConfigBase):
"""记忆配置类"""
enable_memory: bool = True
"""是否启用记忆系统"""
forget_memory_interval: int = 1500
"""记忆遗忘间隔(秒)"""
memory_forget_time: int = 24
"""记忆遗忘时间(小时)"""
memory_forget_percentage: float = 0.01
"""记忆遗忘比例"""
memory_ban_words: list[str] = field(default_factory=lambda: ["表情包", "图片", "回复", "聊天记录"])
"""不允许记忆的词列表"""
@dataclass
class MoodConfig(ConfigBase):
"""情绪配置类"""

View File

@ -23,10 +23,6 @@ from src.plugin_system.core.plugin_manager import plugin_manager
# 导入消息API和traceback模块
from src.common.message import get_global_api
# 条件导入记忆系统
if global_config.memory.enable_memory:
from src.chat.memory_system.Hippocampus import hippocampus_manager
# 插件系统现在使用统一的插件加载器
install(extra_lines=3)
@ -36,10 +32,6 @@ logger = get_logger("main")
class MainSystem:
def __init__(self):
# 根据配置条件性地初始化记忆系统
self.hippocampus_manager = None
if global_config.memory.enable_memory:
self.hippocampus_manager = hippocampus_manager
# 使用消息API替代直接的FastAPI实例
self.app: MessageServer = get_global_api()
@ -101,13 +93,13 @@ class MainSystem:
logger.info("聊天管理器初始化成功")
# 根据配置条件性地初始化记忆系统
if global_config.memory.enable_memory:
if self.hippocampus_manager:
self.hippocampus_manager.initialize()
logger.info("记忆系统初始化成功")
else:
logger.info("记忆系统已禁用,跳过初始化")
# # 根据配置条件性地初始化记忆系统
# if global_config.memory.enable_memory:
# if self.hippocampus_manager:
# self.hippocampus_manager.initialize()
# logger.info("记忆系统初始化成功")
# else:
# logger.info("记忆系统已禁用,跳过初始化")
# await asyncio.sleep(0.5) #防止logger输出飞了
@ -139,14 +131,14 @@ class MainSystem:
]
# 根据配置条件性地添加记忆系统相关任务
if global_config.memory.enable_memory and self.hippocampus_manager:
tasks.extend(
[
# 移除记忆构建的定期调用改为在heartFC_chat.py中调用
# self.build_memory_task(),
self.forget_memory_task(),
]
)
# if global_config.memory.enable_memory and self.hippocampus_manager:
# tasks.extend(
# [
# # 移除记忆构建的定期调用改为在heartFC_chat.py中调用
# # self.build_memory_task(),
# self.forget_memory_task(),
# ]
# )
await asyncio.gather(*tasks)

View File

@ -1,5 +1,5 @@
[inner]
version = "6.9.0"
version = "6.10.1"
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
#如果你想要修改配置文件请递增version的值
@ -50,48 +50,9 @@ expression_groups = [
[chat] #麦麦的聊天设置
talk_frequency = 0.5
# 麦麦活跃度越高麦麦越容易回复范围0-1
focus_value = 0.5
# 麦麦的专注度越高越容易持续连续对话可能消耗更多token, 范围0-1
mentioned_bot_reply = 1 # 提及时,回复概率增幅1为100%回复0为不额外增幅
at_bot_inevitable_reply = 1 # at时,回复概率增幅1为100%回复0为不额外增幅
talk_value = 1.5
max_context_size = 20 # 上下文长度
planner_size = 3.5 # 副规划器大小越小麦麦的动作执行能力越精细但是消耗更多token调大可以缓解429类错误
focus_value_adjust = [
["", "8:00,1", "12:00,0.8", "18:00,1", "01:00,0.3"],
["qq:114514:group", "12:20,0.6", "16:10,0.5", "20:10,0.8", "00:10,0.3"],
["qq:1919810:private", "8:20,0.5", "12:10,0.8", "20:10,1", "00:10,0.2"]
]
talk_frequency_adjust = [
["", "8:00,0.5", "12:00,0.6", "18:00,0.8", "01:00,0.3"],
["qq:114514:group", "12:20,0.3", "16:10,0.5", "20:10,0.4", "00:10,0.1"],
["qq:1919810:private", "8:20,0.3", "12:10,0.4", "20:10,0.5", "00:10,0.1"]
]
# 基于聊天流的个性化活跃度和专注度配置
# 格式:[["platform:chat_id:type", "HH:MM,frequency", "HH:MM,frequency", ...], ...]
# 全局配置示例:
# [["", "8:00,1", "12:00,2", "18:00,1.5", "00:00,0.5"]]
# 特定聊天流配置示例:
# [
# ["", "8:00,1", "12:00,1.2", "18:00,1.5", "01:00,0.6"], # 全局默认配置
# ["qq:1026294844:group", "12:20,1", "16:10,2", "20:10,1", "00:10,0.3"], # 特定群聊配置
# ["qq:729957033:private", "8:20,1", "12:10,2", "20:10,1.5", "00:10,0.2"] # 特定私聊配置
# ]
# 说明:
# - 当第一个元素为空字符串""时,表示全局默认配置
# - 当第一个元素为"platform:id:type"格式时,表示特定聊天流配置
# - 后续元素是"时间,频率"格式,表示从该时间开始使用该活跃度,直到下一个时间点
# - 优先级:特定聊天流配置 > 全局配置 > 默认 talk_frequency
[relationship]
enable_relationship = true # 是否启用关系系统
@ -112,15 +73,6 @@ steal_emoji = true # 是否偷取表情包,让麦麦可以将一些表情包
content_filtration = false # 是否启用表情包过滤,只有符合该要求的表情包才会被保存
filtration_prompt = "符合公序良俗" # 表情包过滤要求,只有符合该要求的表情包才会被保存
[memory]
enable_memory = true # 是否启用记忆系统
forget_memory_interval = 1500 # 记忆遗忘间隔 单位秒 间隔越低,麦麦遗忘越频繁,记忆更精简,但更难学习
memory_forget_time = 48 #多长时间后的记忆会被遗忘 单位小时
memory_forget_percentage = 0.008 # 记忆遗忘比例 控制记忆遗忘程度 越大遗忘越多 建议保持默认
#不希望记忆的词,已经记忆的不会受到影响,需要手动清理
memory_ban_words = [ "表情包", "图片", "回复", "聊天记录" ]
[voice]
enable_asr = false # 是否启用语音识别,启用后麦麦可以识别语音消息,启用该功能需要配置语音识别模型[model.voice]s