Skip to content

Commit 5519248

Browse files
c121914yuFinleyGe
authored andcommitted
Install packages
1 parent 0ee9fda commit 5519248

File tree

11 files changed

+182
-2
lines changed

11 files changed

+182
-2
lines changed

bun.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
},
6969
"devDependencies": {
7070
"@babel/preset-typescript": "^7.27.1",
71+
"@types/babel__generator": "^7.27.0",
72+
"@types/babel__traverse": "^7.28.0",
7173
},
7274
},
7375
"runtime": {
@@ -417,6 +419,10 @@
417419

418420
"@ts-rest/open-api": ["@ts-rest/[email protected]", "", { "dependencies": { "@anatine/zod-openapi": "^1.12.0", "openapi3-ts": "^2.0.2" }, "peerDependencies": { "@ts-rest/core": "~3.52.0", "zod": "^3.22.3" } }, "sha512-VY91g6HFzCe1/fNgX4Y3HzaJbIdztCGHTg34drkh7bKgtNOizLJLXV0wwIkMwLGvjhRHojJxnwYxHjGMIkScwg=="],
419421

422+
"@types/babel__generator": ["@types/[email protected]", "", { "dependencies": { "@babel/types": "^7.0.0" } }, "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg=="],
423+
424+
"@types/babel__traverse": ["@types/[email protected]", "", { "dependencies": { "@babel/types": "^7.28.2" } }, "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q=="],
425+
420426
"@types/body-parser": ["@types/[email protected]", "", { "dependencies": { "@types/connect": "*", "@types/node": "*" } }, "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g=="],
421427

422428
"@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.2.23" } }, "sha512-le8ueOY5b6VKYf19xT3McVbXqLqmxzPXHsQT/q9JHgikJ2X22wyTW3g3ohz2ZMnp7dod6aduIiq8A14Xyimm0A=="],

modules/tool/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"build:marketplace": "bun run ./build/build-json.ts"
66
},
77
"devDependencies": {
8-
"@babel/preset-typescript": "^7.27.1"
8+
"@babel/preset-typescript": "^7.27.1",
9+
"@types/babel__generator": "^7.27.0",
10+
"@types/babel__traverse": "^7.28.0"
911
},
1012
"dependencies": {
1113
"@babel/generator": "^7.28.3",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# xxx 系统工具
2+
3+
## 参考信息
4+
5+
### 参考文档
6+
7+
### 测试密钥环境变量名
8+
9+
### 工具集/子工具列表
10+
11+
描述工具集名称,以及子工具,子工具需要包含 ID,名字,哪些输入输出,例如:
12+
13+
```
14+
工具集名:Redis 操作,需要填写 redis 链接字符串做为密钥。
15+
16+
子工具列表:
17+
1. get;获取缓存了;输入 key;输出 value和是否存在
18+
2. set;设置缓存;输入 key,value,ttl;输出是否成功
19+
3. del;删除缓存;输入 key;输出是否成功
20+
```
21+
22+
---
23+
24+
下面由 AI 生成完整的设计文档
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# example tool
2+
3+
Write the introduction for your tool here.
4+
5+
You can insert a picture with following markdown
6+
7+
```markdown
8+
Insert a assets picture (you need to put you picture file in the assets dir)
9+
![](./assets/pic.png)
10+
11+
Or insert a public pic
12+
![](https://picsum.photos/200)
13+
```
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { defineTool } from '@tool/type';
2+
import {
3+
FlowNodeInputTypeEnum,
4+
FlowNodeOutputTypeEnum,
5+
WorkflowIOValueTypeEnum
6+
} from '@tool/type/fastgpt';
7+
import { ToolTagEnum } from '@tool/type/tags';
8+
9+
export default defineTool({
10+
name: {
11+
'zh-CN': '模版工具',
12+
en: 'Template tool'
13+
},
14+
tags: [ToolTagEnum.enum.tools],
15+
description: {
16+
'zh-CN': '描述',
17+
en: 'description'
18+
},
19+
toolDescription:
20+
'tool description for ai to use, fallback to English description if not provided',
21+
secretInputConfig: [
22+
{
23+
key: 'apiKey',
24+
label: 'API Key',
25+
description: '可以在 xxx 获取',
26+
required: true,
27+
inputType: 'secret'
28+
}
29+
],
30+
versionList: [
31+
{
32+
value: '0.1.0',
33+
description: 'Default version',
34+
inputs: [
35+
{
36+
key: 'formatStr',
37+
label: '格式化字符串',
38+
renderTypeList: [FlowNodeInputTypeEnum.input, FlowNodeInputTypeEnum.reference],
39+
valueType: WorkflowIOValueTypeEnum.string
40+
}
41+
],
42+
outputs: [
43+
{
44+
valueType: WorkflowIOValueTypeEnum.string,
45+
key: 'time',
46+
label: '时间',
47+
description: '当前时间'
48+
}
49+
]
50+
}
51+
]
52+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import config from './config';
2+
import { InputType, OutputType, tool as toolCb } from './src';
3+
import { exportTool } from '@tool/utils/tool';
4+
5+
export default exportTool({
6+
toolCb,
7+
InputType,
8+
OutputType,
9+
config
10+
});
Lines changed: 20 additions & 0 deletions
Loading
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@fastgpt-plugins/tool-test1",
3+
"module": "index.ts",
4+
"type": "module",
5+
"scripts": {
6+
"build": "bun ../../../../scripts/build.ts"
7+
},
8+
"devDependencies": {
9+
"@types/bun": "latest"
10+
},
11+
"peerDependencies": {
12+
"typescript": "^5.0.0"
13+
},
14+
"dependencies": {
15+
"zod": "^3.24.3"
16+
}
17+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { format } from 'date-fns';
2+
import { z } from 'zod';
3+
import axios from 'next';
4+
export const InputType = z.object({
5+
apiKey: z.string(),
6+
formatStr: z.string().optional().default('yyyy-MM-dd HH:mm:ss')
7+
});
8+
9+
export const OutputType = z.object({
10+
time: z.string()
11+
});
12+
13+
export async function tool({
14+
apiKey,
15+
formatStr
16+
}: z.infer<typeof InputType>): Promise<z.infer<typeof OutputType>> {
17+
// 请求数据
18+
// const result = await fetch('https://api.example.com/data', {
19+
// method: 'POST',
20+
// body: JSON.stringify({
21+
// apiKey
22+
// })
23+
// });
24+
25+
return {
26+
time: format(new Date(), formatStr)
27+
};
28+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { expect, test } from 'vitest';
2+
import tool from '..';
3+
4+
test(async () => {
5+
expect(tool.name).toBeDefined();
6+
expect(tool.description).toBeDefined();
7+
expect(tool.cb).toBeDefined();
8+
});

0 commit comments

Comments
 (0)