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.

Diagram

📋 Task

🤖 AI Agent

🔧 Tools

📋 Task

🤖 AI Agent

🔧 Tools

â–¶ Start

âš™ Process

✓ Output

JavaScript

Quick Start

  1. Simple Usage
    npm
    npm install praisonai
    yarn
    yarn add praisonai
  2. With Configuration
    bash
    export OPENAI_API_KEY=xxxxxxxxxxxxxxxxxxxxxx
  3. Create File

    Create app.js file

    ## 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();
  4. Run Script
    bash
    node app.js

Usage Examples

Single Agent Example

Create and run a single agent to perform a specific task:

javascript
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:

javascript
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:

javascript
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

  1. Set Environment Variables
    bash
    export OPENAI_API_KEY='your-api-key'
  2. Create Example File

    Create a new JavaScript file (e.g., app.js) with any of the above examples.

  3. Run the Example
    bash
    node app.js

Related