@aigne/example-chat-bot 1.8.1 → 1.9.1
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 +73 -2
- package/index.ts +2 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Chatbot Example
|
|
2
2
|
|
|
3
|
-
This example demonstrates how to create and run an agent-based chatbot using the [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) and [AIGNE CLI](https://github.com/AIGNE-io/aigne-framework/blob/main/docs/cli.md).
|
|
3
|
+
This example demonstrates how to create and run an agent-based chatbot using the [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) and [AIGNE CLI](https://github.com/AIGNE-io/aigne-framework/blob/main/docs/cli.md). The example now supports both one-shot and interactive chat modes, along with customizable model settings and pipeline input/output.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
@@ -15,5 +15,76 @@ This example demonstrates how to create and run an agent-based chatbot using the
|
|
|
15
15
|
```bash
|
|
16
16
|
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Set your OpenAI API key
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
# Run in one-shot mode (default)
|
|
19
|
+
npx -y @aigne/example-chat-bot
|
|
20
|
+
|
|
21
|
+
# Run in interactive chat mode
|
|
22
|
+
npx -y @aigne/example-chat-bot --chat
|
|
23
|
+
|
|
24
|
+
# Use pipeline input
|
|
25
|
+
echo "Tell me about AIGNE Framework" | npx -y @aigne/example-chat-bot
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
### Clone the Repository
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/AIGNE-io/aigne-framework
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Install Dependencies
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
cd aigne-framework/examples/chat-bot
|
|
40
|
+
|
|
41
|
+
pnpm install
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Setup Environment Variables
|
|
45
|
+
|
|
46
|
+
Setup your OpenAI API key in the `.env.local` file:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
OPENAI_API_KEY="" # Set your OpenAI API key here
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Run the Example
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pnpm start # Run in one-shot mode (default)
|
|
56
|
+
|
|
57
|
+
# Run in interactive chat mode
|
|
58
|
+
pnpm start -- --chat
|
|
59
|
+
|
|
60
|
+
# Use pipeline input
|
|
61
|
+
echo "Tell me about AIGNE Framework" | pnpm start
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Run Options
|
|
65
|
+
|
|
66
|
+
The example supports the following command-line parameters:
|
|
67
|
+
|
|
68
|
+
| Parameter | Description | Default |
|
|
69
|
+
|-----------|-------------|---------|
|
|
70
|
+
| `--chat` | Run in interactive chat mode | Disabled (one-shot mode) |
|
|
71
|
+
| `--model <provider[:model]>` | AI model to use in format 'provider[:model]' where model is optional. Examples: 'openai' or 'openai:gpt-4o-mini' | openai |
|
|
72
|
+
| `--temperature <value>` | Temperature for model generation | Provider default |
|
|
73
|
+
| `--top-p <value>` | Top-p sampling value | Provider default |
|
|
74
|
+
| `--presence-penalty <value>` | Presence penalty value | Provider default |
|
|
75
|
+
| `--frequency-penalty <value>` | Frequency penalty value | Provider default |
|
|
76
|
+
| `--log-level <level>` | Set logging level (ERROR, WARN, INFO, DEBUG, TRACE) | INFO |
|
|
77
|
+
| `--input`, `-i <input>` | Specify input directly | None |
|
|
78
|
+
|
|
79
|
+
#### Examples
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Run in chat mode (interactive)
|
|
83
|
+
pnpm start -- --chat
|
|
84
|
+
|
|
85
|
+
# Set logging level
|
|
86
|
+
pnpm start -- --log-level DEBUG
|
|
87
|
+
|
|
88
|
+
# Use pipeline input
|
|
89
|
+
echo "Tell me about AIGNE Framework" | pnpm start
|
|
19
90
|
```
|
package/index.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { spawnSync } from "node:child_process";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
+
import { argv } from "node:process";
|
|
5
6
|
|
|
6
7
|
const path = join(import.meta.dirname, "agents");
|
|
7
8
|
|
|
8
|
-
spawnSync("aigne", ["run", path], { stdio: "inherit" });
|
|
9
|
+
spawnSync("aigne", ["run", path, ...argv.slice(2)], { stdio: "inherit" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-chat-bot",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "A demonstration of using AIGNE Framework to build a chat bot",
|
|
5
5
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
6
6
|
"homepage": "https://github.com/AIGNE-io/aigne-framework/tree/main/examples/chat-bot",
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
"README.md"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@aigne/cli": "^1.
|
|
21
|
+
"@aigne/cli": "^1.10.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@
|
|
24
|
+
"@types/bun": "^1.2.9",
|
|
25
|
+
"@aigne/test-utils": "^0.3.1"
|
|
25
26
|
},
|
|
26
27
|
"scripts": {
|
|
27
28
|
"start": "bun run index.ts",
|