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.
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');
Create and run a single agent to perform a specific task:
Copy
const { Agent } = require('praisonai');// Create a simple science explainer agentconst agent = new Agent({ instructions: "You are a science expert who explains complex phenomena in simple terms.", name: "ScienceExplainer", verbose: true});// Ask a questionagent.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:
Copy
const { PraisonAIAgents, Agent } = require('praisonai');// Create a story agent and a summary agentconst 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 systemconst agents = new PraisonAIAgents({ agents: [storyAgent, summaryAgent], tasks: [ "Create a short story about a magical forest", "Summarize the story in 2 sentences" ]});// Run the agentsagents.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:
Copy
const { Agent, Task } = require('praisonai');// Create a task-based agentconst agent = new Agent({ name: "TaskMaster", role: "Assistant", goal: "Complete tasks efficiently", backstory: "You are an AI assistant that helps complete tasks step by step."});// Create a task with dependenciesconst mainTask = new Task({ name: "Write Blog Post", description: "Write a blog post about artificial intelligence", expected_output: "A complete blog post", dependencies: []});// Execute the taskagent.execute(mainTask) .then(response => { console.log('\nBlog Post:'); console.log(response); }) .catch(error => console.error('Error:', error));