新增插件智能模式适配 (#1850)

* 新增插件智能模式适配

* 🚨 auto fix by pre-commit hooks

* 更改类名,命名更清晰

* 🎨 添加模块化参数

* 🎨  AI模块化修改

* 🩹  道具调用修复

* 🩹 修复商品使用前检测

* ✨ retry增加参数适配

* ✨  修改道具使用函数参数传递

* ✨ 捕获道具无法使用异常

* 🐛 添加依赖require

* 🐛  修复插件使用问题

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: HibiKier <45528451+HibiKier@users.noreply.github.com>
This commit is contained in:
ChthollyWn
2025-02-24 09:28:53 +08:00
committed by GitHub
co-authored by pre-commit-ci[bot] HibiKier
parent 78df9ed086
commit a6ddb726d3
5 changed files with 97 additions and 40 deletions
+36
View File
@@ -170,6 +170,40 @@ class PluginSetting(BaseModel):
"""调用插件好感度限制"""
class AICallableProperties(BaseModel):
type: str
"""参数类型"""
description: str
"""参数描述"""
enums: list[str] | None = None
"""参数枚举"""
class AICallableParam(BaseModel):
type: str
"""类型"""
properties: dict[str, AICallableProperties]
"""参数列表"""
required: list[str]
"""必要参数"""
class AICallableTag(BaseModel):
name: str
"""工具名称"""
parameters: AICallableParam | None = None
"""工具参数"""
description: str
"""工具描述"""
func: Callable | None = None
"""工具函数"""
def to_dict(self):
result = model_dump(self)
del result["func"]
return result
class SchedulerModel(BaseModel):
trigger: Literal["date", "interval", "cron"]
"""trigger"""
@@ -249,6 +283,8 @@ class PluginExtraData(BaseModel):
"""常用sql"""
is_show: bool = True
"""是否显示在菜单中"""
smart_tools: list[AICallableTag] | None = None
"""智能模式函数工具集"""
def to_dict(self, **kwargs):
return model_dump(self, **kwargs)