点击插件+号
点击创建插件
输入插件名称
然后添加工具,工具可以添加多个,名称必须是英文
在元数据中添加输入与输出,插件工具代码支持python与nodejs,我们以nodejs为例
然后在代码中修改,记得添加axios的依赖,使用axios请求自己的api服务器提供服务:
import { Args } from '@/runtime'; import { Input, Output } from "@/typings/find_codes/find_codes"; import axios from 'axios'; /** * Each file needs to export a function named `handler`. This function is the entrance to the Tool. * @param {Object} args.input - input parameters, you can get test input value by input.xxx. * @param {Object} args.logger - logger instance used to print logs, injected by runtime * @returns {*} The return data of the function, which should match the declared output parameters. * * Remember to fill in input/output in Metadata, it helps LLM to recognize and use tool. */ export async function handler({ input, logger }: Args<Input>): Promise<Output> { // 发送一个GET请求 const response = await axios.post('https://www.bfw.wiki/', { firstName: 'Fred', lastName: 'Flintstone' }); return { codes: "您的代码链接:https://www.bfw.wiki/"+input.name, }; };然后运行查看效果
最后点击发布,发布成功后
我们在插件中+号选择自己刚添加的插件局,然后问答中coze就会自动调用插件了。
网友回复