@aigne/example-workflow-code-execution 1.1.0 → 1.2.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/README.md +4 -4
- package/index.ts +6 -5
- package/package.json +5 -3
- package/usage.ts +4 -6
package/README.md
CHANGED
|
@@ -90,13 +90,13 @@ The following example demonstrates how to build a code-execution workflow:
|
|
|
90
90
|
|
|
91
91
|
```typescript
|
|
92
92
|
import assert from "node:assert";
|
|
93
|
-
import { AIAgent,
|
|
93
|
+
import { AIAgent, OpenAIChatModel, ExecutionEngine, FunctionAgent } from "@aigne/core";
|
|
94
94
|
import { z } from "zod";
|
|
95
95
|
|
|
96
96
|
const { OPENAI_API_KEY } = process.env;
|
|
97
97
|
assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
|
|
98
98
|
|
|
99
|
-
const model = new
|
|
99
|
+
const model = new OpenAIChatModel({
|
|
100
100
|
apiKey: OPENAI_API_KEY,
|
|
101
101
|
});
|
|
102
102
|
|
|
@@ -125,11 +125,11 @@ Work with the sandbox to execute your code.
|
|
|
125
125
|
|
|
126
126
|
const engine = new ExecutionEngine({ model });
|
|
127
127
|
|
|
128
|
-
const result = await engine.
|
|
128
|
+
const result = await engine.call(coder, "10! = ?");
|
|
129
129
|
console.log(result);
|
|
130
130
|
// Output:
|
|
131
131
|
// {
|
|
132
|
-
//
|
|
132
|
+
// $message: "The value of \\(10!\\) (10 factorial) is 3,628,800.",
|
|
133
133
|
// }
|
|
134
134
|
```
|
|
135
135
|
|
package/index.ts
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
import assert from "node:assert";
|
|
4
4
|
import {
|
|
5
5
|
AIAgent,
|
|
6
|
-
ChatModelOpenAI,
|
|
7
6
|
ExecutionEngine,
|
|
8
7
|
FunctionAgent,
|
|
8
|
+
OpenAIChatModel,
|
|
9
9
|
runChatLoopInTerminal,
|
|
10
|
-
} from "@aigne/core
|
|
10
|
+
} from "@aigne/core";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
13
|
const { OPENAI_API_KEY } = process.env;
|
|
14
14
|
assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
|
|
15
15
|
|
|
16
|
-
const model = new
|
|
16
|
+
const model = new OpenAIChatModel({
|
|
17
17
|
apiKey: OPENAI_API_KEY,
|
|
18
18
|
});
|
|
19
19
|
|
|
@@ -38,13 +38,14 @@ You are a proficient coder. You write code to solve problems.
|
|
|
38
38
|
Work with the sandbox to execute your code.
|
|
39
39
|
`,
|
|
40
40
|
tools: [sandbox],
|
|
41
|
+
memory: true,
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
const engine = new ExecutionEngine({ model });
|
|
44
45
|
|
|
45
|
-
const
|
|
46
|
+
const user = engine.call(coder);
|
|
46
47
|
|
|
47
|
-
await runChatLoopInTerminal(
|
|
48
|
+
await runChatLoopInTerminal(user, {
|
|
48
49
|
welcome:
|
|
49
50
|
"Welcome to the code execution workflow! you can ask me anything can be resolved by running code.",
|
|
50
51
|
defaultQuestion: "10! = ?",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-workflow-code-execution",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A demonstration of using AIGNE Framework to build a code-execution workflow",
|
|
5
5
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
6
6
|
"homepage": "https://github.com/AIGNE-io/aigne-framework/tree/main/examples/workflow-code-execution",
|
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"openai": "^4.89.0",
|
|
19
20
|
"zod": "^3.24.2",
|
|
20
|
-
"@aigne/core
|
|
21
|
+
"@aigne/core": "^1.3.0"
|
|
21
22
|
},
|
|
22
23
|
"scripts": {
|
|
23
|
-
"start": "npx -y bun run index.ts"
|
|
24
|
+
"start": "npx -y bun run index.ts",
|
|
25
|
+
"lint": "tsc --noEmit"
|
|
24
26
|
}
|
|
25
27
|
}
|
package/usage.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
#!/usr/bin/env npx -y bun
|
|
2
|
-
|
|
3
1
|
import assert from "node:assert";
|
|
4
|
-
import { AIAgent,
|
|
2
|
+
import { AIAgent, ExecutionEngine, FunctionAgent, OpenAIChatModel } from "@aigne/core";
|
|
5
3
|
import { z } from "zod";
|
|
6
4
|
|
|
7
5
|
const { OPENAI_API_KEY } = process.env;
|
|
8
6
|
assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
|
|
9
7
|
|
|
10
|
-
const model = new
|
|
8
|
+
const model = new OpenAIChatModel({
|
|
11
9
|
apiKey: OPENAI_API_KEY,
|
|
12
10
|
});
|
|
13
11
|
|
|
@@ -36,9 +34,9 @@ Work with the sandbox to execute your code.
|
|
|
36
34
|
|
|
37
35
|
const engine = new ExecutionEngine({ model });
|
|
38
36
|
|
|
39
|
-
const result = await engine.
|
|
37
|
+
const result = await engine.call(coder, "10! = ?");
|
|
40
38
|
console.log(result);
|
|
41
39
|
// Output:
|
|
42
40
|
// {
|
|
43
|
-
//
|
|
41
|
+
// $message: "The value of \\(10!\\) (10 factorial) is 3,628,800.",
|
|
44
42
|
// }
|