@aigne/example-workflow-handoff 1.9.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 +44 -3
- package/index.ts +7 -12
- package/package.json +6 -5
- package/usages.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Workflow Handoff Demo
|
|
2
2
|
|
|
3
|
-
This is a demonstration of using [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) to build a handoff workflow.
|
|
3
|
+
This is a demonstration of using [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) to build a handoff 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
|
|
@@ -53,7 +53,14 @@ end
|
|
|
53
53
|
```bash
|
|
54
54
|
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Set your OpenAI API key
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
# Run in one-shot mode (default)
|
|
57
|
+
npx -y @aigne/example-workflow-handoff
|
|
58
|
+
|
|
59
|
+
# Run in interactive chat mode
|
|
60
|
+
npx -y @aigne/example-workflow-handoff --chat
|
|
61
|
+
|
|
62
|
+
# Use pipeline input
|
|
63
|
+
echo "transfer to agent b" | npx -y @aigne/example-workflow-handoff
|
|
57
64
|
```
|
|
58
65
|
|
|
59
66
|
## Installation
|
|
@@ -83,7 +90,41 @@ OPENAI_API_KEY="" # Set your OpenAI API key here
|
|
|
83
90
|
### Run the Example
|
|
84
91
|
|
|
85
92
|
```bash
|
|
86
|
-
pnpm start
|
|
93
|
+
pnpm start # Run in one-shot mode (default)
|
|
94
|
+
|
|
95
|
+
# Run in interactive chat mode
|
|
96
|
+
pnpm start -- --chat
|
|
97
|
+
|
|
98
|
+
# Use pipeline input
|
|
99
|
+
echo "transfer to agent b" | pnpm start
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Run Options
|
|
103
|
+
|
|
104
|
+
The example supports the following command-line parameters:
|
|
105
|
+
|
|
106
|
+
| Parameter | Description | Default |
|
|
107
|
+
|-----------|-------------|---------|
|
|
108
|
+
| `--chat` | Run in interactive chat mode | Disabled (one-shot mode) |
|
|
109
|
+
| `--model <provider[:model]>` | AI model to use in format 'provider[:model]' where model is optional. Examples: 'openai' or 'openai:gpt-4o-mini' | openai |
|
|
110
|
+
| `--temperature <value>` | Temperature for model generation | Provider default |
|
|
111
|
+
| `--top-p <value>` | Top-p sampling value | Provider default |
|
|
112
|
+
| `--presence-penalty <value>` | Presence penalty value | Provider default |
|
|
113
|
+
| `--frequency-penalty <value>` | Frequency penalty value | Provider default |
|
|
114
|
+
| `--log-level <level>` | Set logging level (ERROR, WARN, INFO, DEBUG, TRACE) | INFO |
|
|
115
|
+
| `--input`, `-i <input>` | Specify input directly | None |
|
|
116
|
+
|
|
117
|
+
#### Examples
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Run in chat mode (interactive)
|
|
121
|
+
pnpm start -- --chat
|
|
122
|
+
|
|
123
|
+
# Set logging level
|
|
124
|
+
pnpm start -- --log-level DEBUG
|
|
125
|
+
|
|
126
|
+
# Use pipeline input
|
|
127
|
+
echo "transfer to agent b" | pnpm start
|
|
87
128
|
```
|
|
88
129
|
|
|
89
130
|
## Example
|
package/index.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bunwrapper
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { AIAgent,
|
|
5
|
-
import { loadModel } from "@aigne/core/loader/index.js";
|
|
3
|
+
import { runWithAIGNE } from "@aigne/cli/utils/run-with-aigne.js";
|
|
4
|
+
import { AIAgent, type Agent, FunctionAgent } from "@aigne/core";
|
|
6
5
|
import { z } from "zod";
|
|
7
6
|
|
|
8
|
-
const model = await loadModel();
|
|
9
|
-
|
|
10
7
|
const execute_order_tool = FunctionAgent.from({
|
|
11
8
|
name: "execute_order",
|
|
12
9
|
description: "Price should be in USD.",
|
|
@@ -145,11 +142,9 @@ But make your questions subtle and natural.
|
|
|
145
142
|
memory: true,
|
|
146
143
|
});
|
|
147
144
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
welcome: `Hello, I'm a customer service bot for ACME Inc. How can I help you today?`,
|
|
154
|
-
defaultQuestion: "I want a refund",
|
|
145
|
+
await runWithAIGNE(triage, {
|
|
146
|
+
chatLoopOptions: {
|
|
147
|
+
welcome: `Hello, I'm a customer service bot for ACME Inc. How can I help you today?`,
|
|
148
|
+
defaultQuestion: "I want a refund",
|
|
149
|
+
},
|
|
155
150
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-workflow-handoff",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "A demonstration of using AIGNE Framework to build a handoff 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-handoff",
|
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"openai": "^4.97.0",
|
|
20
19
|
"zod": "^3.24.4",
|
|
21
|
-
"@aigne/core": "^1.
|
|
22
|
-
"@aigne/
|
|
20
|
+
"@aigne/core": "^1.16.0",
|
|
21
|
+
"@aigne/openai": "^0.1.0",
|
|
22
|
+
"@aigne/cli": "^1.10.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@
|
|
25
|
+
"@types/bun": "^1.2.9",
|
|
26
|
+
"@aigne/test-utils": "^0.3.0"
|
|
26
27
|
},
|
|
27
28
|
"scripts": {
|
|
28
29
|
"start": "bun run index.ts",
|
package/usages.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert";
|
|
2
2
|
import { AIAgent, 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");
|