feat:添加了心流的配置项
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
- `schedule`: 日程表生成功能配置
|
||||
- `response_spliter`: 回复分割控制
|
||||
- `experimental`: 实验性功能开关
|
||||
- `llm_outer_world`和`llm_sub_heartflow`: 思维流模型配置
|
||||
- `llm_observation`和`llm_sub_heartflow`: 思维流模型配置
|
||||
- `llm_heartflow`: 思维流核心模型配置
|
||||
- `prompt_schedule_gen`: 日程生成提示词配置
|
||||
- `memory_ban_words`: 记忆过滤词配置
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
- 新增了 `schedule` 配置项,用于配置日程表生成功能
|
||||
- 新增了 `response_spliter` 配置项,用于控制回复分割
|
||||
- 新增了 `experimental` 配置项,用于实验性功能开关
|
||||
- 新增了 `llm_outer_world` 和 `llm_sub_heartflow` 模型配置
|
||||
- 新增了 `llm_observation` 和 `llm_sub_heartflow` 模型配置
|
||||
- 新增了 `llm_heartflow` 模型配置
|
||||
- 在 `personality` 配置项中新增了 `prompt_schedule_gen` 参数
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
@@ -50,7 +50,7 @@ class Heartflow:
|
||||
|
||||
# 检查所有子心流
|
||||
for subheartflow_id, subheartflow in self._subheartflows.items():
|
||||
if current_time - subheartflow.last_active_time > 600: # 10分钟 = 600秒
|
||||
if current_time - subheartflow.last_active_time > global_config.sub_heart_flow_stop_time: # 10分钟 = 600秒
|
||||
inactive_subheartflows.append(subheartflow_id)
|
||||
logger.info(f"发现不活跃的子心流: {subheartflow_id}")
|
||||
|
||||
@@ -69,11 +69,11 @@ class Heartflow:
|
||||
# 检查是否存在子心流
|
||||
if not self._subheartflows:
|
||||
logger.info("当前没有子心流,等待新的子心流创建...")
|
||||
await asyncio.sleep(60) # 每分钟检查一次是否有新的子心流
|
||||
await asyncio.sleep(30) # 每分钟检查一次是否有新的子心流
|
||||
continue
|
||||
|
||||
await self.do_a_thinking()
|
||||
await asyncio.sleep(300) # 5分钟思考一次
|
||||
await asyncio.sleep(global_config.heart_flow_update_interval) # 5分钟思考一次
|
||||
|
||||
async def do_a_thinking(self):
|
||||
logger.debug("麦麦大脑袋转起来了")
|
||||
@@ -33,7 +33,7 @@ class ChattingObservation(Observation):
|
||||
self.sub_observe = None
|
||||
|
||||
self.llm_summary = LLM_request(
|
||||
model=global_config.llm_outer_world, temperature=0.7, max_tokens=300, request_type="outer_world"
|
||||
model=global_config.llm_observation, temperature=0.7, max_tokens=300, request_type="outer_world"
|
||||
)
|
||||
|
||||
# 进行一次观察 返回观察结果observe_info
|
||||
@@ -80,9 +80,9 @@ class SubHeartflow:
|
||||
async def subheartflow_start_working(self):
|
||||
while True:
|
||||
current_time = time.time()
|
||||
if current_time - self.last_reply_time > 120: # 120秒无回复/不在场,冻结
|
||||
if current_time - self.last_reply_time > global_config.sub_heart_flow_freeze_time: # 120秒无回复/不在场,冻结
|
||||
self.is_active = False
|
||||
await asyncio.sleep(60) # 每60秒检查一次
|
||||
await asyncio.sleep(global_config.sub_heart_flow_update_interval) # 每60秒检查一次
|
||||
else:
|
||||
self.is_active = True
|
||||
self.last_active_time = current_time # 更新最后激活时间
|
||||
@@ -94,10 +94,10 @@ class SubHeartflow:
|
||||
|
||||
await self.do_a_thinking()
|
||||
await self.judge_willing()
|
||||
await asyncio.sleep(60)
|
||||
await asyncio.sleep(global_config.sub_heart_flow_update_interval)
|
||||
|
||||
# 检查是否超过10分钟没有激活
|
||||
if current_time - self.last_active_time > 600: # 5分钟无回复/不在场,销毁
|
||||
if current_time - self.last_active_time > global_config.sub_heart_flow_stop_time: # 5分钟无回复/不在场,销毁
|
||||
logger.info(f"子心流 {self.subheartflow_id} 已经5分钟没有激活,正在销毁...")
|
||||
break # 退出循环,销毁自己
|
||||
|
||||
@@ -7,7 +7,7 @@ from .plugins.chat.emoji_manager import emoji_manager
|
||||
from .plugins.chat.relationship_manager import relationship_manager
|
||||
from .plugins.willing.willing_manager import willing_manager
|
||||
from .plugins.chat.chat_stream import chat_manager
|
||||
from .think_flow_demo.heartflow import heartflow
|
||||
from .heart_flow.heartflow import heartflow
|
||||
from .plugins.memory_system.Hippocampus import HippocampusManager
|
||||
from .plugins.chat.message_sender import message_manager
|
||||
from .plugins.chat.storage import MessageStorage
|
||||
|
||||
@@ -10,7 +10,7 @@ from .message_sender import message_manager
|
||||
from ..moods.moods import MoodManager
|
||||
from .llm_generator import ResponseGenerator
|
||||
from src.common.logger import get_module_logger
|
||||
from src.think_flow_demo.heartflow import heartflow
|
||||
from src.heart_flow.heartflow import heartflow
|
||||
from ...common.database import db
|
||||
|
||||
logger = get_module_logger("auto_speak")
|
||||
|
||||
@@ -19,7 +19,7 @@ from .utils_image import image_path_to_base64
|
||||
from ..willing.willing_manager import willing_manager # 导入意愿管理器
|
||||
from ..message import UserInfo, Seg
|
||||
|
||||
from src.think_flow_demo.heartflow import heartflow
|
||||
from src.heart_flow.heartflow import heartflow
|
||||
from src.common.logger import get_module_logger, CHAT_STYLE_CONFIG, LogConfig
|
||||
|
||||
# 定义日志配置
|
||||
|
||||
@@ -11,7 +11,7 @@ from .utils import get_embedding, get_recent_group_detailed_plain_text
|
||||
from .chat_stream import chat_manager
|
||||
from src.common.logger import get_module_logger
|
||||
|
||||
from src.think_flow_demo.heartflow import heartflow
|
||||
from src.heart_flow.heartflow import heartflow
|
||||
|
||||
logger = get_module_logger("prompt")
|
||||
|
||||
|
||||
@@ -23,15 +23,11 @@ config_config = LogConfig(
|
||||
# 配置主程序日志格式
|
||||
logger = get_module_logger("config", config=config_config)
|
||||
|
||||
|
||||
|
||||
#考虑到,实际上配置文件中的mai_version是不会自动更新的,所以采用硬编码
|
||||
mai_version_main = "0.6.0"
|
||||
mai_version_fix = "mmc-2"
|
||||
mai_version = f"{mai_version_main}-{mai_version_fix}"
|
||||
|
||||
|
||||
|
||||
def update_config():
|
||||
# 获取根目录路径
|
||||
root_dir = Path(__file__).parent.parent.parent.parent
|
||||
@@ -152,6 +148,7 @@ class BotConfig:
|
||||
ENABLE_SCHEDULE_GEN: bool = False # 是否启用日程生成
|
||||
PROMPT_SCHEDULE_GEN = "无日程"
|
||||
SCHEDULE_DOING_UPDATE_INTERVAL: int = 300 # 日程表更新间隔 单位秒
|
||||
SCHEDULE_TEMPERATURE: float = 0.5 # 日程表温度,建议0.5-1.0
|
||||
|
||||
# message
|
||||
MAX_CONTEXT_SIZE: int = 15 # 上下文最大消息数
|
||||
@@ -161,7 +158,14 @@ class BotConfig:
|
||||
|
||||
ban_words = set()
|
||||
ban_msgs_regex = set()
|
||||
|
||||
|
||||
#heartflow
|
||||
enable_heartflow: bool = False # 是否启用心流
|
||||
sub_heart_flow_update_interval: int = 60 # 子心流更新频率,间隔 单位秒
|
||||
sub_heart_flow_freeze_time: int = 120 # 子心流冻结时间,超过这个时间没有回复,子心流会冻结,间隔 单位秒
|
||||
sub_heart_flow_stop_time: int = 600 # 子心流停止时间,超过这个时间没有回复,子心流会停止,间隔 单位秒
|
||||
heart_flow_update_interval: int = 300 # 心流更新频率,间隔 单位秒
|
||||
|
||||
# willing
|
||||
willing_mode: str = "classical" # 意愿模式
|
||||
response_willing_amplifier: float = 1.0 # 回复意愿放大系数
|
||||
@@ -237,7 +241,7 @@ class BotConfig:
|
||||
moderation: Dict[str, str] = field(default_factory=lambda: {})
|
||||
|
||||
# 实验性
|
||||
llm_outer_world: Dict[str, str] = field(default_factory=lambda: {})
|
||||
llm_observation: Dict[str, str] = field(default_factory=lambda: {})
|
||||
llm_sub_heartflow: Dict[str, str] = field(default_factory=lambda: {})
|
||||
llm_heartflow: Dict[str, str] = field(default_factory=lambda: {})
|
||||
|
||||
@@ -329,10 +333,9 @@ class BotConfig:
|
||||
logger.debug(f"载入自定义人格:{personality}")
|
||||
config.PROMPT_PERSONALITY = personality_config.get("prompt_personality", config.PROMPT_PERSONALITY)
|
||||
|
||||
if config.INNER_VERSION in SpecifierSet(">=0.0.2"):
|
||||
config.PERSONALITY_1 = personality_config.get("personality_1_probability", config.PERSONALITY_1)
|
||||
config.PERSONALITY_2 = personality_config.get("personality_2_probability", config.PERSONALITY_2)
|
||||
config.PERSONALITY_3 = personality_config.get("personality_3_probability", config.PERSONALITY_3)
|
||||
config.PERSONALITY_1 = personality_config.get("personality_1_probability", config.PERSONALITY_1)
|
||||
config.PERSONALITY_2 = personality_config.get("personality_2_probability", config.PERSONALITY_2)
|
||||
config.PERSONALITY_3 = personality_config.get("personality_3_probability", config.PERSONALITY_3)
|
||||
|
||||
def schedule(parent: dict):
|
||||
schedule_config = parent["schedule"]
|
||||
@@ -344,6 +347,8 @@ class BotConfig:
|
||||
logger.info(
|
||||
f"载入自定义日程prompt:{schedule_config.get('prompt_schedule_gen', config.PROMPT_SCHEDULE_GEN)}"
|
||||
)
|
||||
if config.INNER_VERSION in SpecifierSet(">=1.0.2"):
|
||||
config.SCHEDULE_TEMPERATURE = schedule_config.get("schedule_temperature", config.SCHEDULE_TEMPERATURE)
|
||||
|
||||
def emoji(parent: dict):
|
||||
emoji_config = parent["emoji"]
|
||||
@@ -359,9 +364,7 @@ class BotConfig:
|
||||
bot_qq = bot_config.get("qq")
|
||||
config.BOT_QQ = int(bot_qq)
|
||||
config.BOT_NICKNAME = bot_config.get("nickname", config.BOT_NICKNAME)
|
||||
|
||||
if config.INNER_VERSION in SpecifierSet(">=0.0.5"):
|
||||
config.BOT_ALIAS_NAMES = bot_config.get("alias_names", config.BOT_ALIAS_NAMES)
|
||||
config.BOT_ALIAS_NAMES = bot_config.get("alias_names", config.BOT_ALIAS_NAMES)
|
||||
|
||||
def response(parent: dict):
|
||||
response_config = parent["response"]
|
||||
@@ -402,7 +405,7 @@ class BotConfig:
|
||||
"vlm",
|
||||
"embedding",
|
||||
"moderation",
|
||||
"llm_outer_world",
|
||||
"llm_observation",
|
||||
"llm_sub_heartflow",
|
||||
"llm_heartflow",
|
||||
]
|
||||
@@ -462,19 +465,15 @@ class BotConfig:
|
||||
config.MAX_CONTEXT_SIZE = msg_config.get("max_context_size", config.MAX_CONTEXT_SIZE)
|
||||
config.emoji_chance = msg_config.get("emoji_chance", config.emoji_chance)
|
||||
config.ban_words = msg_config.get("ban_words", config.ban_words)
|
||||
|
||||
if config.INNER_VERSION in SpecifierSet(">=0.0.2"):
|
||||
config.thinking_timeout = msg_config.get("thinking_timeout", config.thinking_timeout)
|
||||
config.response_willing_amplifier = msg_config.get(
|
||||
"response_willing_amplifier", config.response_willing_amplifier
|
||||
)
|
||||
config.response_interested_rate_amplifier = msg_config.get(
|
||||
"response_interested_rate_amplifier", config.response_interested_rate_amplifier
|
||||
)
|
||||
config.down_frequency_rate = msg_config.get("down_frequency_rate", config.down_frequency_rate)
|
||||
|
||||
if config.INNER_VERSION in SpecifierSet(">=0.0.6"):
|
||||
config.ban_msgs_regex = msg_config.get("ban_msgs_regex", config.ban_msgs_regex)
|
||||
config.thinking_timeout = msg_config.get("thinking_timeout", config.thinking_timeout)
|
||||
config.response_willing_amplifier = msg_config.get(
|
||||
"response_willing_amplifier", config.response_willing_amplifier
|
||||
)
|
||||
config.response_interested_rate_amplifier = msg_config.get(
|
||||
"response_interested_rate_amplifier", config.response_interested_rate_amplifier
|
||||
)
|
||||
config.down_frequency_rate = msg_config.get("down_frequency_rate", config.down_frequency_rate)
|
||||
config.ban_msgs_regex = msg_config.get("ban_msgs_regex", config.ban_msgs_regex)
|
||||
|
||||
if config.INNER_VERSION in SpecifierSet(">=0.0.11"):
|
||||
config.max_response_length = msg_config.get("max_response_length", config.max_response_length)
|
||||
@@ -483,17 +482,12 @@ class BotConfig:
|
||||
memory_config = parent["memory"]
|
||||
config.build_memory_interval = memory_config.get("build_memory_interval", config.build_memory_interval)
|
||||
config.forget_memory_interval = memory_config.get("forget_memory_interval", config.forget_memory_interval)
|
||||
|
||||
# 在版本 >= 0.0.4 时才处理新增的配置项
|
||||
if config.INNER_VERSION in SpecifierSet(">=0.0.4"):
|
||||
config.memory_ban_words = set(memory_config.get("memory_ban_words", []))
|
||||
|
||||
if config.INNER_VERSION in SpecifierSet(">=0.0.7"):
|
||||
config.memory_forget_time = memory_config.get("memory_forget_time", config.memory_forget_time)
|
||||
config.memory_forget_percentage = memory_config.get(
|
||||
"memory_forget_percentage", config.memory_forget_percentage
|
||||
)
|
||||
config.memory_compress_rate = memory_config.get("memory_compress_rate", config.memory_compress_rate)
|
||||
config.memory_ban_words = set(memory_config.get("memory_ban_words", []))
|
||||
config.memory_forget_time = memory_config.get("memory_forget_time", config.memory_forget_time)
|
||||
config.memory_forget_percentage = memory_config.get(
|
||||
"memory_forget_percentage", config.memory_forget_percentage
|
||||
)
|
||||
config.memory_compress_rate = memory_config.get("memory_compress_rate", config.memory_compress_rate)
|
||||
if config.INNER_VERSION in SpecifierSet(">=0.0.11"):
|
||||
config.memory_build_distribution = memory_config.get(
|
||||
"memory_build_distribution", config.memory_build_distribution
|
||||
@@ -553,6 +547,14 @@ class BotConfig:
|
||||
if platforms_config and isinstance(platforms_config, dict):
|
||||
for k in platforms_config.keys():
|
||||
config.api_urls[k] = platforms_config[k]
|
||||
|
||||
def heartflow(parent: dict):
|
||||
heartflow_config = parent["heartflow"]
|
||||
config.enable_heartflow = heartflow_config.get("enable", config.enable_heartflow)
|
||||
config.sub_heart_flow_update_interval = heartflow_config.get("sub_heart_flow_update_interval", config.sub_heart_flow_update_interval)
|
||||
config.sub_heart_flow_freeze_time = heartflow_config.get("sub_heart_flow_freeze_time", config.sub_heart_flow_freeze_time)
|
||||
config.sub_heart_flow_stop_time = heartflow_config.get("sub_heart_flow_stop_time", config.sub_heart_flow_stop_time)
|
||||
config.heart_flow_update_interval = heartflow_config.get("heart_flow_update_interval", config.heart_flow_update_interval)
|
||||
|
||||
def experimental(parent: dict):
|
||||
experimental_config = parent["experimental"]
|
||||
@@ -591,6 +593,7 @@ class BotConfig:
|
||||
"platforms": {"func": platforms, "support": ">=1.0.0"},
|
||||
"response_spliter": {"func": response_spliter, "support": ">=0.0.11", "necessary": False},
|
||||
"experimental": {"func": experimental, "support": ">=0.0.11", "necessary": False},
|
||||
"heartflow": {"func": heartflow, "support": ">=1.0.2", "necessary": False},
|
||||
}
|
||||
|
||||
# 原地修改,将 字符串版本表达式 转换成 版本对象
|
||||
|
||||
@@ -28,10 +28,10 @@ class ScheduleGenerator:
|
||||
def __init__(self):
|
||||
# 使用离线LLM模型
|
||||
self.llm_scheduler_all = LLM_request(
|
||||
model=global_config.llm_reasoning, temperature=0.8, max_tokens=7000, request_type="schedule"
|
||||
model=global_config.llm_reasoning, temperature=global_config.schedule_temperature, max_tokens=7000, request_type="schedule"
|
||||
)
|
||||
self.llm_scheduler_doing = LLM_request(
|
||||
model=global_config.llm_normal, temperature=0.6, max_tokens=2048, request_type="schedule"
|
||||
model=global_config.llm_normal, temperature=global_config.schedule_temperature, max_tokens=2048, request_type="schedule"
|
||||
)
|
||||
|
||||
self.today_schedule_text = ""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[inner]
|
||||
version = "1.0.1"
|
||||
version = "1.0.2"
|
||||
|
||||
|
||||
#以下是给开发人员阅读的,一般用户不需要阅读
|
||||
@@ -47,10 +47,20 @@ personality_3_probability = 0.1 # 第三种人格出现概率,请确保三个
|
||||
enable_schedule_gen = true # 是否启用日程表(尚未完成)
|
||||
prompt_schedule_gen = "用几句话描述描述性格特点或行动规律,这个特征会用来生成日程表"
|
||||
schedule_doing_update_interval = 900 # 日程表更新间隔 单位秒
|
||||
schedule_temperature = 0.5 # 日程表温度,建议0.5-1.0
|
||||
|
||||
[platforms] # 必填项目,填写每个平台适配器提供的链接
|
||||
qq="http://127.0.0.1:18002/api/message"
|
||||
|
||||
[heartflow] # 注意:可能会消耗大量token,请谨慎开启
|
||||
enable = false
|
||||
sub_heart_flow_update_interval = 60 # 子心流更新频率,间隔 单位秒
|
||||
sub_heart_flow_freeze_time = 120 # 子心流冻结时间,超过这个时间没有回复,子心流会冻结,间隔 单位秒
|
||||
sub_heart_flow_stop_time = 600 # 子心流停止时间,超过这个时间没有回复,子心流会停止,间隔 单位秒
|
||||
heart_flow_update_interval = 300 # 心流更新频率,间隔 单位秒
|
||||
|
||||
#思维流适合搭配低能耗普通模型使用,例如qwen2.5 32b
|
||||
|
||||
|
||||
[message]
|
||||
max_context_size = 15 # 麦麦获得的上文数量,建议15,太短太长都会导致脑袋尖尖
|
||||
@@ -134,14 +144,11 @@ enable_response_spliter = true # 是否启用回复分割器
|
||||
response_max_length = 100 # 回复允许的最大长度
|
||||
response_max_sentence_num = 4 # 回复允许的最大句子数
|
||||
|
||||
|
||||
[remote] #发送统计信息,主要是看全球有多少只麦麦
|
||||
enable = true
|
||||
|
||||
[experimental]
|
||||
enable_friend_chat = false # 是否启用好友聊天
|
||||
enable_think_flow = false # 是否启用思维流 注意:可能会消耗大量token,请谨慎开启
|
||||
#思维流适合搭配低能耗普通模型使用,例如qwen2.5 32b
|
||||
|
||||
#下面的模型若使用硅基流动则不需要更改,使用ds官方则改成.env自定义的宏,使用自定义模型则选择定位相似的模型自己填写
|
||||
#推理模型
|
||||
@@ -213,8 +220,7 @@ provider = "SILICONFLOW"
|
||||
pri_in = 0
|
||||
pri_out = 0
|
||||
|
||||
#测试模型,给think_glow用,如果你没开实验性功能,随便写就行,但是要有
|
||||
[model.llm_outer_world] #外世界判断:建议使用qwen2.5 7b
|
||||
[model.llm_observation] #观察模型,建议用免费的:建议使用qwen2.5 7b
|
||||
# name = "Pro/Qwen/Qwen2.5-7B-Instruct"
|
||||
name = "Qwen/Qwen2.5-7B-Instruct"
|
||||
provider = "SILICONFLOW"
|
||||
|
||||
Reference in New Issue
Block a user