@@ -225,9 +225,9 @@ class MessageManager:
|
|||||||
if (
|
if (
|
||||||
# message.apply_set_reply_logic # 检查标记
|
# message.apply_set_reply_logic # 检查标记
|
||||||
# and message.is_head
|
# and message.is_head
|
||||||
message.is_head
|
# message.is_head
|
||||||
and (thinking_messages_count > 3 or thinking_messages_length > 200)
|
# and (thinking_messages_count > 3 or thinking_messages_length > 200) and
|
||||||
and not message.is_private_message()
|
not message.is_private_message()
|
||||||
):
|
):
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"[{message.chat_stream.stream_id}] 应用 set_reply 逻辑: {message.processed_plain_text[:20]}..."
|
f"[{message.chat_stream.stream_id}] 应用 set_reply 逻辑: {message.processed_plain_text[:20]}..."
|
||||||
|
|||||||
@@ -165,8 +165,9 @@ class NormalChat:
|
|||||||
if not items_to_process:
|
if not items_to_process:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 处理每条兴趣消息
|
# 并行处理兴趣消息
|
||||||
for msg_id, (message, interest_value, is_mentioned) in items_to_process:
|
async def process_single_message(msg_id, message, interest_value, is_mentioned):
|
||||||
|
"""处理单个兴趣消息"""
|
||||||
try:
|
try:
|
||||||
# 处理消息
|
# 处理消息
|
||||||
if time.time() - self.start_time > 300:
|
if time.time() - self.start_time > 300:
|
||||||
@@ -184,6 +185,24 @@ class NormalChat:
|
|||||||
finally:
|
finally:
|
||||||
self.interest_dict.pop(msg_id, None)
|
self.interest_dict.pop(msg_id, None)
|
||||||
|
|
||||||
|
# 创建并行任务列表
|
||||||
|
tasks = []
|
||||||
|
for msg_id, (message, interest_value, is_mentioned) in items_to_process:
|
||||||
|
task = process_single_message(msg_id, message, interest_value, is_mentioned)
|
||||||
|
tasks.append(task)
|
||||||
|
|
||||||
|
# 并行执行所有任务,限制并发数量避免资源过度消耗
|
||||||
|
if tasks:
|
||||||
|
# 使用信号量控制并发数,最多同时处理5个消息
|
||||||
|
semaphore = asyncio.Semaphore(5)
|
||||||
|
|
||||||
|
async def limited_process(task):
|
||||||
|
async with semaphore:
|
||||||
|
await task
|
||||||
|
|
||||||
|
limited_tasks = [limited_process(task) for task in tasks]
|
||||||
|
await asyncio.gather(*limited_tasks, return_exceptions=True)
|
||||||
|
|
||||||
# 改为实例方法, 移除 chat 参数
|
# 改为实例方法, 移除 chat 参数
|
||||||
async def normal_response(self, message: MessageRecv, is_mentioned: bool, interested_rate: float) -> None:
|
async def normal_response(self, message: MessageRecv, is_mentioned: bool, interested_rate: float) -> None:
|
||||||
# 新增:如果已停用,直接返回
|
# 新增:如果已停用,直接返回
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ description = "文字转语音插件"
|
|||||||
|
|
||||||
# 组件启用控制
|
# 组件启用控制
|
||||||
[components]
|
[components]
|
||||||
enable_tarots = true
|
enable_tts = true
|
||||||
|
|
||||||
# 日志配置
|
# 日志配置
|
||||||
[logging]
|
[logging]
|
||||||
|
|||||||
@@ -110,13 +110,11 @@ class TTSPlugin(BasePlugin):
|
|||||||
|
|
||||||
# 从配置获取组件启用状态
|
# 从配置获取组件启用状态
|
||||||
enable_tts = self.get_config("components.enable_tts", True)
|
enable_tts = self.get_config("components.enable_tts", True)
|
||||||
components = []
|
components = [] # 添加Action组件
|
||||||
|
|
||||||
# 添加Action组件
|
|
||||||
if enable_tts:
|
if enable_tts:
|
||||||
components.append(
|
components.append(
|
||||||
(
|
(
|
||||||
TTSAction.get_action_info(name="tarots_action", description="文字转语音插件"),
|
TTSAction.get_action_info(name="tts_action", description="文字转语音插件"),
|
||||||
TTSAction,
|
TTSAction,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
from . import vtb_action # noqa
|
|
||||||
26
src/plugins/built_in/vtb_plugin/config.toml
Normal file
26
src/plugins/built_in/vtb_plugin/config.toml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# 虚拟主播情感表达插件配置文件
|
||||||
|
|
||||||
|
[plugin]
|
||||||
|
name = "vtb_plugin"
|
||||||
|
version = "0.1.0"
|
||||||
|
enabled = true
|
||||||
|
description = "虚拟主播情感表达插件"
|
||||||
|
|
||||||
|
# 组件启用控制
|
||||||
|
[components]
|
||||||
|
enable_vtb = true
|
||||||
|
|
||||||
|
# VTB动作配置
|
||||||
|
[vtb_action]
|
||||||
|
# 情感表达增强选项
|
||||||
|
enable_emotion_enhancement = true
|
||||||
|
max_text_length = 100
|
||||||
|
default_emotion = "平静"
|
||||||
|
|
||||||
|
# 激活概率控制(Normal模式)
|
||||||
|
random_activation_probability = 0.08
|
||||||
|
|
||||||
|
# 日志配置
|
||||||
|
[logging]
|
||||||
|
level = "INFO"
|
||||||
|
prefix = "[VTB]"
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
|
from src.plugin_system.base.base_plugin import BasePlugin, register_plugin
|
||||||
|
from src.plugin_system.base.component_types import ComponentInfo
|
||||||
from src.common.logger import get_logger
|
from src.common.logger import get_logger
|
||||||
from src.plugin_system.base.base_action import BaseAction as PluginAction, ActionActivationType
|
from src.plugin_system.base.base_action import BaseAction, ActionActivationType, ChatMode
|
||||||
from src.plugin_system.base.base_action import register_action
|
from typing import Tuple, List, Type
|
||||||
from typing import Tuple
|
|
||||||
|
|
||||||
logger = get_logger("vtb_action")
|
logger = get_logger("vtb")
|
||||||
|
|
||||||
|
|
||||||
@register_action
|
class VTBAction(BaseAction):
|
||||||
class VTBAction(PluginAction):
|
|
||||||
"""VTB虚拟主播动作处理类"""
|
"""VTB虚拟主播动作处理类"""
|
||||||
|
|
||||||
action_name = "vtb_action"
|
action_name = "vtb_action"
|
||||||
@@ -24,9 +24,13 @@ class VTBAction(PluginAction):
|
|||||||
enable_plugin = True # 启用插件
|
enable_plugin = True # 启用插件
|
||||||
associated_types = ["vtb_text"]
|
associated_types = ["vtb_text"]
|
||||||
|
|
||||||
|
# 模式和并行控制
|
||||||
|
mode_enable = ChatMode.ALL
|
||||||
|
parallel_action = True # VTB动作可以与回复并行执行,增强表达效果
|
||||||
|
|
||||||
# 激活类型设置
|
# 激活类型设置
|
||||||
focus_activation_type = ActionActivationType.LLM_JUDGE # Focus模式使用LLM判定,精确识别情感表达需求
|
focus_activation_type = ActionActivationType.LLM_JUDGE # Focus模式使用LLM判定,精确识别情感表达需求
|
||||||
normal_activation_type = ActionActivationType.RANDOM # Normal模式使用随机激活,增加趣味性
|
normal_activation_type = ActionActivationType.ALWAYS # Normal模式使用随机激活,增加趣味性
|
||||||
|
|
||||||
# LLM判定提示词(用于Focus模式)
|
# LLM判定提示词(用于Focus模式)
|
||||||
llm_judge_prompt = """
|
llm_judge_prompt = """
|
||||||
@@ -35,18 +39,13 @@ class VTBAction(PluginAction):
|
|||||||
2. 用户询问或讨论情感相关话题
|
2. 用户询问或讨论情感相关话题
|
||||||
3. 场景需要生动的情感回应
|
3. 场景需要生动的情感回应
|
||||||
4. 当前回复内容可以通过VTB动作增强表达效果
|
4. 当前回复内容可以通过VTB动作增强表达效果
|
||||||
|
|
||||||
不需要使用的情况:
|
|
||||||
1. 纯粹的信息查询
|
|
||||||
2. 技术性问题讨论
|
|
||||||
3. 不涉及情感的日常对话
|
|
||||||
4. 已经有足够的情感表达
|
4. 已经有足够的情感表达
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Random激活概率(用于Normal模式)
|
# Random激活概率(用于Normal模式)
|
||||||
random_activation_probability = 0.08 # 较低概率,避免过度使用
|
random_activation_probability = 0.08 # 较低概率,避免过度使用
|
||||||
|
|
||||||
async def process(self) -> Tuple[bool, str]:
|
async def execute(self) -> Tuple[bool, str]:
|
||||||
"""处理VTB虚拟主播动作"""
|
"""处理VTB虚拟主播动作"""
|
||||||
logger.info(f"{self.log_prefix} 执行VTB动作: {self.reasoning}")
|
logger.info(f"{self.log_prefix} 执行VTB动作: {self.reasoning}")
|
||||||
|
|
||||||
@@ -61,8 +60,8 @@ class VTBAction(PluginAction):
|
|||||||
processed_text = self._process_text_for_vtb(text)
|
processed_text = self._process_text_for_vtb(text)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 发送VTB动作消息
|
# 发送VTB动作消息 - 使用新版本的send_type方法
|
||||||
await self.send_message(type="vtb_text", data=processed_text)
|
await self.send_type(type="vtb_text", text=processed_text)
|
||||||
|
|
||||||
logger.info(f"{self.log_prefix} VTB动作执行成功,文本内容: {processed_text}")
|
logger.info(f"{self.log_prefix} VTB动作执行成功,文本内容: {processed_text}")
|
||||||
return True, "VTB动作执行成功"
|
return True, "VTB动作执行成功"
|
||||||
@@ -95,3 +94,39 @@ class VTBAction(PluginAction):
|
|||||||
processed_text = "平静"
|
processed_text = "平静"
|
||||||
|
|
||||||
return processed_text
|
return processed_text
|
||||||
|
|
||||||
|
|
||||||
|
@register_plugin
|
||||||
|
class VTBPlugin(BasePlugin):
|
||||||
|
"""VTB虚拟主播插件
|
||||||
|
- 这是虚拟主播情感表达插件
|
||||||
|
- Normal模式下依靠随机触发增加趣味性
|
||||||
|
- Focus模式下由LLM判断触发,精确识别情感表达需求
|
||||||
|
- 具有情感文本处理和优化能力
|
||||||
|
"""
|
||||||
|
|
||||||
|
# 插件基本信息
|
||||||
|
plugin_name = "vtb_plugin"
|
||||||
|
plugin_description = "虚拟主播情感表达插件"
|
||||||
|
plugin_version = "0.1.0"
|
||||||
|
plugin_author = "MaiBot开发团队"
|
||||||
|
enable_plugin = True
|
||||||
|
config_file_name = "config.toml"
|
||||||
|
|
||||||
|
def get_plugin_components(self) -> List[Tuple[ComponentInfo, Type]]:
|
||||||
|
"""返回插件包含的组件列表"""
|
||||||
|
|
||||||
|
# 从配置获取组件启用状态
|
||||||
|
enable_vtb = self.get_config("components.enable_vtb", True)
|
||||||
|
components = []
|
||||||
|
|
||||||
|
# 添加Action组件
|
||||||
|
if enable_vtb:
|
||||||
|
components.append(
|
||||||
|
(
|
||||||
|
VTBAction.get_action_info(name="vtb_action", description="虚拟主播情感表达插件"),
|
||||||
|
VTBAction,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return components
|
||||||
Reference in New Issue
Block a user