@aigne/example-workflow-router 1.11.1 → 1.12.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 +44 -3
- package/index.ts +7 -12
- package/package.json +6 -6
- package/usages.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Workflow Router Demo
|
|
2
2
|
|
|
3
|
-
This is a demonstration of using [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) to build a router workflow.
|
|
3
|
+
This is a demonstration of using [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) to build a router workflow. The example now supports both one-shot and interactive chat modes, along with customizable model settings and pipeline input/output.
|
|
4
4
|
|
|
5
5
|
```mermaid
|
|
6
6
|
flowchart LR
|
|
@@ -40,7 +40,14 @@ class other processing
|
|
|
40
40
|
```bash
|
|
41
41
|
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Set your OpenAI API key
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
# Run in one-shot mode (default)
|
|
44
|
+
npx -y @aigne/example-workflow-router
|
|
45
|
+
|
|
46
|
+
# Run in interactive chat mode
|
|
47
|
+
npx -y @aigne/example-workflow-router --chat
|
|
48
|
+
|
|
49
|
+
# Use pipeline input
|
|
50
|
+
echo "How do I return a product?" | npx -y @aigne/example-workflow-router
|
|
44
51
|
```
|
|
45
52
|
|
|
46
53
|
## Installation
|
|
@@ -70,7 +77,41 @@ OPENAI_API_KEY="" # Set your OpenAI API key here
|
|
|
70
77
|
### Run the Example
|
|
71
78
|
|
|
72
79
|
```bash
|
|
73
|
-
pnpm start
|
|
80
|
+
pnpm start # Run in one-shot mode (default)
|
|
81
|
+
|
|
82
|
+
# Run in interactive chat mode
|
|
83
|
+
pnpm start -- --chat
|
|
84
|
+
|
|
85
|
+
# Use pipeline input
|
|
86
|
+
echo "How do I return a product?" | pnpm start
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Run Options
|
|
90
|
+
|
|
91
|
+
The example supports the following command-line parameters:
|
|
92
|
+
|
|
93
|
+
| Parameter | Description | Default |
|
|
94
|
+
|-----------|-------------|---------|
|
|
95
|
+
| `--chat` | Run in interactive chat mode | Disabled (one-shot mode) |
|
|
96
|
+
| `--model <provider[:model]>` | AI model to use in format 'provider[:model]' where model is optional. Examples: 'openai' or 'openai:gpt-4o-mini' | openai |
|
|
97
|
+
| `--temperature <value>` | Temperature for model generation | Provider default |
|
|
98
|
+
| `--top-p <value>` | Top-p sampling value | Provider default |
|
|
99
|
+
| `--presence-penalty <value>` | Presence penalty value | Provider default |
|
|
100
|
+
| `--frequency-penalty <value>` | Frequency penalty value | Provider default |
|
|
101
|
+
| `--log-level <level>` | Set logging level (ERROR, WARN, INFO, DEBUG, TRACE) | INFO |
|
|
102
|
+
| `--input`, `-i <input>` | Specify input directly | None |
|
|
103
|
+
|
|
104
|
+
#### Examples
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Run in chat mode (interactive)
|
|
108
|
+
pnpm start -- --chat
|
|
109
|
+
|
|
110
|
+
# Set logging level
|
|
111
|
+
pnpm start -- --log-level DEBUG
|
|
112
|
+
|
|
113
|
+
# Use pipeline input
|
|
114
|
+
echo "How do I return a product?" | pnpm start
|
|
74
115
|
```
|
|
75
116
|
|
|
76
117
|
## Example
|
package/index.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bunwrapper
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { AIAgent, AIAgentToolChoice
|
|
5
|
-
import { loadModel } from "@aigne/core/loader/index.js";
|
|
6
|
-
|
|
7
|
-
const model = await loadModel();
|
|
3
|
+
import { runWithAIGNE } from "@aigne/cli/utils/run-with-aigne.js";
|
|
4
|
+
import { AIAgent, AIAgentToolChoice } from "@aigne/core";
|
|
8
5
|
|
|
9
6
|
const productSupport = AIAgent.from({
|
|
10
7
|
name: "product_support",
|
|
@@ -43,12 +40,9 @@ Be concise, accurate, and ensure efficient handoff to the correct agent.`,
|
|
|
43
40
|
toolChoice: AIAgentToolChoice.router,
|
|
44
41
|
});
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
await runChatLoopInTerminal(userAgent, {
|
|
51
|
-
welcome: `Welcome to the support chat!
|
|
43
|
+
await runWithAIGNE(triage, {
|
|
44
|
+
chatLoopOptions: {
|
|
45
|
+
welcome: `Welcome to the support chat!
|
|
52
46
|
|
|
53
47
|
I can help you with any questions you have, such as
|
|
54
48
|
- product-related queries: "How do I use this product?"
|
|
@@ -57,5 +51,6 @@ I can help you with any questions you have, such as
|
|
|
57
51
|
|
|
58
52
|
How can I assist you today?
|
|
59
53
|
`,
|
|
60
|
-
|
|
54
|
+
defaultQuestion: "How do I use this product?",
|
|
55
|
+
},
|
|
61
56
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-workflow-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.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",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"@aigne/
|
|
22
|
-
"@aigne/core": "^1.15.0"
|
|
19
|
+
"@aigne/cli": "^1.10.0",
|
|
20
|
+
"@aigne/core": "^1.16.0",
|
|
21
|
+
"@aigne/openai": "^0.1.0"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
|
25
|
-
"@
|
|
24
|
+
"@types/bun": "^1.2.9",
|
|
25
|
+
"@aigne/test-utils": "^0.3.0"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"start": "bun run index.ts",
|
package/usages.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert";
|
|
2
2
|
import { AIAgent, AIAgentToolChoice, AIGNE } from "@aigne/core";
|
|
3
|
-
import { OpenAIChatModel } from "@aigne/
|
|
3
|
+
import { OpenAIChatModel } from "@aigne/openai";
|
|
4
4
|
|
|
5
5
|
const { OPENAI_API_KEY } = process.env;
|
|
6
6
|
assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
|