feat: 插件自动发现 — plugins.json + 代码生成器
- plugins.json 配置文件列出所有插件及其import路径 - gen_plugins.go 读取配置生成 plugins_gen.go - main.go 调用 registerPlugins() 替代硬编码列表 - 新增 backend/plugins/ 第三方插件目录 - 插件开发文档: docs/api/plugin-development.md Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -31,15 +31,8 @@ import (
|
||||
|
||||
plgManager "git.yeij.top/AskaEth/Cyrene-Plugins/manager"
|
||||
plgSDK "git.yeij.top/AskaEth/Cyrene-Plugins/sdk"
|
||||
pluginCalc "git.yeij.top/AskaEth/Cyrene-Plugins/calculator"
|
||||
pluginCrypto "git.yeij.top/AskaEth/Cyrene-Plugins/crypto"
|
||||
pluginDate "git.yeij.top/AskaEth/Cyrene-Plugins/datetime"
|
||||
pluginFile "git.yeij.top/AskaEth/Cyrene-Plugins/file"
|
||||
pluginHTTP "git.yeij.top/AskaEth/Cyrene-Plugins/http"
|
||||
pluginJSON "git.yeij.top/AskaEth/Cyrene-Plugins/json"
|
||||
pluginMD "git.yeij.top/AskaEth/Cyrene-Plugins/markdown"
|
||||
pluginRand "git.yeij.top/AskaEth/Cyrene-Plugins/random"
|
||||
pluginText "git.yeij.top/AskaEth/Cyrene-Plugins/text"
|
||||
pluginWF "git.yeij.top/AskaEth/Cyrene-Plugins/web_fetch"
|
||||
pluginWS "git.yeij.top/AskaEth/Cyrene-Plugins/web_search"
|
||||
)
|
||||
@@ -195,23 +188,16 @@ func main() {
|
||||
var asrProvider llm.ASRProvider
|
||||
if getEnvBool("ENABLE_TOOLS", true) {
|
||||
// 11 个共享通用插件 — 注册其工具到统一注册中心
|
||||
registerPluginTools(toolRegistry, &pluginCalc.CalculatorPlugin{})
|
||||
registerPluginTools(toolRegistry, &pluginDate.DatetimePlugin{})
|
||||
registerPluginTools(toolRegistry, &pluginText.TextPlugin{})
|
||||
registerPluginTools(toolRegistry, &pluginCrypto.CryptoPlugin{})
|
||||
registerPluginTools(toolRegistry, &pluginRand.RandomPlugin{})
|
||||
registerPluginTools(toolRegistry, &pluginMD.MarkdownPlugin{})
|
||||
registerPluginTools(toolRegistry, &pluginJSON.JSONPlugin{})
|
||||
registerPluginTools(toolRegistry, pluginFile.NewFilePlugin(dataDir))
|
||||
registerPluginTools(toolRegistry, pluginHTTP.NewHTTPPlugin())
|
||||
searxngURL := getEnv("SEARXNG_URL", "")
|
||||
if searxngURL != "" {
|
||||
registerPluginTools(toolRegistry, pluginWS.NewWebSearchPluginWithURL(searxngURL))
|
||||
} else {
|
||||
registerPluginTools(toolRegistry, pluginWS.NewWebSearchPlugin())
|
||||
}
|
||||
registerPluginTools(toolRegistry, pluginWF.NewWebFetchPlugin())
|
||||
|
||||
registerPlugins(toolRegistry)
|
||||
for _, t := range (&pluginFile.FilePlugin{}).Tools() { toolRegistry.Register(t) }
|
||||
for _, t := range (&pluginHTTP.HTTPPlugin{}).Tools() { toolRegistry.Register(t) }
|
||||
for _, t := range (&pluginWS.WebSearchPlugin{}).Tools() { toolRegistry.Register(t) }
|
||||
for _, t := range (&pluginWF.WebFetchPlugin{}).Tools() { toolRegistry.Register(t) }
|
||||
// ai-core 专属工具 — 通过 sdk.Tool 适配器注册
|
||||
if iotClient != nil {
|
||||
toolRegistry.Register(wrapTool(tools.NewIoTQueryTool(iotClient), "iot_query", "Query IoT Devices", "iot"))
|
||||
|
||||
Reference in New Issue
Block a user