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