praisonai 1.0.2 → 1.0.3
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 +104 -27
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,20 +26,118 @@ npm install
|
|
|
26
26
|
npm run build
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Here are examples of different ways to use PraisonAI:
|
|
32
|
+
|
|
33
|
+
### 1. Single Agent Example
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { SimpleAgent, OpenAIService } from 'praisonai';
|
|
37
|
+
|
|
38
|
+
async function main() {
|
|
39
|
+
// Initialize a single agent with OpenAI
|
|
40
|
+
const llm = new OpenAIService({
|
|
41
|
+
apiKey: process.env.OPENAI_API_KEY
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const agent = new SimpleAgent({
|
|
45
|
+
llm,
|
|
46
|
+
name: 'ResearchAssistant',
|
|
47
|
+
description: 'An AI assistant that helps with research tasks'
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Execute a task
|
|
51
|
+
const response = await agent.execute('Summarize the key concepts of quantum computing');
|
|
52
|
+
console.log('Agent Response:', response);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
main();
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 2. Multi-Agent Example
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { SimpleAgent, OpenAIService, MultiAgentSystem } from 'praisonai';
|
|
62
|
+
|
|
63
|
+
async function main() {
|
|
64
|
+
const llm = new OpenAIService({
|
|
65
|
+
apiKey: process.env.OPENAI_API_KEY
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Create multiple agents
|
|
69
|
+
const researcher = new SimpleAgent({
|
|
70
|
+
llm,
|
|
71
|
+
name: 'Researcher',
|
|
72
|
+
description: 'Researches and gathers information'
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const writer = new SimpleAgent({
|
|
76
|
+
llm,
|
|
77
|
+
name: 'Writer',
|
|
78
|
+
description: 'Writes and formats content'
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Create multi-agent system
|
|
82
|
+
const system = new MultiAgentSystem([researcher, writer]);
|
|
83
|
+
|
|
84
|
+
// Execute collaborative task
|
|
85
|
+
const result = await system.execute('Research and write a summary about AI agents');
|
|
86
|
+
console.log('Multi-Agent Result:', result);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
main();
|
|
90
|
+
```
|
|
30
91
|
|
|
31
|
-
|
|
92
|
+
### 3. Task-Based Agent Example
|
|
32
93
|
|
|
33
|
-
|
|
94
|
+
```typescript
|
|
95
|
+
import { SimpleAgent, OpenAIService, Task, ArxivSearchTool } from 'praisonai';
|
|
96
|
+
|
|
97
|
+
async function main() {
|
|
98
|
+
const llm = new OpenAIService({
|
|
99
|
+
apiKey: process.env.OPENAI_API_KEY
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Create agent with tools
|
|
103
|
+
const agent = new SimpleAgent({
|
|
104
|
+
llm,
|
|
105
|
+
name: 'ResearchAgent',
|
|
106
|
+
tools: [new ArxivSearchTool()]
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Create and execute a task
|
|
110
|
+
const task = new Task({
|
|
111
|
+
objective: 'Find recent quantum computing papers',
|
|
112
|
+
steps: [
|
|
113
|
+
'Search for quantum computing papers',
|
|
114
|
+
'Summarize the findings'
|
|
115
|
+
]
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const result = await agent.executeTask(task);
|
|
119
|
+
console.log('Task Result:', result);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
main();
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Running the Examples
|
|
126
|
+
|
|
127
|
+
1. First, set up your environment variables:
|
|
34
128
|
```bash
|
|
35
|
-
|
|
129
|
+
export OPENAI_API_KEY='your-api-key'
|
|
36
130
|
```
|
|
37
131
|
|
|
38
|
-
2.
|
|
132
|
+
2. Create a new TypeScript file (e.g., `example.ts`) with any of the above examples.
|
|
133
|
+
|
|
134
|
+
3. Run the example:
|
|
39
135
|
```bash
|
|
40
|
-
npx ts-node
|
|
136
|
+
npx ts-node example.ts
|
|
41
137
|
```
|
|
42
138
|
|
|
139
|
+
For more examples, check out the `examples/concepts/` directory in the repository.
|
|
140
|
+
|
|
43
141
|
## Package Structure
|
|
44
142
|
|
|
45
143
|
```
|
|
@@ -56,27 +154,6 @@ src/
|
|
|
56
154
|
└── ... (other tools)
|
|
57
155
|
```
|
|
58
156
|
|
|
59
|
-
## Usage
|
|
60
|
-
|
|
61
|
-
Here's a simple example of using the ArxivSearchTool:
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
import { ArxivSearchTool } from 'praisonai';
|
|
65
|
-
|
|
66
|
-
async function main() {
|
|
67
|
-
const searchTool = new ArxivSearchTool();
|
|
68
|
-
const papers = await searchTool.execute('quantum computing', 5);
|
|
69
|
-
|
|
70
|
-
papers.forEach(paper => {
|
|
71
|
-
console.log(`Title: ${paper.title}`);
|
|
72
|
-
console.log(`Authors: ${paper.authors.join(', ')}`);
|
|
73
|
-
console.log('---');
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
main();
|
|
78
|
-
```
|
|
79
|
-
|
|
80
157
|
## Contributing
|
|
81
158
|
|
|
82
159
|
1. Fork the repository
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "praisonai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "PraisonAI TypeScript AI Agents Framework - Node.js, npm, and Javascript AI Agents Framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"dotenv": "^16.4.1",
|
|
61
61
|
"fast-xml-parser": "^4.3.4",
|
|
62
62
|
"openai": "^4.24.7",
|
|
63
|
-
"praisonai": "^1.0.
|
|
63
|
+
"praisonai": "^1.0.2"
|
|
64
64
|
},
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": ">=14.0.0"
|