A production-ready Multi AI Agents framework for Node.js
PraisonAI is a production-ready Multi AI Agents framework for Node.js, 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');
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
import { Agent } from 'praisonai';// Single agent example - Science Explainerconst agent = new Agent({ instructions: `You are a science expert who explains complex phenomena in simple terms.Provide clear, accurate, and easy-to-understand explanations.`, name: "ScienceExplainer", verbose: true});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:
Copy
import { Agent, PraisonAIAgents } from 'praisonai';// Create story agentconst storyAgent = new Agent({ instructions: "You are a storyteller. Write a very short story (2-3 sentences) about a given topic.", name: "StoryAgent", verbose: true});// Create summary agentconst summaryAgent = new Agent({ instructions: "You are an editor. Create a one-sentence summary of the given story.", name: "SummaryAgent", verbose: true});// Create and start agentsconst agents = new PraisonAIAgents({ agents: [storyAgent, summaryAgent], tasks: [ "Write a short story about a cat", "{previous_result}" // This will be replaced with the story ], verbose: true});agents.start() .then(results => { console.log('\nStory:', results[0]); console.log('\nSummary:', results[1]); }) .catch(error => console.error('Error:', error));
Task-Based Agent Example
Create agents with specific tasks and dependencies:
Copy
import { Agent, PraisonAIAgents } from 'praisonai';// Create recipe agentconst recipeAgent = new Agent({ instructions: `You are a professional chef and nutritionist. Create 5 healthy food recipes that are both nutritious and delicious.Each recipe should include:1. Recipe name2. List of ingredients with quantities3. Step-by-step cooking instructions4. Nutritional information5. Health benefitsFormat your response in markdown.`, name: "RecipeAgent", verbose: true});// Create blog agentconst blogAgent = new Agent({ instructions: `You are a food and health blogger. Write an engaging blog post about the provided recipes.The blog post should:1. Have an engaging title2. Include an introduction about healthy eating3. Discuss each recipe and its unique health benefits4. Include tips for meal planning and preparation5. End with a conclusion encouraging healthy eating habitsHere are the recipes to write about:{previous_result}Format your response in markdown.`, name: "BlogAgent", verbose: true});// Create PraisonAIAgents instance with tasksconst agents = new PraisonAIAgents({ agents: [recipeAgent, blogAgent], tasks: [ "Create 5 healthy and delicious recipes", "Write a blog post about the recipes" ], verbose: true});// Start the agentsagents.start() .then(results => { console.log('\nFinal Results:'); console.log('\nRecipe Task Results:'); console.log(results[0]); console.log('\nBlog Task Results:'); console.log(results[1]); }) .catch(error => { console.error('Error:', error); });