diff --git a/src/plugins/action_executer/action_executer.py b/src/plugins/action_executer/action_executer.py new file mode 100644 index 00000000..8edb7340 --- /dev/null +++ b/src/plugins/action_executer/action_executer.py @@ -0,0 +1,23 @@ +class ResponseAction: + def __init__(self): + self.tags = [] + + def parse_action(self, msg: str, action: str) -> str: + if action in msg: + self.tags.append(action) + return msg.replace(action, '') + return msg + + def empty(self): + return len(self.tags) == 0 + + def __contains__(self, other: str): + if isinstance(other, str): + return other in self.tags + else: + # 非str输入直接抛异常 + raise TypeError + + def __bool__(self): + # 这是为了直接嵌入到llm_generator.py的处理流里 便于跳过消息处理流程 + return False \ No newline at end of file diff --git a/src/plugins/config/config.py b/src/plugins/config/config.py index 1ac2a7ea..37daf580 100644 --- a/src/plugins/config/config.py +++ b/src/plugins/config/config.py @@ -115,7 +115,7 @@ class BotConfig: # experimental enable_friend_chat: bool = False # 是否启用好友聊天 enable_think_flow: bool = False # 是否启用思考流程 - + enable_think_flow: bool = False # 是否允许执行动作 # 模型配置 @@ -421,6 +421,7 @@ class BotConfig: experimental_config = parent["experimental"] config.enable_friend_chat = experimental_config.get("enable_friend_chat", config.enable_friend_chat) config.enable_think_flow = experimental_config.get("enable_think_flow", config.enable_think_flow) + config.enable_action_execute = experimental_config.get("enable_action_execute", config.enable_action_execute) # 版本表达式:>=1.0.0,<2.0.0 # 允许字段:func: method, support: str, notice: str, necessary: bool