praisonai 1.0.4 → 1.0.5
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 +103 -47
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,23 +33,30 @@ Here are examples of different ways to use PraisonAI:
|
|
|
33
33
|
### 1. Single Agent Example
|
|
34
34
|
|
|
35
35
|
```typescript
|
|
36
|
-
import {
|
|
36
|
+
import { Agent, PraisonAIAgents } from 'praisonai';
|
|
37
37
|
|
|
38
38
|
async function main() {
|
|
39
|
-
//
|
|
40
|
-
const
|
|
41
|
-
|
|
39
|
+
// Create a simple agent (no task specified)
|
|
40
|
+
const agent = new Agent({
|
|
41
|
+
name: "BiologyExpert",
|
|
42
|
+
instructions: "Explain the process of photosynthesis in detail.",
|
|
43
|
+
verbose: true
|
|
42
44
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
|
|
46
|
+
// Run the agent
|
|
47
|
+
const praisonAI = new PraisonAIAgents({
|
|
48
|
+
agents: [agent],
|
|
49
|
+
tasks: ["Explain the process of photosynthesis in detail."],
|
|
50
|
+
verbose: true
|
|
48
51
|
});
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
try {
|
|
54
|
+
console.log('Starting single agent example...');
|
|
55
|
+
const results = await praisonAI.start();
|
|
56
|
+
console.log('\nFinal Results:', results);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error('Error:', error);
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
main();
|
|
@@ -58,32 +65,46 @@ main();
|
|
|
58
65
|
### 2. Multi-Agent Example
|
|
59
66
|
|
|
60
67
|
```typescript
|
|
61
|
-
import {
|
|
68
|
+
import { Agent, PraisonAIAgents } from 'praisonai';
|
|
62
69
|
|
|
63
70
|
async function main() {
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
// Create multiple agents with different roles
|
|
72
|
+
const researchAgent = new Agent({
|
|
73
|
+
name: "ResearchAgent",
|
|
74
|
+
instructions: "Research and provide detailed information about renewable energy sources.",
|
|
75
|
+
verbose: true
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const summaryAgent = new Agent({
|
|
79
|
+
name: "SummaryAgent",
|
|
80
|
+
instructions: "Create a concise summary of the research findings about renewable energy sources. Use {previous_result} as input.",
|
|
81
|
+
verbose: true
|
|
66
82
|
});
|
|
67
83
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
description: 'Researches and gathers information'
|
|
84
|
+
const recommendationAgent = new Agent({
|
|
85
|
+
name: "RecommendationAgent",
|
|
86
|
+
instructions: "Based on the summary in {previous_result}, provide specific recommendations for implementing renewable energy solutions.",
|
|
87
|
+
verbose: true
|
|
73
88
|
});
|
|
74
89
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
// Run the agents in sequence
|
|
91
|
+
const praisonAI = new PraisonAIAgents({
|
|
92
|
+
agents: [researchAgent, summaryAgent, recommendationAgent],
|
|
93
|
+
tasks: [
|
|
94
|
+
"Research and analyze current renewable energy technologies and their implementation.",
|
|
95
|
+
"Summarize the key findings from the research.",
|
|
96
|
+
"Provide actionable recommendations based on the summary."
|
|
97
|
+
],
|
|
98
|
+
verbose: true
|
|
79
99
|
});
|
|
80
100
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
101
|
+
try {
|
|
102
|
+
console.log('Starting multi-agent example...');
|
|
103
|
+
const results = await praisonAI.start();
|
|
104
|
+
console.log('\nFinal Results:', results);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
console.error('Error:', error);
|
|
107
|
+
}
|
|
87
108
|
}
|
|
88
109
|
|
|
89
110
|
main();
|
|
@@ -92,31 +113,66 @@ main();
|
|
|
92
113
|
### 3. Task-Based Agent Example
|
|
93
114
|
|
|
94
115
|
```typescript
|
|
95
|
-
import {
|
|
116
|
+
import { Agent, Task, PraisonAIAgents } from 'praisonai';
|
|
96
117
|
|
|
97
118
|
async function main() {
|
|
98
|
-
|
|
99
|
-
|
|
119
|
+
// Create agents first
|
|
120
|
+
const dietAgent = new Agent({
|
|
121
|
+
name: "DietAgent",
|
|
122
|
+
role: "Nutrition Expert",
|
|
123
|
+
goal: "Create healthy and delicious recipes",
|
|
124
|
+
backstory: "You are a certified nutritionist with years of experience in creating balanced meal plans.",
|
|
125
|
+
verbose: true, // Enable streaming output
|
|
126
|
+
instructions: `You are a professional chef and nutritionist. Create 5 healthy food recipes that are both nutritious and delicious.
|
|
127
|
+
Each recipe should include:
|
|
128
|
+
1. Recipe name
|
|
129
|
+
2. List of ingredients with quantities
|
|
130
|
+
3. Step-by-step cooking instructions
|
|
131
|
+
4. Nutritional information
|
|
132
|
+
5. Health benefits
|
|
133
|
+
|
|
134
|
+
Format your response in markdown.`
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const blogAgent = new Agent({
|
|
138
|
+
name: "BlogAgent",
|
|
139
|
+
role: "Food Blogger",
|
|
140
|
+
goal: "Write engaging blog posts about food and recipes",
|
|
141
|
+
backstory: "You are a successful food blogger known for your ability to make recipes sound delicious and approachable.",
|
|
142
|
+
verbose: true, // Enable streaming output
|
|
143
|
+
instructions: `You are a food and health blogger. Write an engaging blog post about the provided recipes.
|
|
144
|
+
The blog post should:
|
|
145
|
+
1. Have an engaging title
|
|
146
|
+
2. Include an introduction about healthy eating`
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Create tasks
|
|
150
|
+
const createRecipesTask = new Task({
|
|
151
|
+
name: "Create Recipes",
|
|
152
|
+
description: "Create 5 healthy and delicious recipes",
|
|
153
|
+
agent: dietAgent
|
|
100
154
|
});
|
|
101
155
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
156
|
+
const writeBlogTask = new Task({
|
|
157
|
+
name: "Write Blog",
|
|
158
|
+
description: "Write a blog post about the recipes",
|
|
159
|
+
agent: blogAgent,
|
|
160
|
+
dependencies: [createRecipesTask] // This task depends on the recipes being created first
|
|
107
161
|
});
|
|
108
162
|
|
|
109
|
-
//
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
'Search for quantum computing papers',
|
|
114
|
-
'Summarize the findings'
|
|
115
|
-
]
|
|
163
|
+
// Run the tasks
|
|
164
|
+
const praisonAI = new PraisonAIAgents({
|
|
165
|
+
tasks: [createRecipesTask, writeBlogTask],
|
|
166
|
+
verbose: true
|
|
116
167
|
});
|
|
117
168
|
|
|
118
|
-
|
|
119
|
-
|
|
169
|
+
try {
|
|
170
|
+
console.log('Starting task-based example...');
|
|
171
|
+
const results = await praisonAI.start();
|
|
172
|
+
console.log('\nFinal Results:', results);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.error('Error:', error);
|
|
175
|
+
}
|
|
120
176
|
}
|
|
121
177
|
|
|
122
178
|
main();
|