@aidejs/tools 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +26 -0
- package/src/index.js +16 -0
- package/src/readPlain.js +27 -0
- package/src/writePlain.js +26 -0
- package/types/index.d.ts +5 -0
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aidejs/tools",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "@aidejs/tools",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"typings": "./types/index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"scripts": {},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/NN-Studio/Aidejs.git",
|
|
12
|
+
"directory": "packages/tools"
|
|
13
|
+
},
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "zxl20070701",
|
|
16
|
+
"url": "https://zxl20070701.github.io/notebook/home.html"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/NN-Studio/Aidejs/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/NN-Studio/Aidejs",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"oipage": "^2.0.0"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
install(Aidejs) {
|
|
3
|
+
|
|
4
|
+
// 工具列表
|
|
5
|
+
const tools = {
|
|
6
|
+
readPlain: require('./readPlain'),
|
|
7
|
+
writePlain: require('./writePlain'),
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// 注册工具
|
|
11
|
+
for (let toolName in tools) {
|
|
12
|
+
Aidejs.registerTool(toolName, tools[toolName]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
};
|
package/src/readPlain.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
|
|
3
|
+
// 描述这个工具方法
|
|
4
|
+
// https://docs.ollama.com/api/chat#body-tools
|
|
5
|
+
"description": {
|
|
6
|
+
"type": "function",
|
|
7
|
+
"function": {
|
|
8
|
+
"name": "readPlain", // 方法名称
|
|
9
|
+
"description": "读取文本文件中的内容", // 描述这个方法有什么功能
|
|
10
|
+
"parameters": { // 调用这个方法需要的参数
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"filepath": { // 参数一
|
|
14
|
+
"type": "string", // 参数类型
|
|
15
|
+
"description": "需要读取的文本文件的全路径", // 参数描述
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"required": ["filepath"], // 哪些是必须参数
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
// 定义这个工具方法
|
|
24
|
+
"valueOf": function (args) {
|
|
25
|
+
return require("oipage/nodejs/disk/index.js").readPlain(args.filepath);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"description": {
|
|
3
|
+
"type": "function",
|
|
4
|
+
"function": {
|
|
5
|
+
"name": "writePlain",
|
|
6
|
+
"description": "在指定文本文件中写入内容",
|
|
7
|
+
"parameters": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"filepath": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "需要写入文本文件的全路径",
|
|
13
|
+
},
|
|
14
|
+
"content": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "需要写入的内容",
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": ["filepath", "content"],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
"valueOf": function (args) {
|
|
24
|
+
return require("oipage/nodejs/disk/index.js").writePlain(args.filepath, args.content);
|
|
25
|
+
}
|
|
26
|
+
};
|