- 创建一个文件夹,例如
my_extension - 在该文件夹下创建一个
info.json文件,并添加以下内容:
{
"description": "扩展说明",
"enabled": false,
"func": [ // 定义 function tool
{
"description": "get system version info", //Function tool 描述
"func": "do_example_tool_call", //tool 函数名 ** 需要在__init__.py中实现
"name": "获取系统版本信息", //tool 名称
"parameters": { //tool 参数
"properties": {
"item": {
"description": "anything",
"type": "string"
}
},
"required": [
"item"
],
"type": "object"
}
}
],
"icon": "/icon?id=example_extension",
"id": "example_extension", //id需要和plugin下的文件夹名称一致
"size": "0.01MB",
"title": "example 扩展名字",
"type": "func",
"updated": "2025-02-20",
"version": "0.0.1",
"author": "Example Developer",
"website": "https://example.com"
}
- 在
my_extension文件夹下创建一个__init__.py文件,并添加以下内容:
from funcproxy.core.plugin_base import PluginBase
class Plugin(PluginBase):
# 继承PluginBase类,实现函数
def do_example_tool_call(self, parameters) -> str:
pass- [可选]如果扩展需要引入配置项的话,可以在
my_extension文件夹下创建 setting.json 文件,并添加以下内容,在扩展详情页面会自动生成表单:
{
"current": {
"apikey": ""
},
"form": [
{
"default": "",
"label": "API KEY",
"name": "apikey",
"placeholder": "API KEY",
"required": true,
"type": "text"
}
]
}扩展开发完成后,将my_extension文件夹,上传到src/plugins文件夹中。或者使用web界面进行上传。