feat: prompt 加载器的扩展性

This commit is contained in:
Junyan Qin
2024-03-12 16:22:07 +00:00
parent 8c6ce1f030
commit b9fa11c0c3
4 changed files with 23 additions and 5 deletions
+14
View File
@@ -1,13 +1,27 @@
from __future__ import annotations
import abc
import typing
from ...core import app
from . import entities
preregistered_loaders: list[typing.Type[PromptLoader]] = []
def loader_class(name: str):
def decorator(cls: typing.Type[PromptLoader]) -> typing.Type[PromptLoader]:
cls.name = name
preregistered_loaders.append(cls)
return cls
return decorator
class PromptLoader(metaclass=abc.ABCMeta):
"""Prompt加载器抽象类
"""
name: str
ap: app.Application