feat: 新的引入路径

This commit is contained in:
RockChinQ 2024-03-20 15:48:11 +08:00
parent 52a7c25540
commit 9855c6b8f5
5 changed files with 32 additions and 16 deletions

View File

@ -85,8 +85,7 @@ class Application:
tasks = []
try:
tasks = [
asyncio.create_task(self.im_mgr.run()),
asyncio.create_task(self.ctrl.run())

View File

@ -9,6 +9,26 @@ from ..provider.tools import entities as tools_entities
from ..core import app
def register(
name: str,
description: str,
version: str,
author
) -> typing.Callable[[typing.Type[BasePlugin]], typing.Type[BasePlugin]]:
pass
def handler(
event: typing.Type[events.BaseEventModel]
) -> typing.Callable[[typing.Callable], typing.Callable]:
pass
def llm_func(
name: str=None,
) -> typing.Callable:
pass
class BasePlugin(metaclass=abc.ABCMeta):
"""插件基类"""

View File

@ -1,3 +1,7 @@
# 此模块已过时
# 请从 pkg.plugin.context 引入 BasePlugin, EventContext 和 APIHost
# 最早将于 v3.4 移除此模块
from . events import *
from . context import EventContext, APIHost as PluginHost

View File

@ -28,8 +28,9 @@ class PluginLoader(loader.PluginLoader):
setattr(models, 'on', self.on)
setattr(models, 'func', self.func)
setattr(models, 'handler', self.handler)
setattr(models, 'llm_func', self.llm_func)
setattr(context, 'register', self.register)
setattr(context, 'handler', self.handler)
setattr(context, 'llm_func', self.llm_func)
def register(
self,

View File

@ -1,3 +1,7 @@
# 此模块已过时,请引入 pkg.plugin.context 中的 register, handler 和 llm_func 来注册插件、事件处理函数和内容函数
# 各个事件模型请从 pkg.plugin.events 引入
# 最早将于 v3.4 移除此模块
from __future__ import annotations
import typing
@ -24,15 +28,3 @@ def func(
name: str=None,
) -> typing.Callable:
pass
def handler(
event: typing.Type[BaseEventModel]
) -> typing.Callable[[typing.Callable], typing.Callable]:
pass
def llm_func(
name: str=None,
) -> typing.Callable:
pass