🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -366,7 +366,7 @@ class BaseAction(ABC):
|
||||
@classmethod
|
||||
def get_action_info(cls) -> "ActionInfo":
|
||||
"""从类属性生成ActionInfo
|
||||
|
||||
|
||||
所有信息都从类属性中读取,确保一致性和完整性。
|
||||
Action类必须定义所有必要的类属性。
|
||||
|
||||
@@ -376,7 +376,7 @@ class BaseAction(ABC):
|
||||
|
||||
# 从类属性读取名称,如果没有定义则使用类名自动生成
|
||||
name = getattr(cls, "action_name", cls.__name__.lower().replace("action", ""))
|
||||
|
||||
|
||||
# 从类属性读取描述,如果没有定义则使用文档字符串的第一行
|
||||
description = getattr(cls, "action_description", None)
|
||||
if description is None:
|
||||
|
||||
@@ -36,17 +36,17 @@ class ChatMode(Enum):
|
||||
@dataclass
|
||||
class PythonDependency:
|
||||
"""Python包依赖信息"""
|
||||
|
||||
|
||||
package_name: str # 包名称
|
||||
version: str = "" # 版本要求,例如: ">=1.0.0", "==2.1.3", ""表示任意版本
|
||||
optional: bool = False # 是否为可选依赖
|
||||
description: str = "" # 依赖描述
|
||||
install_name: str = "" # 安装时的包名(如果与import名不同)
|
||||
|
||||
|
||||
def __post_init__(self):
|
||||
if not self.install_name:
|
||||
self.install_name = self.package_name
|
||||
|
||||
|
||||
def get_pip_requirement(self) -> str:
|
||||
"""获取pip安装格式的依赖字符串"""
|
||||
if self.version:
|
||||
@@ -141,7 +141,7 @@ class PluginInfo:
|
||||
self.python_dependencies = []
|
||||
if self.metadata is None:
|
||||
self.metadata = {}
|
||||
|
||||
|
||||
def get_missing_packages(self) -> List[PythonDependency]:
|
||||
"""检查缺失的Python包"""
|
||||
missing = []
|
||||
@@ -152,7 +152,7 @@ class PluginInfo:
|
||||
if not dep.optional:
|
||||
missing.append(dep)
|
||||
return missing
|
||||
|
||||
|
||||
def get_pip_requirements(self) -> List[str]:
|
||||
"""获取所有pip安装格式的依赖"""
|
||||
return [dep.get_pip_requirement() for dep in self.python_dependencies]
|
||||
|
||||
Reference in New Issue
Block a user