@aigne/agent-library 1.5.0 → 1.6.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/CHANGELOG.md +16 -0
- package/LICENSE +93 -0
- package/README.md +133 -0
- package/README.zh.md +133 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
- chore: release 1.2.0
|
|
4
4
|
|
|
5
|
+
## [1.6.1](https://github.com/AIGNE-io/aigne-framework/compare/agent-library-v1.6.0...agent-library-v1.6.1) (2025-04-23)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Dependencies
|
|
9
|
+
|
|
10
|
+
* The following workspace dependencies were updated
|
|
11
|
+
* dependencies
|
|
12
|
+
* @aigne/core bumped to 1.11.0
|
|
13
|
+
|
|
14
|
+
## [1.6.0](https://github.com/AIGNE-io/aigne-framework/compare/agent-library-v1.5.0...agent-library-v1.6.0) (2025-04-22)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **stream:** add streaming output support for agent ([#73](https://github.com/AIGNE-io/aigne-framework/issues/73)) ([5f3ea4b](https://github.com/AIGNE-io/aigne-framework/commit/5f3ea4bccda7c8c457d6e9518b3d6a8b254ec041))
|
|
20
|
+
|
|
5
21
|
## [1.5.0](https://github.com/AIGNE-io/aigne-framework/compare/agent-library-v1.4.0...agent-library-v1.5.0) (2025-04-15)
|
|
6
22
|
|
|
7
23
|
|
package/LICENSE
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Elastic License 2.0
|
|
2
|
+
|
|
3
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
12
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
13
|
+
available, and prepare derivative works of the software, in each case subject to
|
|
14
|
+
the limitations and conditions below.
|
|
15
|
+
|
|
16
|
+
## Limitations
|
|
17
|
+
|
|
18
|
+
You may not provide the software to third parties as a hosted or managed
|
|
19
|
+
service, where the service provides users with access to any substantial set of
|
|
20
|
+
the features or functionality of the software.
|
|
21
|
+
|
|
22
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
23
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
24
|
+
software that is protected by the license key.
|
|
25
|
+
|
|
26
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
27
|
+
of the licensor in the software. Any use of the licensor’s trademarks is subject
|
|
28
|
+
to applicable law.
|
|
29
|
+
|
|
30
|
+
## Patents
|
|
31
|
+
|
|
32
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
33
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
34
|
+
sale, import and have imported the software, in each case subject to the
|
|
35
|
+
limitations and conditions in this license. This license does not cover any
|
|
36
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
37
|
+
the software. If you or your company make any written claim that the software
|
|
38
|
+
infringes or contributes to infringement of any patent, your patent license for
|
|
39
|
+
the software granted under these terms ends immediately. If your company makes
|
|
40
|
+
such a claim, your patent license ends immediately for work on behalf of your
|
|
41
|
+
company.
|
|
42
|
+
|
|
43
|
+
## Notices
|
|
44
|
+
|
|
45
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
46
|
+
also gets a copy of these terms.
|
|
47
|
+
|
|
48
|
+
If you modify the software, you must include in any modified copies of the
|
|
49
|
+
software prominent notices stating that you have modified the software.
|
|
50
|
+
|
|
51
|
+
## No Other Rights
|
|
52
|
+
|
|
53
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
54
|
+
these terms.
|
|
55
|
+
|
|
56
|
+
## Termination
|
|
57
|
+
|
|
58
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
59
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
60
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
61
|
+
later than 30 days after you receive that notice, your licenses will be
|
|
62
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
63
|
+
reinstatement, any additional violation of these terms will cause your licenses
|
|
64
|
+
to terminate automatically and permanently.
|
|
65
|
+
|
|
66
|
+
## No Liability
|
|
67
|
+
|
|
68
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
69
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
70
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
71
|
+
legal claim.*
|
|
72
|
+
|
|
73
|
+
## Definitions
|
|
74
|
+
|
|
75
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
|
76
|
+
software the licensor makes available under these terms, including any portion
|
|
77
|
+
of it.
|
|
78
|
+
|
|
79
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
80
|
+
|
|
81
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
82
|
+
organization that you work for, plus all organizations that have control over,
|
|
83
|
+
are under the control of, or are under common control with that
|
|
84
|
+
organization. **control** means ownership of substantially all the assets of an
|
|
85
|
+
entity, or the power to direct its management and policies by vote, contract, or
|
|
86
|
+
otherwise. Control can be direct or indirect.
|
|
87
|
+
|
|
88
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
89
|
+
these terms.
|
|
90
|
+
|
|
91
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
92
|
+
|
|
93
|
+
**trademark** means trademarks, service marks, and similar rights.
|
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @aigne/agent-library
|
|
2
|
+
|
|
3
|
+
[](https://star-history.com/#AIGNE-io/aigne-framework)
|
|
4
|
+
[](https://github.com/AIGNE-io/aigne-framework/issues)
|
|
5
|
+
[](https://codecov.io/gh/AIGNE-io/aigne-framework)
|
|
6
|
+
[](https://www.npmjs.com/package/@aigne/agent-library)
|
|
7
|
+
[](https://github.com/AIGNE-io/aigne-framework/blob/main/LICENSE)
|
|
8
|
+
|
|
9
|
+
**English** | [中文](README.zh.md)
|
|
10
|
+
|
|
11
|
+
Collection of agent libraries for [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework), providing pre-built agent implementations.
|
|
12
|
+
|
|
13
|
+
## Introduction
|
|
14
|
+
|
|
15
|
+
`@aigne/agent-library` is a collection of agent libraries for [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework), providing pre-built agent implementations for developers. The library is built on top of [@aigne/core](https://github.com/AIGNE-io/aigne-framework/tree/main/packages/core), extending the core functionality to simplify complex workflow orchestration.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Orchestrator Agent**: Provides OrchestratorAgent implementation for coordinating workflows between multiple agents
|
|
20
|
+
- **Task Concurrency**: Supports parallel execution of multiple tasks to improve processing efficiency
|
|
21
|
+
- **Planning & Execution**: Automatically generates execution plans and executes them step by step
|
|
22
|
+
- **Result Synthesis**: Intelligently synthesizes results from multiple steps and tasks
|
|
23
|
+
- **TypeScript Support**: Complete type definitions providing an excellent development experience
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Using npm
|
|
29
|
+
npm install @aigne/agent-library @aigne/core
|
|
30
|
+
|
|
31
|
+
# Using yarn
|
|
32
|
+
yarn add @aigne/agent-library @aigne/core
|
|
33
|
+
|
|
34
|
+
# Using pnpm
|
|
35
|
+
pnpm add @aigne/agent-library @aigne/core
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Basic Usage
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { ExecutionEngine } from "@aigne/core";
|
|
42
|
+
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
43
|
+
import { OrchestratorAgent } from "@aigne/agent-library/orchestrator";
|
|
44
|
+
|
|
45
|
+
// Create AI model instance
|
|
46
|
+
const model = new OpenAIChatModel({
|
|
47
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
48
|
+
model: "gpt-4-turbo",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Create execution engine
|
|
52
|
+
const engine = new ExecutionEngine({ model });
|
|
53
|
+
|
|
54
|
+
// Create orchestrator agent
|
|
55
|
+
const orchestrator = new OrchestratorAgent({
|
|
56
|
+
name: "MainOrchestrator",
|
|
57
|
+
instructions: "You are a task orchestrator responsible for coordinating multiple specialized agents to complete complex tasks.",
|
|
58
|
+
// Configure sub-agents and tools...
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Execute orchestration task
|
|
62
|
+
const userAgent = await engine.call(orchestrator);
|
|
63
|
+
const result = await userAgent.call("Analyze this article and generate a summary and keywords");
|
|
64
|
+
console.log(result);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Provided Agent Types
|
|
68
|
+
|
|
69
|
+
The library currently provides one specialized agent implementation:
|
|
70
|
+
|
|
71
|
+
- **Orchestrator Agent (OrchestratorAgent)**: Responsible for coordinating work between multiple agents and managing complex workflows. It can automatically plan task steps, distribute and execute tasks across multiple agents, and finally synthesize the results.
|
|
72
|
+
|
|
73
|
+
## Advanced Usage
|
|
74
|
+
|
|
75
|
+
### Creating an Orchestration Workflow
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { AIAgent, ExecutionEngine } from "@aigne/core";
|
|
79
|
+
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
80
|
+
import { OrchestratorAgent } from "@aigne/agent-library/orchestrator";
|
|
81
|
+
|
|
82
|
+
const model = new OpenAIChatModel({
|
|
83
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
84
|
+
model: "gpt-4-turbo",
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Create specialized sub-agents
|
|
88
|
+
const researchAgent = AIAgent.from({
|
|
89
|
+
name: "Researcher",
|
|
90
|
+
instructions: "You are a professional researcher responsible for collecting and analyzing information.",
|
|
91
|
+
outputKey: "research",
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const writerAgent = AIAgent.from({
|
|
95
|
+
name: "Writer",
|
|
96
|
+
instructions: "You are a professional writer responsible for creating high-quality content.",
|
|
97
|
+
outputKey: "content",
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const editorAgent = AIAgent.from({
|
|
101
|
+
name: "Editor",
|
|
102
|
+
instructions: "You are a strict editor responsible for checking content quality and formatting.",
|
|
103
|
+
outputKey: "edited",
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Create orchestrator agent
|
|
107
|
+
const orchestrator = new OrchestratorAgent({
|
|
108
|
+
name: "WorkflowOrchestrator",
|
|
109
|
+
instructions: "You are responsible for coordinating research, writing, and editing processes.",
|
|
110
|
+
tools: [researchAgent, writerAgent, editorAgent],
|
|
111
|
+
// Optional configuration
|
|
112
|
+
maxIterations: 30, // Maximum number of iterations
|
|
113
|
+
tasksConcurrency: 5, // Task concurrency
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Use the orchestrator agent
|
|
117
|
+
const engine = new ExecutionEngine({ model });
|
|
118
|
+
const userAgent = await engine.call(orchestrator);
|
|
119
|
+
const result = await userAgent.call("Applications of artificial intelligence in healthcare");
|
|
120
|
+
console.log(result);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Documentation
|
|
124
|
+
|
|
125
|
+
For more detailed API documentation and usage guides, please refer to:
|
|
126
|
+
|
|
127
|
+
- [Agent Development Guide](../../docs/agent-development.md)
|
|
128
|
+
- [Agent API](../../docs/apis/agent-api.md)
|
|
129
|
+
- [AI Agent API](../../docs/apis/ai-agent-api.md)
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
Elastic-2.0
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @aigne/agent-library
|
|
2
|
+
|
|
3
|
+
[](https://star-history.com/#AIGNE-io/aigne-framework)
|
|
4
|
+
[](https://github.com/AIGNE-io/aigne-framework/issues)
|
|
5
|
+
[](https://codecov.io/gh/AIGNE-io/aigne-framework)
|
|
6
|
+
[](https://www.npmjs.com/package/@aigne/agent-library)
|
|
7
|
+
[](https://github.com/AIGNE-io/aigne-framework/blob/main/LICENSE)
|
|
8
|
+
|
|
9
|
+
[English](README.md) | **中文**
|
|
10
|
+
|
|
11
|
+
[AIGNE 框架](https://github.com/AIGNE-io/aigne-framework)的代理库集合,提供预构建的代理实现。
|
|
12
|
+
|
|
13
|
+
## 简介
|
|
14
|
+
|
|
15
|
+
`@aigne/agent-library` 是 [AIGNE 框架](https://github.com/AIGNE-io/aigne-framework)的代理库集合,为开发者提供预构建的代理实现。该库是基于 [@aigne/core](https://github.com/AIGNE-io/aigne-framework/tree/main/packages/core) 构建的,扩展了核心功能,使复杂工作流的编排更加简便。
|
|
16
|
+
|
|
17
|
+
## 特性
|
|
18
|
+
|
|
19
|
+
- **编排代理**:提供 OrchestratorAgent 实现,用于协调多个代理之间的工作流
|
|
20
|
+
- **任务并发**:支持并行执行多个任务,提高处理效率
|
|
21
|
+
- **计划与执行**:自动生成执行计划并逐步执行
|
|
22
|
+
- **结果合成**:智能合成多个步骤和任务的结果
|
|
23
|
+
- **TypeScript 支持**:完整的类型定义,提供优秀的开发体验
|
|
24
|
+
|
|
25
|
+
## 安装
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# 使用 npm
|
|
29
|
+
npm install @aigne/agent-library @aigne/core
|
|
30
|
+
|
|
31
|
+
# 使用 yarn
|
|
32
|
+
yarn add @aigne/agent-library @aigne/core
|
|
33
|
+
|
|
34
|
+
# 使用 pnpm
|
|
35
|
+
pnpm add @aigne/agent-library @aigne/core
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 基本用法
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { ExecutionEngine } from "@aigne/core";
|
|
42
|
+
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
43
|
+
import { OrchestratorAgent } from "@aigne/agent-library/orchestrator";
|
|
44
|
+
|
|
45
|
+
// 创建 AI 模型实例
|
|
46
|
+
const model = new OpenAIChatModel({
|
|
47
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
48
|
+
model: "gpt-4-turbo",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// 创建执行引擎
|
|
52
|
+
const engine = new ExecutionEngine({ model });
|
|
53
|
+
|
|
54
|
+
// 创建编排代理
|
|
55
|
+
const orchestrator = new OrchestratorAgent({
|
|
56
|
+
name: "主编排器",
|
|
57
|
+
instructions: "你是一个任务编排器,负责协调多个专业代理完成复杂任务。",
|
|
58
|
+
// 配置子代理和工具...
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// 执行编排任务
|
|
62
|
+
const userAgent = await engine.call(orchestrator);
|
|
63
|
+
const result = await userAgent.call("分析这篇文章并生成摘要和关键词");
|
|
64
|
+
console.log(result);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 提供的代理类型
|
|
68
|
+
|
|
69
|
+
该库目前提供了一种专业化的代理实现:
|
|
70
|
+
|
|
71
|
+
- **编排代理(OrchestratorAgent)**:负责协调多个代理之间的工作,管理复杂工作流。它能够自动规划任务步骤,并在多个代理之间分配和执行任务,最后合成结果。
|
|
72
|
+
|
|
73
|
+
## 高级用法
|
|
74
|
+
|
|
75
|
+
### 创建编排工作流
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { AIAgent, ExecutionEngine } from "@aigne/core";
|
|
79
|
+
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
80
|
+
import { OrchestratorAgent } from "@aigne/agent-library/orchestrator";
|
|
81
|
+
|
|
82
|
+
const model = new OpenAIChatModel({
|
|
83
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
84
|
+
model: "gpt-4-turbo",
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// 创建专业子代理
|
|
88
|
+
const researchAgent = AIAgent.from({
|
|
89
|
+
name: "研究员",
|
|
90
|
+
instructions: "你是一位专业研究员,负责收集和分析信息。",
|
|
91
|
+
outputKey: "research",
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const writerAgent = AIAgent.from({
|
|
95
|
+
name: "作家",
|
|
96
|
+
instructions: "你是一位专业作家,负责创作高质量内容。",
|
|
97
|
+
outputKey: "content",
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const editorAgent = AIAgent.from({
|
|
101
|
+
name: "编辑",
|
|
102
|
+
instructions: "你是一位严格的编辑,负责检查内容质量和格式。",
|
|
103
|
+
outputKey: "edited",
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// 创建编排代理
|
|
107
|
+
const orchestrator = new OrchestratorAgent({
|
|
108
|
+
name: "工作流编排器",
|
|
109
|
+
instructions: "你负责协调研究、写作和编辑流程。",
|
|
110
|
+
tools: [researchAgent, writerAgent, editorAgent],
|
|
111
|
+
// 可选配置
|
|
112
|
+
maxIterations: 30, // 最大迭代次数
|
|
113
|
+
tasksConcurrency: 5, // 任务并发数
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// 使用编排代理
|
|
117
|
+
const engine = new ExecutionEngine({ model });
|
|
118
|
+
const userAgent = await engine.call(orchestrator);
|
|
119
|
+
const result = await userAgent.call("关于人工智能在医疗领域的应用");
|
|
120
|
+
console.log(result);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 文档
|
|
124
|
+
|
|
125
|
+
更多详细的 API 文档和使用指南,请参考:
|
|
126
|
+
|
|
127
|
+
- [代理开发指南](../../docs/agent-development.zh.md)
|
|
128
|
+
- [Agent API](../../docs/apis/agent-api.zh.md)
|
|
129
|
+
- [AI Agent API](../../docs/apis/ai-agent-api.zh.md)
|
|
130
|
+
|
|
131
|
+
## 协议
|
|
132
|
+
|
|
133
|
+
Elastic-2.0
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/agent-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Collection of agent libraries for AIGNE framework",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
9
9
|
"homepage": "https://github.com/AIGNE-io/aigne-framework/tree/main/packages/agent-library",
|
|
10
|
-
"license": "
|
|
10
|
+
"license": "Elastic-2.0",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "git+https://github.com/AIGNE-io/aigne-framework"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"fastq": "^1.19.1",
|
|
43
43
|
"zod": "^3.24.2",
|
|
44
|
-
"@aigne/core": "^1.
|
|
44
|
+
"@aigne/core": "^1.11.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/bun": "^1.2.9",
|