1+ from src .plugin_system .base .base_plugin import BasePlugin , register_plugin
2+ from src .plugin_system .base .component_types import ComponentInfo
13from src .common .logger import get_logger
2- from src .plugin_system .base .base_action import BaseAction as PluginAction , ActionActivationType
3- from src .plugin_system .base .base_action import register_action
4- from typing import Tuple
4+ from src .plugin_system .base .base_action import BaseAction , ActionActivationType , ChatMode
5+ from typing import Tuple , List , Type
56
6- logger = get_logger ("vtb_action " )
7+ logger = get_logger ("vtb " )
78
89
9- @register_action
10- class VTBAction (PluginAction ):
10+ class VTBAction (BaseAction ):
1111 """VTB虚拟主播动作处理类"""
1212
1313 action_name = "vtb_action"
@@ -24,9 +24,13 @@ class VTBAction(PluginAction):
2424 enable_plugin = True # 启用插件
2525 associated_types = ["vtb_text" ]
2626
27+ # 模式和并行控制
28+ mode_enable = ChatMode .ALL
29+ parallel_action = True # VTB动作可以与回复并行执行,增强表达效果
30+
2731 # 激活类型设置
2832 focus_activation_type = ActionActivationType .LLM_JUDGE # Focus模式使用LLM判定,精确识别情感表达需求
29- normal_activation_type = ActionActivationType .RANDOM # Normal模式使用随机激活,增加趣味性
33+ normal_activation_type = ActionActivationType .ALWAYS # Normal模式使用随机激活,增加趣味性
3034
3135 # LLM判定提示词(用于Focus模式)
3236 llm_judge_prompt = """
@@ -35,18 +39,13 @@ class VTBAction(PluginAction):
35392. 用户询问或讨论情感相关话题
36403. 场景需要生动的情感回应
37414. 当前回复内容可以通过VTB动作增强表达效果
38-
39- 不需要使用的情况:
40- 1. 纯粹的信息查询
41- 2. 技术性问题讨论
42- 3. 不涉及情感的日常对话
43424. 已经有足够的情感表达
4443"""
4544
4645 # Random激活概率(用于Normal模式)
4746 random_activation_probability = 0.08 # 较低概率,避免过度使用
4847
49- async def process (self ) -> Tuple [bool , str ]:
48+ async def execute (self ) -> Tuple [bool , str ]:
5049 """处理VTB虚拟主播动作"""
5150 logger .info (f"{ self .log_prefix } 执行VTB动作: { self .reasoning } " )
5251
@@ -61,8 +60,8 @@ async def process(self) -> Tuple[bool, str]:
6160 processed_text = self ._process_text_for_vtb (text )
6261
6362 try :
64- # 发送VTB动作消息
65- await self .send_message (type = "vtb_text" , data = processed_text )
63+ # 发送VTB动作消息 - 使用新版本的send_type方法
64+ await self .send_type (type = "vtb_text" , text = processed_text )
6665
6766 logger .info (f"{ self .log_prefix } VTB动作执行成功,文本内容: { processed_text } " )
6867 return True , "VTB动作执行成功"
@@ -95,3 +94,39 @@ def _process_text_for_vtb(self, text: str) -> str:
9594 processed_text = "平静"
9695
9796 return processed_text
97+
98+
99+ @register_plugin
100+ class VTBPlugin (BasePlugin ):
101+ """VTB虚拟主播插件
102+ - 这是虚拟主播情感表达插件
103+ - Normal模式下依靠随机触发增加趣味性
104+ - Focus模式下由LLM判断触发,精确识别情感表达需求
105+ - 具有情感文本处理和优化能力
106+ """
107+
108+ # 插件基本信息
109+ plugin_name = "vtb_plugin"
110+ plugin_description = "虚拟主播情感表达插件"
111+ plugin_version = "0.1.0"
112+ plugin_author = "MaiBot开发团队"
113+ enable_plugin = True
114+ config_file_name = "config.toml"
115+
116+ def get_plugin_components (self ) -> List [Tuple [ComponentInfo , Type ]]:
117+ """返回插件包含的组件列表"""
118+
119+ # 从配置获取组件启用状态
120+ enable_vtb = self .get_config ("components.enable_vtb" , True )
121+ components = []
122+
123+ # 添加Action组件
124+ if enable_vtb :
125+ components .append (
126+ (
127+ VTBAction .get_action_info (name = "vtb_action" , description = "虚拟主播情感表达插件" ),
128+ VTBAction ,
129+ )
130+ )
131+
132+ return components
0 commit comments