JavaScript AI Agents Framework
A production-ready Multi AI Agents framework for JavaScript
PraisonAI is a production-ready Multi AI Agents framework for JavaScript, 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.
JavaScript
Quick Start
- Simple Usage
npm npm install praisonaiyarn yarn add praisonai - With Configuration
bash export OPENAI_API_KEY=xxxxxxxxxxxxxxxxxxxxxx - Create File
Create
app.jsfile## Code Example
Single Agent const { Agent } = require('praisonai'); const agent = new Agent({ instructions: 'You are a helpful AI assistant' }); agent.start('Write a movie script about a robot in Mars');Multi Agents const { Agent, Agents } = require('praisonai'); const researchAgent = new Agent({ instructions: 'Research about AI' }); const summariseAgent = new Agent({ instructions: 'Summarise research agent\'s findings' }); const agents = new AgentTeam({ agents: [researchAgent, summariseAgent] }); agents.start(); - Run Script
bash node app.js
Usage Examples
Single Agent Example
Create and run a single agent to perform a specific task:
const { Agent } = require('praisonai');
// Create a simple science explainer agent
const agent = new Agent({
instructions: "You are a science expert who explains complex phenomena in simple terms.",
name: "ScienceExplainer",
verbose: true
});
// Ask a question
agent.start("Why is the sky blue?")
.then(response => {
console.log('\nExplanation:');
console.log(response);
})
.catch(error => console.error('Error:', error));Multi-Agent Example
Create and run multiple agents working together:
const { Agents, Agent } = require('praisonai');
// Create a story agent and a summary agent
const storyAgent = new Agent({
instructions: "You are a creative storyteller. Create engaging stories.",
name: "Storyteller"
});
const summaryAgent = new Agent({
instructions: "You summarize stories into brief, engaging summaries.",
name: "Summarizer"
});
// Create multi-agent system
const agents = new AgentTeam({
agents: [storyAgent, summaryAgent],
tasks: [
"Create a short story about a magical forest",
"Summarize the story in 2 sentences"
]
});
// Run the agents
agents.start()
.then(responses => {
console.log('\nStory:');
console.log(responses[0]);
console.log('\nSummary:');
console.log(responses[1]);
})
.catch(error => console.error('Error:', error));Task-Based Agent Example
Create agents with specific tasks and dependencies:
const { Agent } = require('praisonai');
// Create a task-based agent
const agent = new Agent({
name: "TaskMaster",
role: "Assistant",
goal: "Complete tasks efficiently",
instructions: "You are an AI assistant that helps complete tasks step by step."
});
// A task is a plain object — agent.execute reads its description
const mainTask = {
name: "Write Blog Post",
description: "Write a blog post about artificial intelligence",
expectedOutput: "A complete blog post"
};
// Execute the task
agent.execute(mainTask)
.then(response => {
console.log('\nBlog Post:');
console.log(response);
})
.catch(error => console.error('Error:', error));Running the Examples
- Set Environment Variables
bash export OPENAI_API_KEY='your-api-key' - Create Example File
Create a new JavaScript file (e.g.,
app.js) with any of the above examples. - Run the Example
bash node app.js