@aigne/example-workflow-router 1.8.0 → 1.10.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 CHANGED
@@ -79,7 +79,7 @@ The following example demonstrates how to build a router workflow:
79
79
 
80
80
  ```typescript
81
81
  import assert from "node:assert";
82
- import { AIAgent, ExecutionEngine } from "@aigne/core";
82
+ import { AIAgent, AIGNE } from "@aigne/core";
83
83
  import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
84
84
 
85
85
  const { OPENAI_API_KEY } = process.env;
@@ -121,25 +121,25 @@ const triage = AIAgent.from({
121
121
  instructions: `You are an agent capable of routing questions to the appropriate agent.
122
122
  Your goal is to understand the user's query and direct them to the agent best suited to assist them.
123
123
  Be efficient, clear, and ensure the user is connected to the right resource quickly.`,
124
- tools: [productSupport, feedback, other],
124
+ skills: [productSupport, feedback, other],
125
125
  toolChoice: "router", // Set toolChoice to "router" to enable router mode
126
126
  });
127
127
 
128
- const engine = new ExecutionEngine({ model });
128
+ const aigne = new AIGNE({ model });
129
129
 
130
- const result1 = await engine.call(triage, "How to use this product?");
130
+ const result1 = await aigne.invoke(triage, "How to use this product?");
131
131
  console.log(result1);
132
132
  // {
133
133
  // product_support: "I’d be happy to help you with that! However, I need to know which specific product you’re referring to. Could you please provide me with the name or type of product you have in mind?",
134
134
  // }
135
135
 
136
- const result2 = await engine.call(triage, "I have feedback about the app.");
136
+ const result2 = await aigne.invoke(triage, "I have feedback about the app.");
137
137
  console.log(result2);
138
138
  // {
139
139
  // feedback: "Thank you for sharing your feedback! I'm here to listen. Please go ahead and let me know what you’d like to share about the app.",
140
140
  // }
141
141
 
142
- const result3 = await engine.call(triage, "What is the weather today?");
142
+ const result3 = await aigne.invoke(triage, "What is the weather today?");
143
143
  console.log(result3);
144
144
  // {
145
145
  // other: "I can't provide real-time weather updates. However, you can check a reliable weather website or a weather app on your phone for the current conditions in your area. If you tell me your location, I can suggest a few sources where you can find accurate weather information!",
package/index.test.ts CHANGED
@@ -1,5 +1,11 @@
1
- import { test } from "bun:test";
1
+ import { expect, test } from "bun:test";
2
+ import { runExampleTest } from "@aigne/test-utils/run-example-test.js";
2
3
 
3
- test("should successfully execute the workflow-router", () => import("./index.js"), {
4
- timeout: 60000,
5
- });
4
+ test(
5
+ "should successfully run the workflow-router",
6
+ async () => {
7
+ const { code } = await runExampleTest();
8
+ expect(code).toBe(0);
9
+ },
10
+ { timeout: 600000 },
11
+ );
package/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bunwrapper
2
2
 
3
3
  import { runChatLoopInTerminal } from "@aigne/cli/utils/run-chat-loop.js";
4
- import { AIAgent, ExecutionEngine } from "@aigne/core";
4
+ import { AIAgent, AIGNE } from "@aigne/core";
5
5
  import { loadModel } from "@aigne/core/loader/index.js";
6
6
 
7
7
  const model = await loadModel();
@@ -38,13 +38,13 @@ const triage = AIAgent.from({
38
38
  instructions: `You are an agent capable of routing questions to the appropriate agent.
39
39
  Your goal is to understand the user's query and direct them to the agent best suited to assist them.
40
40
  Be efficient, clear, and ensure the user is connected to the right resource quickly.`,
41
- tools: [productSupport, feedback, other],
41
+ skills: [productSupport, feedback, other],
42
42
  toolChoice: "router",
43
43
  });
44
44
 
45
- const engine = new ExecutionEngine({ model });
45
+ const aigne = new AIGNE({ model });
46
46
 
47
- const userAgent = engine.call(triage);
47
+ const userAgent = aigne.invoke(triage);
48
48
 
49
49
  await runChatLoopInTerminal(userAgent, {
50
50
  welcome: `Welcome to the support chat!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/example-workflow-router",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "description": "A demonstration of using AIGNE Framework to build a router 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-router",
@@ -18,8 +18,11 @@
18
18
  "dependencies": {
19
19
  "openai": "^4.94.0",
20
20
  "zod": "^3.24.2",
21
- "@aigne/cli": "^1.7.0",
22
- "@aigne/core": "^1.11.0"
21
+ "@aigne/core": "^1.13.0",
22
+ "@aigne/cli": "^1.8.1"
23
+ },
24
+ "devDependencies": {
25
+ "@aigne/test-utils": "^0.1.0"
23
26
  },
24
27
  "scripts": {
25
28
  "start": "bun run index.ts",
package/usages.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import assert from "node:assert";
2
- import { AIAgent, ExecutionEngine } from "@aigne/core";
2
+ import { AIAgent, AIGNE } from "@aigne/core";
3
3
  import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
4
4
 
5
5
  const { OPENAI_API_KEY } = process.env;
@@ -41,25 +41,25 @@ const triage = AIAgent.from({
41
41
  instructions: `You are an agent capable of routing questions to the appropriate agent.
42
42
  Your goal is to understand the user's query and direct them to the agent best suited to assist them.
43
43
  Be efficient, clear, and ensure the user is connected to the right resource quickly.`,
44
- tools: [productSupport, feedback, other],
44
+ skills: [productSupport, feedback, other],
45
45
  toolChoice: "router", // Set toolChoice to "router" to enable router mode
46
46
  });
47
47
 
48
- const engine = new ExecutionEngine({ model });
48
+ const aigne = new AIGNE({ model });
49
49
 
50
- const result1 = await engine.call(triage, "How to use this product?");
50
+ const result1 = await aigne.invoke(triage, "How to use this product?");
51
51
  console.log(result1);
52
52
  // {
53
53
  // product_support: "I’d be happy to help you with that! However, I need to know which specific product you’re referring to. Could you please provide me with the name or type of product you have in mind?",
54
54
  // }
55
55
 
56
- const result2 = await engine.call(triage, "I have feedback about the app.");
56
+ const result2 = await aigne.invoke(triage, "I have feedback about the app.");
57
57
  console.log(result2);
58
58
  // {
59
59
  // feedback: "Thank you for sharing your feedback! I'm here to listen. Please go ahead and let me know what you’d like to share about the app.",
60
60
  // }
61
61
 
62
- const result3 = await engine.call(triage, "What is the weather today?");
62
+ const result3 = await aigne.invoke(triage, "What is the weather today?");
63
63
  console.log(result3);
64
64
  // {
65
65
  // other: "I can't provide real-time weather updates. However, you can check a reliable weather website or a weather app on your phone for the current conditions in your area. If you tell me your location, I can suggest a few sources where you can find accurate weather information!",