@aigne/example-workflow-group-chat 1.3.1 → 1.5.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/index.ts +7 -8
- package/package.json +4 -3
package/index.ts
CHANGED
|
@@ -12,18 +12,21 @@ import {
|
|
|
12
12
|
getMessage,
|
|
13
13
|
} from "@aigne/core";
|
|
14
14
|
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
15
|
-
import { logger } from "@aigne/core/utils/logger.js";
|
|
16
15
|
import inquirer from "inquirer";
|
|
17
16
|
import { z } from "zod";
|
|
18
17
|
|
|
19
18
|
const { OPENAI_API_KEY } = process.env;
|
|
20
19
|
assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
|
|
21
20
|
|
|
22
|
-
const
|
|
21
|
+
const model = new OpenAIChatModel({
|
|
23
22
|
apiKey: OPENAI_API_KEY,
|
|
24
23
|
model: "gpt-4o",
|
|
25
24
|
});
|
|
26
25
|
|
|
26
|
+
const engine = new ExecutionEngine({
|
|
27
|
+
model,
|
|
28
|
+
});
|
|
29
|
+
|
|
27
30
|
const DEFAULT_TOPIC = "DEFAULT_TOPIC";
|
|
28
31
|
|
|
29
32
|
const writer = AIAgent.from({
|
|
@@ -83,12 +86,12 @@ Make sure the images have consistent characters and style.`,
|
|
|
83
86
|
let isFirstQuestion = true;
|
|
84
87
|
|
|
85
88
|
const user = UserAgent.from({
|
|
89
|
+
context: engine.newContext(),
|
|
86
90
|
name: "user",
|
|
87
91
|
description: "User for providing final approval",
|
|
88
92
|
publishTopic: DEFAULT_TOPIC,
|
|
89
93
|
memory: { subscribeTopic: DEFAULT_TOPIC },
|
|
90
94
|
async process() {
|
|
91
|
-
logger.globalSpinner.stop();
|
|
92
95
|
const { question } = await inquirer.prompt([
|
|
93
96
|
{
|
|
94
97
|
type: "input",
|
|
@@ -101,7 +104,6 @@ const user = UserAgent.from({
|
|
|
101
104
|
},
|
|
102
105
|
]);
|
|
103
106
|
isFirstQuestion = false;
|
|
104
|
-
logger.globalSpinner.start();
|
|
105
107
|
return createMessage(question);
|
|
106
108
|
},
|
|
107
109
|
});
|
|
@@ -136,10 +138,7 @@ const manager = AIAgent.from({
|
|
|
136
138
|
}),
|
|
137
139
|
});
|
|
138
140
|
|
|
139
|
-
|
|
140
|
-
model: gpt,
|
|
141
|
-
agents: [user, manager, writer, editor, illustrator],
|
|
142
|
-
});
|
|
141
|
+
engine.addAgent(user, writer, editor, illustrator, manager);
|
|
143
142
|
|
|
144
143
|
engine.subscribe(DEFAULT_TOPIC, (message) => {
|
|
145
144
|
console.log(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-workflow-group-chat",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "A demonstration of using AIGNE Framework to build a group chat 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-group-chat",
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"openai": "^4.
|
|
19
|
+
"openai": "^4.93.0",
|
|
20
20
|
"zod": "^3.24.2",
|
|
21
|
-
"@aigne/
|
|
21
|
+
"@aigne/cli": "^1.2.0",
|
|
22
|
+
"@aigne/core": "^1.7.0"
|
|
22
23
|
},
|
|
23
24
|
"scripts": {
|
|
24
25
|
"start": "npx -y bun run index.ts",
|