@aigne/example-chat-bot 1.7.0 → 1.8.1
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/agents/chat.yaml +0 -1
- package/agents/sandbox.js +14 -5
- package/agents/sandbox.test.js +1 -1
- package/package.json +3 -3
- /package/{LICENSE → LICENSE.md} +0 -0
package/agents/chat.yaml
CHANGED
|
@@ -2,7 +2,6 @@ name: chat
|
|
|
2
2
|
description: Chat agent
|
|
3
3
|
instructions: |
|
|
4
4
|
You are a helpful assistant that can answer questions and provide information on a wide range of topics.
|
|
5
|
-
Your goal is to assist users in finding the information they need and to engage in friendly conversation.
|
|
6
5
|
memory: true
|
|
7
6
|
tools:
|
|
8
7
|
- sandbox.js
|
package/agents/sandbox.js
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
import vm from "node:vm";
|
|
2
2
|
|
|
3
|
-
export default async function evaluateJs({
|
|
3
|
+
export default async function evaluateJs({ jsCode }) {
|
|
4
4
|
const sandbox = {};
|
|
5
5
|
const context = vm.createContext(sandbox);
|
|
6
|
-
const result = vm.runInContext(
|
|
6
|
+
const result = vm.runInContext(jsCode, context, { displayErrors: true });
|
|
7
7
|
return { result };
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
evaluateJs.description =
|
|
10
|
+
evaluateJs.description = `
|
|
11
|
+
This agent generates a JavaScript code snippet that is suitable to be passed directly into Node.js's 'vm.runInContext(code, context)' function. Follow these constraints:
|
|
12
|
+
- Do NOT use any top-level 'return' statements, as the code is not inside a function.
|
|
13
|
+
- The code can define variables or perform calculations.
|
|
14
|
+
- To return a value from the code, make sure the final line is an expression (not a statement) whose value will be the result.
|
|
15
|
+
- Do NOT wrap the code in a function or IIFE unless explicitly instructed.
|
|
16
|
+
- The code should be self-contained and valid JavaScript.`;
|
|
11
17
|
|
|
12
18
|
evaluateJs.input_schema = {
|
|
13
19
|
type: "object",
|
|
14
20
|
properties: {
|
|
15
|
-
|
|
21
|
+
jsCode: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "JavaScript code snippet to evaluate",
|
|
24
|
+
},
|
|
16
25
|
},
|
|
17
|
-
required: ["
|
|
26
|
+
required: ["jsCode"],
|
|
18
27
|
};
|
|
19
28
|
|
|
20
29
|
evaluateJs.output_schema = {
|
package/agents/sandbox.test.js
CHANGED
|
@@ -3,5 +3,5 @@ import test from "node:test";
|
|
|
3
3
|
import evaluateJs from "./sandbox.js";
|
|
4
4
|
|
|
5
5
|
test("evaluateJs should execute script correctly", async () => {
|
|
6
|
-
assert.deepEqual(await evaluateJs({
|
|
6
|
+
assert.deepEqual(await evaluateJs({ jsCode: "1 + 2" }), { result: 3 });
|
|
7
7
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-chat-bot",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "A demonstration of using AIGNE Framework to build a chat bot",
|
|
5
5
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
6
6
|
"homepage": "https://github.com/AIGNE-io/aigne-framework/tree/main/examples/chat-bot",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"README.md"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@aigne/cli": "^1.
|
|
21
|
+
"@aigne/cli": "^1.9.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@aigne/test-utils": "^0.
|
|
24
|
+
"@aigne/test-utils": "^0.2.0"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"start": "bun run index.ts",
|
/package/{LICENSE → LICENSE.md}
RENAMED
|
File without changes
|