Skip to content

Commit 25cbab3

Browse files
Merge pull request #348 from MervinPraison/develop
Add Node.js AI Agents Framework Documentation
2 parents 239e40f + 16ea183 commit 25cbab3

File tree

8 files changed

+245
-222
lines changed

8 files changed

+245
-222
lines changed

docs/js/js.mdx

+235
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
---
2+
title: "Node.js AI Agents Framework"
3+
sidebarTitle: "Node.js"
4+
description: "A production-ready Multi AI Agents framework for TypeScript and Node.js"
5+
icon: "js"
6+
---
7+
8+
PraisonAI is a production-ready Multi AI Agents framework, designed to create AI Agents to automate and solve problems ranging from simple tasks to complex challenges. It provides a low-code solution to streamline the building and management of multi-agent LLM systems, emphasising simplicity, customisation, and effective human-agent collaboration.
9+
10+
## Installation
11+
12+
<CodeGroup>
13+
```bash npm
14+
npm install praisonai
15+
```
16+
17+
```bash yarn
18+
yarn add praisonai
19+
```
20+
</CodeGroup>
21+
22+
## Usage Examples
23+
24+
<AccordionGroup>
25+
<Accordion title="Single Agent Example" icon="user" defaultOpen>
26+
Create and run a single agent to perform a specific task:
27+
28+
```typescript
29+
import { Agent, PraisonAIAgents } from 'praisonai';
30+
31+
async function main() {
32+
// Create a simple agent (no task specified)
33+
const agent = new Agent({
34+
name: "BiologyExpert",
35+
instructions: "Explain the process of photosynthesis in detail.",
36+
verbose: true
37+
});
38+
39+
// Run the agent
40+
const praisonAI = new PraisonAIAgents({
41+
agents: [agent],
42+
tasks: ["Explain the process of photosynthesis in detail."],
43+
verbose: true
44+
});
45+
46+
try {
47+
console.log('Starting single agent example...');
48+
const results = await praisonAI.start();
49+
console.log('\nFinal Results:', results);
50+
} catch (error) {
51+
console.error('Error:', error);
52+
}
53+
}
54+
55+
main();
56+
```
57+
</Accordion>
58+
59+
<Accordion title="Multi-Agent Example" icon="users" defaultOpen>
60+
Create and run multiple agents working together:
61+
62+
```typescript
63+
import { Agent, PraisonAIAgents } from 'praisonai';
64+
65+
async function main() {
66+
// Create multiple agents with different roles
67+
const researchAgent = new Agent({
68+
name: "ResearchAgent",
69+
instructions: "Research and provide detailed information about renewable energy sources.",
70+
verbose: true
71+
});
72+
73+
const summaryAgent = new Agent({
74+
name: "SummaryAgent",
75+
instructions: "Create a concise summary of the research findings about renewable energy sources. Use {previous_result} as input.",
76+
verbose: true
77+
});
78+
79+
const recommendationAgent = new Agent({
80+
name: "RecommendationAgent",
81+
instructions: "Based on the summary in {previous_result}, provide specific recommendations for implementing renewable energy solutions.",
82+
verbose: true
83+
});
84+
85+
// Run the agents in sequence
86+
const praisonAI = new PraisonAIAgents({
87+
agents: [researchAgent, summaryAgent, recommendationAgent],
88+
tasks: [
89+
"Research and analyze current renewable energy technologies and their implementation.",
90+
"Summarize the key findings from the research.",
91+
"Provide actionable recommendations based on the summary."
92+
],
93+
verbose: true
94+
});
95+
96+
try {
97+
console.log('Starting multi-agent example...');
98+
const results = await praisonAI.start();
99+
console.log('\nFinal Results:', results);
100+
} catch (error) {
101+
console.error('Error:', error);
102+
}
103+
}
104+
105+
main();
106+
```
107+
</Accordion>
108+
109+
<Accordion title="Task-Based Agent Example" icon="list-check" defaultOpen>
110+
Create agents with specific tasks and dependencies:
111+
112+
```typescript
113+
import { Agent, Task, PraisonAIAgents } from 'praisonai';
114+
115+
async function main() {
116+
// Create agents first
117+
const dietAgent = new Agent({
118+
name: "DietAgent",
119+
role: "Nutrition Expert",
120+
goal: "Create healthy and delicious recipes",
121+
backstory: "You are a certified nutritionist with years of experience in creating balanced meal plans.",
122+
verbose: true,
123+
instructions: `You are a professional chef and nutritionist. Create 5 healthy food recipes that are both nutritious and delicious.
124+
Each recipe should include:
125+
1. Recipe name
126+
2. List of ingredients with quantities
127+
3. Step-by-step cooking instructions
128+
4. Nutritional information
129+
5. Health benefits
130+
131+
Format your response in markdown.`
132+
});
133+
134+
const blogAgent = new Agent({
135+
name: "BlogAgent",
136+
role: "Food Blogger",
137+
goal: "Write engaging blog posts about food and recipes",
138+
backstory: "You are a successful food blogger known for your ability to make recipes sound delicious and approachable.",
139+
verbose: true,
140+
instructions: `You are a food and health blogger. Write an engaging blog post about the provided recipes.
141+
The blog post should:
142+
1. Have an engaging title
143+
2. Include an introduction about healthy eating`
144+
});
145+
146+
// Create tasks
147+
const createRecipesTask = new Task({
148+
name: "Create Recipes",
149+
description: "Create 5 healthy and delicious recipes",
150+
agent: dietAgent
151+
});
152+
153+
const writeBlogTask = new Task({
154+
name: "Write Blog",
155+
description: "Write a blog post about the recipes",
156+
agent: blogAgent,
157+
dependencies: [createRecipesTask] // This task depends on the recipes being created first
158+
});
159+
160+
// Run the tasks
161+
const praisonAI = new PraisonAIAgents({
162+
tasks: [createRecipesTask, writeBlogTask],
163+
verbose: true
164+
});
165+
166+
try {
167+
console.log('Starting task-based example...');
168+
const results = await praisonAI.start();
169+
console.log('\nFinal Results:', results);
170+
} catch (error) {
171+
console.error('Error:', error);
172+
}
173+
}
174+
175+
main();
176+
```
177+
</Accordion>
178+
</AccordionGroup>
179+
180+
## Running the Examples
181+
182+
<Steps>
183+
<Step title="Set Environment Variables">
184+
```bash
185+
export OPENAI_API_KEY='your-api-key'
186+
```
187+
</Step>
188+
189+
<Step title="Create Example File">
190+
Create a new TypeScript file (e.g., `example.ts`) with any of the above examples.
191+
</Step>
192+
193+
<Step title="Run the Example">
194+
```bash
195+
npx ts-node example.ts
196+
```
197+
</Step>
198+
</Steps>
199+
200+
<Note>
201+
For more examples, check out the `examples/concepts/` directory in the repository.
202+
</Note>
203+
204+
## Development Setup
205+
206+
<Steps>
207+
<Step title="Clone Repository">
208+
```bash
209+
git clone https://github.com/MervinPraison/PraisonAI.git
210+
cd src/praisonai-ts
211+
```
212+
</Step>
213+
214+
<Step title="Install Dependencies">
215+
```bash
216+
npm install
217+
```
218+
</Step>
219+
220+
<Step title="Build Package">
221+
```bash
222+
npm run build
223+
```
224+
</Step>
225+
</Steps>
226+
227+
## Package Structure
228+
229+
```
230+
src/
231+
├── agent/ # Agent-related interfaces and implementations
232+
├── task/ # Task management and execution
233+
├── utils/ # Utility functions and helpers
234+
└── types/ # TypeScript type definitions
235+
```

docs/mint.json

+10
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
{
7575
"name": "Tools",
7676
"url": "/tools"
77+
},
78+
{
79+
"name": "JS",
80+
"url": "/js"
7781
}
7882
],
7983
"navigation": [
@@ -234,6 +238,12 @@
234238
"tools/googlecalendar"
235239
]
236240
},
241+
{
242+
"group": "js",
243+
"pages": [
244+
"js/js"
245+
]
246+
},
237247
{
238248
"group": "Other Features",
239249
"pages": [

src/praisonai-examples/README.md

-33
This file was deleted.

src/praisonai-examples/concepts/multi-agent.ts

-50
This file was deleted.

src/praisonai-examples/concepts/single-agent.ts

-30
This file was deleted.

0 commit comments

Comments
 (0)