@aigne/example-workflow-sequential 1.2.0 → 1.3.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/README.md +6 -8
- package/index.ts +5 -3
- package/package.json +5 -3
- package/usages.ts +6 -8
package/README.md
CHANGED
|
@@ -72,12 +72,13 @@ The following example demonstrates how to build a sequential workflow:
|
|
|
72
72
|
|
|
73
73
|
```typescript
|
|
74
74
|
import assert from "node:assert";
|
|
75
|
-
import { AIAgent,
|
|
75
|
+
import { AIAgent, ExecutionEngine, sequential } from "@aigne/core";
|
|
76
|
+
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
76
77
|
|
|
77
78
|
const { OPENAI_API_KEY } = process.env;
|
|
78
79
|
assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
|
|
79
80
|
|
|
80
|
-
const model = new
|
|
81
|
+
const model = new OpenAIChatModel({
|
|
81
82
|
apiKey: OPENAI_API_KEY,
|
|
82
83
|
});
|
|
83
84
|
|
|
@@ -125,12 +126,9 @@ Draft copy:
|
|
|
125
126
|
|
|
126
127
|
const engine = new ExecutionEngine({ model });
|
|
127
128
|
|
|
128
|
-
const result = await engine.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
writer,
|
|
132
|
-
formatProof,
|
|
133
|
-
);
|
|
129
|
+
const result = await engine.call(sequential(conceptExtractor, writer, formatProof), {
|
|
130
|
+
product: "AIGNE is a No-code Generative AI Apps Engine",
|
|
131
|
+
});
|
|
134
132
|
|
|
135
133
|
console.log(result);
|
|
136
134
|
|
package/index.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env npx -y bun
|
|
2
2
|
|
|
3
3
|
import assert from "node:assert";
|
|
4
|
-
import { AIAgent,
|
|
4
|
+
import { AIAgent, ExecutionEngine, sequential } from "@aigne/core";
|
|
5
|
+
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
6
|
+
import { runChatLoopInTerminal } from "@aigne/core/utils/run-chat-loop.js";
|
|
5
7
|
|
|
6
8
|
const { OPENAI_API_KEY } = process.env;
|
|
7
9
|
assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
|
|
8
10
|
|
|
9
|
-
const model = new
|
|
11
|
+
const model = new OpenAIChatModel({
|
|
10
12
|
apiKey: OPENAI_API_KEY,
|
|
11
13
|
});
|
|
12
14
|
|
|
@@ -54,7 +56,7 @@ Draft copy:
|
|
|
54
56
|
|
|
55
57
|
const engine = new ExecutionEngine({ model });
|
|
56
58
|
|
|
57
|
-
const userAgent =
|
|
59
|
+
const userAgent = engine.call(sequential(conceptExtractor, writer, formatProof));
|
|
58
60
|
|
|
59
61
|
await runChatLoopInTerminal(userAgent, {
|
|
60
62
|
welcome: `Hello, I'm a marketing assistant. I can help you with product descriptions, marketing copy, and editing.`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-workflow-sequential",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "A demonstration of using AIGNE Framework to build a sequential 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-sequential",
|
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"openai": "^4.89.1",
|
|
19
20
|
"zod": "^3.24.2",
|
|
20
|
-
"@aigne/core
|
|
21
|
+
"@aigne/core": "^1.5.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/usages.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import assert from "node:assert";
|
|
2
|
-
import { AIAgent,
|
|
2
|
+
import { AIAgent, ExecutionEngine, sequential } from "@aigne/core";
|
|
3
|
+
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
3
4
|
|
|
4
5
|
const { OPENAI_API_KEY } = process.env;
|
|
5
6
|
assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
|
|
6
7
|
|
|
7
|
-
const model = new
|
|
8
|
+
const model = new OpenAIChatModel({
|
|
8
9
|
apiKey: OPENAI_API_KEY,
|
|
9
10
|
});
|
|
10
11
|
|
|
@@ -52,12 +53,9 @@ Draft copy:
|
|
|
52
53
|
|
|
53
54
|
const engine = new ExecutionEngine({ model });
|
|
54
55
|
|
|
55
|
-
const result = await engine.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
writer,
|
|
59
|
-
formatProof,
|
|
60
|
-
);
|
|
56
|
+
const result = await engine.call(sequential(conceptExtractor, writer, formatProof), {
|
|
57
|
+
product: "AIGNE is a No-code Generative AI Apps Engine",
|
|
58
|
+
});
|
|
61
59
|
|
|
62
60
|
console.log(result);
|
|
63
61
|
|