Merge pull request #9 from Plutor-05/PFC-test

完善传参
pull/937/head
未來星織 2025-05-09 14:28:52 +09:00 committed by GitHub
commit 7287cd0ac7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 23 deletions

View File

@ -278,11 +278,11 @@ class BotConfig:
2 # PFC 聊天消息缓冲数量,有利于使聊天节奏更加紧凑流畅,请根据实际 LLM 响应速度进行调整默认2条
)
# idle_conversation
enable_idle_conversation: bool = False # 是否启用 pfc 主动发言
# idle_chat
enable_idle_chat: bool = False # 是否启用 pfc 主动发言
idle_check_interval: int = 10 # 检查间隔10分钟检查一次
min_idle_time: int = 7200 # 最短无活动时间2小时 (7200秒)
max_idle_time: int = 18000 # 最长无活动时间5小时 (18000秒)
min_cooldown: int = 7200 # 最短冷却时间2小时 (7200秒)
max_cooldown: int = 18000 # 最长冷却时间5小时 (18000秒)
# 模型配置
llm_reasoning: dict[str, str] = field(default_factory=lambda: {})
@ -677,17 +677,17 @@ class BotConfig:
"pfc_message_buffer_size", config.pfc_message_buffer_size
)
def idle_conversation(parent: dict):
idle_conversation_config = parent["idle_conversation"]
def idle_chat(parent: dict):
idle_chat_config = parent["idle_chat"]
if config.INNER_VERSION in SpecifierSet(">=1.6.2"):
config.enable_idle_conversation = idle_conversation_config.get(
"enable_idle_conversation", config.enable_idle_conversation
config.enable_idle_chat = idle_chat_config.get(
"enable_idle_chat", config.enable_idle_chat
)
config.idle_check_interval = idle_conversation_config.get(
config.idle_check_interval = idle_chat_config.get(
"idle_check_interval", config.idle_check_interval
)
config.min_idle_time = idle_conversation_config.get("min_idle_time", config.min_idle_time)
config.max_idle_time = idle_conversation_config.get("max_idle_time", config.max_idle_time)
config.min_cooldown = idle_chat_config.get("min_cooldown", config.min_cooldown)
config.max_cooldown = idle_chat_config.get("max_cooldown", config.max_cooldown)
# 版本表达式:>=1.0.0,<2.0.0
# 允许字段func: method, support: str, notice: str, necessary: bool
@ -722,7 +722,7 @@ class BotConfig:
"chat": {"func": chat, "support": ">=1.6.0", "necessary": False},
"normal_chat": {"func": normal_chat, "support": ">=1.6.0", "necessary": False},
"focus_chat": {"func": focus_chat, "support": ">=1.6.0", "necessary": False},
"idle_conversation": {"func": idle_conversation, "support": ">=1.6.2", "necessary": False},
"idle_chat": {"func": idle_chat, "support": ">=1.6.2", "necessary": False},
}
# 原地修改,将 字符串版本表达式 转换成 版本对象

View File

@ -144,8 +144,8 @@ class IdleChat:
self._task: Optional[asyncio.Task] = None
# 配置参数 - 从global_config加载
self.min_cooldown = global_config.min_idle_time # 最短冷却时间默认2小时
self.max_cooldown = global_config.max_idle_time # 最长冷却时间默认5小时
self.min_cooldown = global_config.min_cooldown # 最短冷却时间默认2小时
self.max_cooldown = global_config.max_cooldown # 最长冷却时间默认5小时
self.check_interval = global_config.idle_check_interval * 60 # 检查间隔默认10分钟转换为秒
self.active_hours_start = 7 # 活动开始时间
self.active_hours_end = 23 # 活动结束时间
@ -157,8 +157,8 @@ class IdleChat:
def start(self) -> None:
"""启动主动聊天检测"""
# 检查是否启用了主动聊天功能
if not global_config.enable_idle_conversation:
logger.info(f"[私聊][{self.private_name}]主动聊天功能已禁用配置ENABLE_IDLE_CONVERSATION=False")
if not global_config.enable_idle_chat:
logger.info(f"[私聊][{self.private_name}]主动聊天功能已禁用配置ENABLE_IDLE_CHAT=False")
return
if self._running:
@ -350,7 +350,7 @@ class IdleChat:
try:
while self._running:
# 检查是否启用了主动聊天功能
if not global_config.enable_idle_conversation:
if not global_config.enable_idle_chat:
# 如果禁用了功能,等待一段时间后再次检查配置
await asyncio.sleep(60) # 每分钟检查一次配置变更
continue
@ -492,12 +492,12 @@ class IdleChat:
else:
schedule_prompt = ""
# 构建提示词
# 构建提示词,暂存废弃部分这是你的日程{schedule_prompt}
current_time = datetime.now().strftime("%H:%M")
prompt = f"""你是{global_config.BOT_NICKNAME}
你正在与用户{self.private_name}进行QQ私聊你们的关系是{relationship_description}
现在时间{current_time}
这是你的日程{schedule_prompt}
你想要主动发起对话
请基于以下之前的对话历史生成一条自然友好符合关系程度的主动对话消息
这条消息应能够引起用户的兴趣重新开始对话

View File

@ -191,11 +191,11 @@ pfc_chatting = false # 是否启用PFC聊天该功能仅作用于私聊
enable_pfc_reply_checker = true # 是否启用 PFC 的回复检查器
pfc_message_buffer_size = 2 # PFC 聊天消息缓冲数量,有利于使聊天节奏更加紧凑流畅,请根据实际 LLM 响应速度进行调整默认2条
[idle_conversation]
enable_idle_conversation = false # 是否启用 pfc 主动发言
[idle_chat]
enable_idle_chat = false # 是否启用 pfc 主动发言
idle_check_interval = 10 # 检查间隔10分钟检查一次
min_idle_time = 7200 # 最短无活动时间2小时 (7200秒)
max_idle_time = 18000 # 最长无活动时间5小时 (18000秒)
min_cooldown = 7200 # 最短冷却时间2小时 (7200秒)
max_cooldown = 18000 # 最长冷却时间5小时 (18000秒)
#下面的模型若使用硅基流动则不需要更改使用ds官方则改成.env自定义的宏使用自定义模型则选择定位相似的模型自己填写
#推理模型