44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
|
|
"""插件相关数据模型"""
|
||
|
|
from typing import Optional, Dict, Any
|
||
|
|
from pydantic import BaseModel, Field
|
||
|
|
|
||
|
|
|
||
|
|
class PluginRequest(BaseModel):
|
||
|
|
"""
|
||
|
|
插件请求模型
|
||
|
|
|
||
|
|
Attributes:
|
||
|
|
plugin_id: 插件ID
|
||
|
|
action: 执行动作
|
||
|
|
params: 请求参数
|
||
|
|
"""
|
||
|
|
plugin_id: str = Field(..., description="插件ID", examples=["plugin_001"])
|
||
|
|
action: str = Field(..., description="执行动作", examples=["execute"])
|
||
|
|
params: Optional[Dict[str, Any]] = Field(default=None, description="请求参数")
|
||
|
|
|
||
|
|
model_config = {
|
||
|
|
"json_schema_extra": {
|
||
|
|
"examples": [
|
||
|
|
{
|
||
|
|
"plugin_id": "plugin_001",
|
||
|
|
"action": "execute",
|
||
|
|
"params": {"key": "value"}
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
class PluginResponse(BaseModel):
|
||
|
|
"""
|
||
|
|
插件响应模型
|
||
|
|
|
||
|
|
Attributes:
|
||
|
|
plugin_id: 插件ID
|
||
|
|
result: 执行结果
|
||
|
|
status: 执行状态
|
||
|
|
"""
|
||
|
|
plugin_id: str = Field(..., description="插件ID")
|
||
|
|
result: Optional[Dict[str, Any]] = Field(default=None, description="执行结果")
|
||
|
|
status: str = Field(default="success", description="执行状态")
|