events system init
This commit is contained in:
19
src/plugin_system/base/base_event_plugin.py
Normal file
19
src/plugin_system/base/base_event_plugin.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
from abc import ABC, abstractmethod
|
||||||
|
from typing import List, Dict, Type
|
||||||
|
|
||||||
|
class BaseEventsPlugin(ABC):
|
||||||
|
"""
|
||||||
|
事件触发型插件基类
|
||||||
|
|
||||||
|
所有事件触发型插件都应该继承这个基类而不是 BasePlugin
|
||||||
|
"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
@abstractmethod
|
||||||
|
def plugin_name(self) -> str:
|
||||||
|
return "" # 插件内部标识符(如 "hello_world_plugin")
|
||||||
|
|
||||||
|
@property
|
||||||
|
@abstractmethod
|
||||||
|
def enable_plugin(self) -> bool:
|
||||||
|
return False
|
||||||
@@ -40,6 +40,20 @@ class ChatMode(Enum):
|
|||||||
return self.value
|
return self.value
|
||||||
|
|
||||||
|
|
||||||
|
# 事件类型枚举
|
||||||
|
class EventType(Enum):
|
||||||
|
"""
|
||||||
|
事件类型枚举类
|
||||||
|
"""
|
||||||
|
|
||||||
|
ON_MESSAGE = "on_message"
|
||||||
|
ON_PLAN = "on_plan"
|
||||||
|
POST_LLM = "post_llm"
|
||||||
|
AFTER_LLM = "after_llm"
|
||||||
|
POST_SEND = "post_send"
|
||||||
|
AFTER_SEND = "after_send"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class PythonDependency:
|
class PythonDependency:
|
||||||
"""Python包依赖信息"""
|
"""Python包依赖信息"""
|
||||||
|
|||||||
9
src/plugin_system/core/events_manager.py
Normal file
9
src/plugin_system/core/events_manager.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from typing import List, Dict, Type
|
||||||
|
|
||||||
|
from src.plugin_system.base.component_types import EventType
|
||||||
|
|
||||||
|
|
||||||
|
class EventsManager:
|
||||||
|
def __init__(self):
|
||||||
|
# 有权重的 events 订阅者注册表
|
||||||
|
self.events_subscribers: Dict[EventType, List[Dict[int, Type]]] = {event: [] for event in EventType}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
"""
|
|
||||||
插件的事件系统模块
|
|
||||||
"""
|
|
||||||
|
|
||||||
from .events import EventType
|
|
||||||
|
|
||||||
__all__ = [
|
|
||||||
"EventType",
|
|
||||||
]
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
from enum import Enum
|
|
||||||
|
|
||||||
|
|
||||||
class EventType(Enum):
|
|
||||||
"""
|
|
||||||
事件类型枚举类
|
|
||||||
"""
|
|
||||||
|
|
||||||
ON_MESSAGE = "on_message"
|
|
||||||
ON_PLAN = "on_plan"
|
|
||||||
POST_LLM = "post_llm"
|
|
||||||
AFTER_LLM = "after_llm"
|
|
||||||
POST_SEND = "post_send"
|
|
||||||
AFTER_SEND = "after_send"
|
|
||||||
Reference in New Issue
Block a user