让activation概率可以为0
This commit is contained in:
@@ -3,7 +3,7 @@ from src.plugin_system.base.base_action import BaseAction
|
|||||||
from src.chat.message_receive.chat_stream import ChatStream
|
from src.chat.message_receive.chat_stream import ChatStream
|
||||||
from src.common.logger import get_logger
|
from src.common.logger import get_logger
|
||||||
from src.plugin_system.core.component_registry import component_registry
|
from src.plugin_system.core.component_registry import component_registry
|
||||||
from src.plugin_system.base.component_types import ComponentType, ActionActivationType, ChatMode, ActionInfo
|
from src.plugin_system.base.component_types import ComponentType, ActionInfo
|
||||||
|
|
||||||
logger = get_logger("action_manager")
|
logger = get_logger("action_manager")
|
||||||
|
|
||||||
@@ -15,11 +15,6 @@ class ActionManager:
|
|||||||
现在统一使用新插件系统,简化了原有的新旧兼容逻辑。
|
现在统一使用新插件系统,简化了原有的新旧兼容逻辑。
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# 类常量
|
|
||||||
DEFAULT_RANDOM_PROBABILITY = 0.3
|
|
||||||
DEFAULT_MODE = ChatMode.ALL
|
|
||||||
DEFAULT_ACTIVATION_TYPE = ActionActivationType.ALWAYS
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""初始化动作管理器"""
|
"""初始化动作管理器"""
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ class ActionModifier:
|
|||||||
continue # 总是激活,无需处理
|
continue # 总是激活,无需处理
|
||||||
|
|
||||||
elif activation_type == ActionActivationType.RANDOM:
|
elif activation_type == ActionActivationType.RANDOM:
|
||||||
probability = action_info.random_activation_probability or ActionManager.DEFAULT_RANDOM_PROBABILITY
|
probability = action_info.random_activation_probability
|
||||||
if random.random() >= probability:
|
if random.random() >= probability:
|
||||||
reason = f"RANDOM类型未触发(概率{probability})"
|
reason = f"RANDOM类型未触发(概率{probability})"
|
||||||
deactivated_actions.append((action_name, reason))
|
deactivated_actions.append((action_name, reason))
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class ChatManager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_all_streams(platform: Optional[str] | SpecialTypes = "qq") -> List[ChatStream]:
|
def get_all_streams(platform: Optional[str] | SpecialTypes = "qq") -> List[ChatStream]:
|
||||||
|
# sourcery skip: for-append-to-extend
|
||||||
"""获取所有聊天流
|
"""获取所有聊天流
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -57,6 +58,7 @@ class ChatManager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_group_streams(platform: Optional[str] | SpecialTypes = "qq") -> List[ChatStream]:
|
def get_group_streams(platform: Optional[str] | SpecialTypes = "qq") -> List[ChatStream]:
|
||||||
|
# sourcery skip: for-append-to-extend
|
||||||
"""获取所有群聊聊天流
|
"""获取所有群聊聊天流
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -79,6 +81,7 @@ class ChatManager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_private_streams(platform: Optional[str] | SpecialTypes = "qq") -> List[ChatStream]:
|
def get_private_streams(platform: Optional[str] | SpecialTypes = "qq") -> List[ChatStream]:
|
||||||
|
# sourcery skip: for-append-to-extend
|
||||||
"""获取所有私聊聊天流
|
"""获取所有私聊聊天流
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -105,7 +108,7 @@ class ChatManager:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_group_stream_by_group_id(
|
def get_group_stream_by_group_id(
|
||||||
group_id: str, platform: Optional[str] | SpecialTypes = "qq"
|
group_id: str, platform: Optional[str] | SpecialTypes = "qq"
|
||||||
) -> Optional[ChatStream]:
|
) -> Optional[ChatStream]: # sourcery skip: remove-unnecessary-cast
|
||||||
"""根据群ID获取聊天流
|
"""根据群ID获取聊天流
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -142,7 +145,7 @@ class ChatManager:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_private_stream_by_user_id(
|
def get_private_stream_by_user_id(
|
||||||
user_id: str, platform: Optional[str] | SpecialTypes = "qq"
|
user_id: str, platform: Optional[str] | SpecialTypes = "qq"
|
||||||
) -> Optional[ChatStream]:
|
) -> Optional[ChatStream]: # sourcery skip: remove-unnecessary-cast
|
||||||
"""根据用户ID获取私聊流
|
"""根据用户ID获取私聊流
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ async def generate_reply(
|
|||||||
|
|
||||||
logger.debug("[GeneratorAPI] 开始生成回复")
|
logger.debug("[GeneratorAPI] 开始生成回复")
|
||||||
|
|
||||||
if not reply_to:
|
if not reply_to and action_data:
|
||||||
reply_to = action_data.get("reply_to", "")
|
reply_to = action_data.get("reply_to", "")
|
||||||
if not extra_info and action_data:
|
if not extra_info and action_data:
|
||||||
extra_info = action_data.get("extra_info", "")
|
extra_info = action_data.get("extra_info", "")
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ class BaseAction(ABC):
|
|||||||
keyword_case_sensitive=getattr(cls, "keyword_case_sensitive", False),
|
keyword_case_sensitive=getattr(cls, "keyword_case_sensitive", False),
|
||||||
mode_enable=getattr(cls, "mode_enable", ChatMode.ALL),
|
mode_enable=getattr(cls, "mode_enable", ChatMode.ALL),
|
||||||
parallel_action=getattr(cls, "parallel_action", True),
|
parallel_action=getattr(cls, "parallel_action", True),
|
||||||
random_activation_probability=getattr(cls, "random_activation_probability", 0.3),
|
random_activation_probability=getattr(cls, "random_activation_probability", 0.0),
|
||||||
llm_judge_prompt=getattr(cls, "llm_judge_prompt", ""),
|
llm_judge_prompt=getattr(cls, "llm_judge_prompt", ""),
|
||||||
# 使用正确的字段名
|
# 使用正确的字段名
|
||||||
action_parameters=getattr(cls, "action_parameters", {}).copy(),
|
action_parameters=getattr(cls, "action_parameters", {}).copy(),
|
||||||
|
|||||||
Reference in New Issue
Block a user