### Install PraisonAI Package (No-Code Setup) Source: https://docs.praison.ai/docs/features/langchain Installs the core `praisonai` package, which is used for the upcoming no-code configuration feature. ```bash pip install "praisonai" ``` -------------------------------- ### Install and Run PraisonAI Agents (Default) Source: https://docs.praison.ai/docs/nocode/tldr This snippet demonstrates how to install the core PraisonAI library, set your OpenAI API key, and then initialize and run a PraisonAI agent with a specific prompt. ```bash pip install praisonai export OPENAI_API_KEY="Enter your API key" praisonai --init "create a movie script about dog in moon" praisonai ``` -------------------------------- ### Install and Run PraisonAI User Interface (UI) Source: https://docs.praison.ai/docs/nocode/tldr This snippet provides instructions for installing PraisonAI with UI support, setting the OpenAI API key, generating a Chainlit authentication secret, and finally launching the PraisonAI user interface. ```bash pip install "praisonai[ui]" export OPENAI_API_KEY="Enter your API key" chainlit create-secret export CHAINLIT_AUTH_SECRET=xxxxxxxx praisonai ui ``` -------------------------------- ### Install and Run PraisonAI with AG2 (AutoGen) Framework Source: https://docs.praison.ai/docs/nocode/tldr This snippet details the process of installing PraisonAI with AG2 (AutoGen) support, setting up the OpenAI API key, and then initializing and running a PraisonAI project utilizing the AutoGen framework. ```bash pip install "praisonai[autogen]" export OPENAI_API_KEY="Enter your API key" praisonai --framework autogen --init "create a movie script about dog in moon" praisonai --framework autogen ``` -------------------------------- ### Install and Run PraisonAI with CrewAI Framework Source: https://docs.praison.ai/docs/nocode/tldr This snippet shows how to install PraisonAI with CrewAI support, configure your OpenAI API key, and then initialize and run a PraisonAI project specifically using the CrewAI framework. ```bash pip install "praisonai[crewai]" export OPENAI_API_KEY="Enter your API key" praisonai --framework crewai --init "create a movie script about dog in moon" praisonai --framework crewai ``` -------------------------------- ### Install PraisonAI Agents and Dependencies Source: https://docs.praison.ai/docs/features/langchain Installs the necessary Python packages for PraisonAI agents, including `langchain-community` and `wikipedia`, which are required for tool integration. ```bash pip install praisonaiagents langchain-community wikipedia ``` -------------------------------- ### JavaScript PraisonAI Agent Examples Source: https://docs.praison.ai/docs/index Illustrates how to instantiate and execute single and multiple PraisonAI agents using JavaScript, demonstrating common patterns for agent interaction. ```javascript 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'); ``` ```javascript const { Agent, PraisonAIAgents } = require('praisonai'); const researchAgent = new Agent({ instructions: 'Research about AI' }); const summariseAgent = new Agent({ instructions: 'Summarise research agent\'s findings' }); const agents = new PraisonAIAgents({ agents: [researchAgent, summariseAgent] }); agents.start(); ``` -------------------------------- ### Python PraisonAI Agent Examples Source: https://docs.praison.ai/docs/index Demonstrates how to initialize and run single and multiple PraisonAI agents in Python for various tasks, showcasing basic agent creation and multi-agent orchestration. ```python from praisonaiagents import Agent agent = Agent(instructions="Your are a helpful AI assistant") agent.start("Write a movie script about a robot in Mars") ``` ```python from praisonaiagents import Agent, PraisonAIAgents research_agent = Agent(instructions="Research about AI") summarise_agent = Agent(instructions="Summarise research agent's findings") agents = PraisonAIAgents(agents=[research_agent, summarise_agent]) agents.start() ``` -------------------------------- ### Run PraisonAI Agent Application Source: https://docs.praison.ai/docs/features/langchain Executes the Python script (`app.py`) containing the PraisonAI agent setup, initiating the defined workflow and agent operations. ```bash python app.py ``` -------------------------------- ### Quick Start: Configuring PraisonAI Async Agents with YAML Source: https://docs.praison.ai/docs/features/async This guide demonstrates how to set up PraisonAI Agents using a declarative YAML configuration, including package installation, API key setup, and running the agent from a YAML file. It defines roles and tasks directly in the YAML structure. ```bash pip install praisonai ``` ```bash export OPENAI_API_KEY=your_api_key_here ``` ```yaml framework: praisonai process: sequential topic: async operations roles: assistant: name: AsyncAgent role: Assistant goal: Help with tasks backstory: Expert in async operations tasks: hello_task: description: Say hello and introduce yourself expected_output: Answer to the question async_execution: true ``` ```bash praisonai agents.yaml ``` -------------------------------- ### TypeScript PraisonAI Agent Examples Source: https://docs.praison.ai/docs/index Shows how to define and run single and multiple PraisonAI agents in TypeScript, including agent naming and specific instructions for complex workflows. ```typescript import { Agent } from 'praisonai'; const agent = new Agent({ instructions: 'You are a creative writer who writes short stories with emojis.', name: "StoryWriter" }); agent.start("Write a story about a time traveler") ``` ```typescript import { Agent, PraisonAIAgents } from 'praisonai'; const storyAgent = new Agent({ instructions: "Generate a very short story (2-3 sentences) about artificial intelligence with emojis.", name: "StoryAgent" }); const summaryAgent = new Agent({ instructions: "Summarize the provided AI story in one sentence with emojis.", name: "SummaryAgent" }); const agents = new PraisonAIAgents({ agents: [storyAgent, summaryAgent] }); agents.start() ``` -------------------------------- ### Quick Start: Setting up PraisonAI Async Agents with Python Code Source: https://docs.praison.ai/docs/features/async This guide provides a step-by-step process to install the PraisonAI Agents package, configure your OpenAI API key, and run a basic asynchronous AI agent using Python code. It demonstrates creating an agent, defining a task, and executing it asynchronously. ```bash pip install praisonaiagents ``` ```bash export OPENAI_API_KEY=your_api_key_here ``` ```python import asyncio from praisonaiagents import Agent, Task, PraisonAIAgents # Create an agent agent = Agent( name="AsyncAgent", role="Assistant", goal="Help with tasks", backstory="Expert in async operations" ) # Create a task task = Task( name="hello_task", description="Say hello and introduce yourself", agent=agent, async_execution=True, expected_output="Answer to the question" ) # Create agents manager agents = PraisonAIAgents( agents=[agent], tasks=[task], process="sequential" ) # Main async function async def main(): result = await agents.astart() print(result) # Run the program if __name__ == "__main__": asyncio.run(main()) ``` ```bash python app.py ``` -------------------------------- ### Install PraisonAI Optional Features Source: https://docs.praison.ai/docs/nocode/installation This command block demonstrates how to install various optional features for PraisonAI. These include UI support, a chat interface, a code interface, realtime voice interaction, and call functionality, each installed as a separate extra. ```bash # UI support pip install "praisonai[ui]" # Chat interface pip install "praisonai[chat]" # Code interface pip install "praisonai[code]" # Realtime voice interaction pip install "praisonai[realtime]" # Call feature pip install "praisonai[call]" ``` -------------------------------- ### Install PraisonAI Core Library Source: https://docs.praison.ai/docs/nocode/installation This command installs the fundamental PraisonAI library. It provides the core functionalities without any specific framework integrations or additional features. ```bash pip install praisonai ``` -------------------------------- ### Basic PraisonAI Agent Setup for Python Code Execution Source: https://docs.praison.ai/docs/tools/python_tools Provides a complete example of setting up a `PraisonAI` agent named 'PythonExpert' with a specific role and goal, equipped with all Python tools. It defines a task for data processing and demonstrates how to initialize and start a sequential process with this agent, showcasing a fundamental agent configuration. ```python from praisonaiagents import Agent, Task, PraisonAIAgents from praisonaiagents.tools import ( execute_code, analyze_code, format_code, lint_code, disassemble_code ) # Create Python agent python_agent = Agent( name="PythonExpert", role="Code Execution Specialist", goal="Execute Python code efficiently and safely.", backstory="Expert in Python programming and execution.", tools=[ execute_code, analyze_code, format_code, lint_code, disassemble_code ], self_reflect=False ) # Define Python task python_task = Task( description="Execute data processing scripts.", expected_output="Processing results.", agent=python_agent, name="data_processing" ) # Run agent agents = PraisonAIAgents( agents=[python_agent], tasks=[python_task], process="sequential" ) agents.start() ``` -------------------------------- ### Start PraisonAI Agent and Get Response Source: https://docs.praison.ai/docs/course/agents/11-creating-your-first-agent This Python snippet demonstrates how to invoke the `start` method on an initialized agent instance, passing a specific query. The agent processes the query based on its defined instructions, and the generated response is then captured and printed to the console. ```python # Start the agent with a specific query response = research_assistant.start("Explain how solar panels work in simple terms") # Print the response print(response) ``` -------------------------------- ### Install PraisonAI Client Libraries Source: https://docs.praison.ai/docs/index Commands to install the PraisonAI library for different programming environments: `pip` for Python, `npm` for JavaScript/TypeScript, and `yarn` for TypeScript. ```bash pip install praisonaiagents ``` ```bash npm install praisonai ``` ```bash yarn add praisonai ``` -------------------------------- ### Install PraisonAI Code and Configure OpenAI API Key Source: https://docs.praison.ai/docs/ui/code This snippet provides the necessary commands to install PraisonAI Code and set up your OpenAI API key, which is required for the application to function. It covers the pip installation, environment variable setup, and the command to launch PraisonAI Code. ```bash pip install "praisonai[code]" ``` ```bash export OPENAI_API_KEY=xxxxxxxx ``` ```bash praisonai code ``` -------------------------------- ### Install PraisonAI Project Dependencies Source: https://docs.praison.ai/docs/js/development Installs all required Node.js package dependencies for the PraisonAI project using npm, preparing the environment for development or building. ```bash npm install ``` -------------------------------- ### Install PraisonAI and DuckDuckGo Search for YAML Setup Source: https://docs.praison.ai/docs/tools/tools Installs the core PraisonAI package and the DuckDuckGo search library, specifically for the 'No Code' setup using YAML configurations, via pip. ```bash pip install praisonai duckduckgo_search ``` -------------------------------- ### Install PraisonAI and DuckDuckGo Search (No Code Setup) Source: https://docs.praison.ai/docs/tools/tools Installs the `praisonai` and `duckduckgo_search` packages, providing the necessary libraries for a 'no-code' agent setup that relies on YAML configuration for agent and tool definitions. ```bash pip install praisonai duckduckgo_search ``` -------------------------------- ### Create PraisonAI Agent with Single Wikipedia Tool Source: https://docs.praison.ai/docs/features/langchain Demonstrates how to initialize a PraisonAI `Agent` with a single tool (`WikipediaAPIWrapper`) and define a research `Task`. It then sets up and starts the `PraisonAIAgents` workflow for a specific query. ```python from praisonaiagents import Agent, Task, PraisonAIAgents from langchain_community.utilities import WikipediaAPIWrapper # Create an agent with Wikipedia tool agent = Agent( name="WikiAgent", role="Research Assistant", goal="Search Wikipedia for accurate information", backstory="I am an AI assistant specialized in Wikipedia research", tools=[WikipediaAPIWrapper], self_reflect=False ) # Create a research task task = Task( name="wiki_search", description="Research 'Artificial Intelligence' on Wikipedia", expected_output="Comprehensive information from Wikipedia articles", agent=agent ) # Create and start the workflow agents = PraisonAIAgents( agents=[agent], tasks=[task], verbose=True ) agents.start() ``` -------------------------------- ### PraisonAI Training Configuration File Example Source: https://docs.praison.ai/docs/train Provides a comprehensive example of the `config.yaml` file used to configure PraisonAI training parameters. It defines settings for model saving, base model, dataset processing, LoRA parameters, batch sizes, learning rates, and quantization methods. ```yaml ollama_save: "true" huggingface_save: "true" train: "true" model_name: "unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit" hf_model_name: "mervinpraison/llama-3.1-instruct" ollama_model: "mervinpraison/llama3.1-instruct" model_parameters: "8b" dataset: - name: "yahma/alpaca-cleaned" split_type: "train" processing_func: "format_prompts" rename: input: "input" output: "output" instruction: "instruction" filter_data: false filter_column_value: "id" filter_value: "alpaca" num_samples: 20000 dataset_text_field: "text" dataset_num_proc: 2 packing: false max_seq_length: 2048 load_in_4bit: true lora_r: 16 lora_target_modules: - "q_proj" - "k_proj" - "v_proj" - "o_proj" - "gate_proj" - "up_proj" - "down_proj" lora_alpha: 16 lora_dropout: 0 lora_bias: "none" use_gradient_checkpointing: "unsloth" random_state: 3407 use_rslora: false loftq_config: null per_device_train_batch_size: 2 gradient_accumulation_steps: 2 warmup_steps: 5 num_train_epochs: 1 max_steps: 10 learning_rate: 2.0e-4 logging_steps: 1 optim: "adamw_8bit" weight_decay: 0.01 lr_scheduler_type: "linear" seed: 3407 output_dir: "outputs" quantization_method: - "q4_k_m" ``` -------------------------------- ### Install PraisonAI with CrewAI Framework Support Source: https://docs.praison.ai/docs/nocode/installation This command installs PraisonAI along with the CrewAI framework. It enables advanced task delegation, sequential, and parallel task execution, integrating PraisonAI tools for enhanced agent capabilities. ```bash pip install "praisonai[crewai]" ``` -------------------------------- ### Create and Run PraisonAI Agents Source: https://docs.praison.ai/docs/concepts/tasks These Python code examples demonstrate how to initialize and run PraisonAI agents. The first example shows a single agent setup, defining an agent and a task, then executing it. The second example illustrates a more complex scenario with multiple agents and tasks, orchestrated using a hierarchical process for collaborative work. ```python from praisonaiagents import Agent, Task, PraisonAIAgents # Create an agent researcher = Agent( name="Researcher", role="Senior Research Analyst", goal="Uncover cutting-edge developments in AI", backstory="You are an expert at a technology research group", verbose=True, llm="gpt-4o" ) # Define a task task = Task( name="research_task", description="Analyze 2024's AI advancements", expected_output="A detailed report", agent=researcher ) # Run the agents agents = PraisonAIAgents( agents=[researcher], tasks=[task], verbose=False ) result = agents.start() ``` ```python from praisonaiagents import Agent, Task, PraisonAIAgents # Create multiple agents researcher = Agent( name="Researcher", role="Senior Research Analyst", goal="Uncover cutting-edge developments in AI", backstory="You are an expert at a technology research group", verbose=True, llm="gpt-4o", markdown=True ) writer = Agent( name="Writer", role="Tech Content Strategist", goal="Craft compelling content on tech advancements", backstory="You are a content strategist", llm="gpt-4o", markdown=True ) # Define multiple tasks task1 = Task( name="research_task", description="Analyze 2024's AI advancements", expected_output="A detailed report", agent=researcher ) task2 = Task( name="writing_task", description="Create a blog post about AI advancements", expected_output="A blog post", agent=writer ) # Run with hierarchical process agents = PraisonAIAgents( agents=[researcher, writer], tasks=[task1, task2], verbose=False, process="hierarchical", manager_llm="gpt-4o" ) result = agents.start() ``` -------------------------------- ### Initialize PraisonAI Training Environment Source: https://docs.praison.ai/docs/train Initializes the PraisonAI training environment, setting up necessary directories and configurations before starting a model training process. ```bash praisonai train init ``` -------------------------------- ### Complete Basic PraisonAI Financial Agent Example Source: https://docs.praison.ai/docs/tools/yfinance_tools A comprehensive, runnable example demonstrating the full setup and execution of a basic PraisonAI agent for financial data analysis. It includes all necessary imports, agent and task definitions, and the workflow initiation. ```python from praisonaiagents import Agent, Task, PraisonAIAgents from praisonaiagents.tools import get_stock_price, get_stock_info, get_historical_data # Create finance agent finance_agent = Agent( name="MarketAnalyst", role="Financial Data Specialist", goal="Analyze market data efficiently and accurately.", backstory="Expert in financial analysis and market research.", tools=[get_stock_price, get_stock_info, get_historical_data], self_reflect=False ) # Define finance task finance_task = Task( description="Analyze tech sector performance and trends.", expected_output="Comprehensive market analysis report.", agent=finance_agent, name="sector_analysis" ) # Run agent agents = PraisonAIAgents( agents=[finance_agent], tasks=[finance_task], process="sequential" ) agents.start() ``` -------------------------------- ### Basic Example of PraisonAI Recommendation Agent Usage Source: https://docs.praison.ai/docs/agents/recommendation This Python snippet provides a concise example of how to quickly instantiate and use the PraisonAI Agent for recommendations. It shows the minimal setup required to get personalized suggestions using the DuckDuckGo tool. ```python from praisonaiagents import Agent, Tools from praisonaiagents.tools import duckduckgo agent = Agent(instructions="You are a Recommendation Agent", tools=[duckduckgo]) agent.start("Recommend me a good movie to watch in 2025") ``` -------------------------------- ### Complete Basic YAML Processing Agent Setup Source: https://docs.praison.ai/docs/tools/yaml_tools A comprehensive example demonstrating the full setup and execution of a single PraisonAI agent dedicated to YAML processing. It includes all necessary imports, the creation of an agent with specific YAML tools, the definition of a task, and the initiation of the agent's workflow. ```python from praisonaiagents import Agent, Task, PraisonAIAgents from praisonaiagents.tools import read_yaml, write_yaml, validate_yaml, merge_yaml, convert_yaml # Create YAML agent yaml_agent = Agent( name="YAMLExpert", role="YAML Processing Specialist", goal="Process YAML files efficiently and accurately.", backstory="Expert in YAML file handling and validation.", tools=[read_yaml, write_yaml, validate_yaml, merge_yaml, convert_yaml], self_reflect=False ) # Define YAML task yaml_task = Task( description="Parse and validate configuration files.", expected_output="Processed and validated YAML data.", agent=yaml_agent, name="config_processing" ) # Run agent agents = PraisonAIAgents( agents=[yaml_agent], tasks=[yaml_task], process="sequential" ) agents.start() ``` -------------------------------- ### Create PraisonAI Agents with Multiple Tools (YouTube, Wikipedia) Source: https://docs.praison.ai/docs/features/langchain Illustrates setting up multiple PraisonAI `Agent` instances, each with a different tool (`YouTubeSearchTool`, `WikipediaAPIWrapper`), and assigning separate `Task` objects to them within a single `PraisonAIAgents` workflow for diverse research. ```python from praisonaiagents import Agent, Task, PraisonAIAgents from langchain_community.tools import YouTubeSearchTool from langchain_community.utilities import WikipediaAPIWrapper # Create YouTube search agent agent = Agent( name="SearchAgent", role="Research Assistant", goal="Search for information from YouTube", backstory="I am an AI assistant that can search YouTube for relevant videos.", tools=[YouTubeSearchTool], self_reflect=False ) # Create Wikipedia research agent agent2 = Agent( name="WikiAgent", role="Research Assistant", goal="Search for information from Wikipedia", backstory="I am an AI assistant that can search Wikipedia for accurate information.", tools=[WikipediaAPIWrapper], self_reflect=False ) # Create YouTube search task task = Task( name="search_task", description="Search for information about 'AI advancements' on YouTube", expected_output="Relevant information from YouTube videos", agent=agent ) # Create Wikipedia research task task2 = Task( name="wiki_task", description="Search for information about 'AI advancements' on Wikipedia", expected_output="Comprehensive information from Wikipedia articles", agent=agent2 ) # Create and start the workflow agents = PraisonAIAgents( agents=[agent, agent2], tasks=[task, task2], verbose=True ) agents.start() ``` -------------------------------- ### Run PraisonAI Agent Configuration Source: https://docs.praison.ai/docs/features/langchain This command executes the PraisonAI application, loading agent configurations from a specified YAML file. It's the primary method for launching and running PraisonAI agents with their defined behaviors and tools. ```bash praisonai agents.yaml ``` -------------------------------- ### Initialize Agent with Knowledge Base Source: https://docs.praison.ai/docs/api/praisonaiagents/knowledge/knowledge Demonstrates how to create an `Agent` instance and configure its knowledge base by specifying source files and integrating with a Chroma vector store for persistent storage. ```python from praisonaiagents import Agent agent = Agent( name="Research Assistant", role="Knowledge expert", goal="Answer questions using knowledge base", knowledge=["research.pdf", "notes.txt"], # Files to process knowledge_config={ "vector_store": { "provider": "chroma", "config": { "collection_name": "research_kb" } } } ) ``` -------------------------------- ### Execute PraisonAI Agent Script Source: https://docs.praison.ai/docs/mcp/gemini Command to run the Python script that initializes and starts the PraisonAI agent. This demonstrates the final step in the setup process, allowing users to execute their configured agent and observe its behavior. ```bash python gemini_airbnb.py ``` -------------------------------- ### Install PraisonAI JavaScript/TypeScript Package Source: https://docs.praison.ai/docs/installation Command to install the PraisonAI package using npm, applicable for both JavaScript and TypeScript projects. ```bash npm install praisonai ``` -------------------------------- ### Agent Initialization with XML Tools Source: https://docs.praison.ai/docs/tools/xml_tools A concise example showing the `Agent` constructor, specifically highlighting how to pass a list of XML-specific tools to enable an agent for XML operations. ```python Agent(tools=[read_xml, write_xml, transform_xml, validate_xml, xml_to_dict, dict_to_xml]) ``` -------------------------------- ### Basic Knowledge Module Initialization and Usage Source: https://docs.praison.ai/docs/api/praisonaiagents/knowledge/knowledge Shows the fundamental steps to initialize the `Knowledge` module, add diverse content (files, URLs, raw text), and perform a simple semantic search to retrieve relevant information. ```python from praisonaiagents import Knowledge # Initialize knowledge base knowledge = Knowledge() # Add knowledge from various sources knowledge.add("path/to/document.pdf") knowledge.add("https://example.com/article") knowledge.add("Direct text content about AI") # Search the knowledge base results = knowledge.search("What is machine learning?") for result in results: print(f"Content: {result['text']}") print(f"Source: {result['source']}") print(f"Score: {result['score']}") ``` -------------------------------- ### Install PraisonAI Packages Source: https://docs.praison.ai/docs/introduction Instructions for installing the PraisonAI library using `pip` for Python environments or `npm`/`yarn` for JavaScript/TypeScript environments. This is the first step to set up the development environment. ```bash pip install praisonaiagents ``` ```bash npm install praisonai ``` ```bash yarn add praisonai ``` -------------------------------- ### Synchronous Image Generation with PraisonAI Source: https://docs.praison.ai/docs/features/image-generation Demonstrates how to initialize the PraisonAI ImageAgent and generate an image synchronously using a text prompt. This example shows basic setup, agent creation with DALL-E 3, and a direct blocking call to the `chat` method to get the image result. ```python from praisonaiagents.agent.image_agent import ImageAgent # Create an image agent agent = ImageAgent( llm="dall-e-3", verbose=True ) # Generate an image result = agent.chat("A cute baby sea otter playing with a laptop") print("Image generation result:", result) ``` -------------------------------- ### Complete Praison AI Knowledge Base Initialization and Data Ingestion Example Source: https://docs.praison.ai/docs/api/praisonaiagents/knowledge/knowledge This comprehensive Python example demonstrates how to initialize a `Knowledge` object with optimal settings, including collection name, storage path, chunking strategy, and reranking. It also shows how to add various types of knowledge sources like local documents, web URLs, and direct text. ```python from praisonaiagents import Knowledge, Agent, Task, PraisonAIAgents import os # Initialize knowledge base with optimal settings knowledge = Knowledge( collection_name="customer_support", storage_path="./support_kb", chunk_size=512, chunk_overlap=50, chunking_strategy="recursive", use_reranking=True ) # Add various knowledge sources print("Building knowledge base...") # Documentation for doc in os.listdir("./docs"): if doc.endswith(('.pdf', '.md', '.txt')): knowledge.add(f"./docs/{doc}") print(f"Added: {doc}") # FAQs from web knowledge.add("https://example.com/faq") # Direct knowledge knowledge.add(""" Customer Support Best Practices: 1. Always greet customers warmly 2. Listen actively to understand the issue 3. Search knowledge base before responding 4. Provide clear, step-by-step solutions 5. Follow up to ensure resolution """) ``` -------------------------------- ### Install PraisonAI Python Packages Source: https://docs.praison.ai/docs/installation Commands to install the core PraisonAI packages and the PraisonAI Agents package using pip, targeting Python development environments. ```bash pip install praisonaiagents ``` ```bash pip install praisonai ``` -------------------------------- ### Install Dependencies and Configure API Keys for SerpAPI Source: https://docs.praison.ai/docs/tools/external/serp-search This snippet provides the necessary shell commands to install the required Python packages (`langchain-community`, `google-search-results`) and set up environment variables for SerpAPI and OpenAI API keys. These configurations are crucial for enabling the SerpSearch tool and PraisonAI agents to function correctly. ```bash pip install langchain-community google-search-results export SERPAPI_API_KEY=your_api_key_here export OPENAI_API_KEY=your_api_key_here ``` -------------------------------- ### Configure Vector Store and Embedder Source: https://docs.praison.ai/docs/api/praisonaiagents/knowledge/knowledge Example configuration dictionary for setting up the vector store provider (e.g., Chroma, Qdrant, Pinecone) and the embedding model (e.g., OpenAI's `text-embedding-3-small`). This dictionary is passed to the `Knowledge` class during initialization. ```python config = { "vector_store": { "provider": "chroma", # Options: chroma, qdrant, pinecone "config": { "collection_name": "my_knowledge", "path": ".praison", # For local storage # Additional provider-specific options } }, "embedder": { "provider": "openai", "config": { "model": "text-embedding-3-small" } } } ``` -------------------------------- ### Instruct PraisonAI Agent for Automated Data Analysis Script Generation Source: https://docs.praison.ai/docs/agents/programming This Python example showcases how to prompt the PraisonAI Agent to create a data analysis script. The agent is guided to use pandas, read CSVs, perform statistics, and generate visualizations, handling package installation and result analysis autonomously. ```python # Example: Create and run a data analysis script response = agent.start(""" 1. Create a script that: - Uses pandas for data analysis - Reads a CSV file - Performs basic statistics - Creates a visualization 2. Check and install required packages 3. Execute and analyze the results """) ``` -------------------------------- ### Install PraisonAI Agents Package Source: https://docs.praison.ai/docs/examples/emergency-response Installs the PraisonAI Agents Python package using pip, the standard package installer for Python. This is the first step to start developing with PraisonAI Agents. ```bash pip install praisonaiagents ``` -------------------------------- ### Create and Run a Multi-Tool Agent with PraisonAIAgents Source: https://docs.praison.ai/docs/mcp/mcp-tools This Python example demonstrates how to set up and run a multi-tool agent using the `praisonaiagents` library. It initializes an agent with `MCP` tools for filesystem, GitHub, and memory management, defines two tasks, and then executes them through the `PraisonAIAgents` system. Environment variables for GitHub token are also configured. ```python from praisonaiagents import Agent, Task, PraisonAIAgents, MCP import os # Set up environment os.environ["GITHUB_TOKEN"] = "ghp_..." # Create agent with multiple MCP tools agent = Agent( name="DevOps Assistant", instructions="""You are a DevOps assistant that can: - Manage files and directories - Interact with GitHub repositories - Store and retrieve important information Use your tools wisely to help with development tasks.""", tools=[ MCP("npx @modelcontextprotocol/server-filesystem"), MCP("npx @modelcontextprotocol/server-github"), MCP("npx @modelcontextprotocol/server-memory") ] ) # Create tasks tasks = [ Task( description="Check the current directory structure", agent=agent, expected_output="Directory listing with key files identified" ), Task( description="Remember the project structure for future reference", agent=agent, expected_output="Confirmation that structure is memorised" ) ] # Run the system agents = PraisonAIAgents(agents=[agent], tasks=tasks) result = agents.start() ``` -------------------------------- ### Experiment with Different Queries for PraisonAI Agent Source: https://docs.praison.ai/docs/course/agents/11-creating-your-first-agent This Python example shows how to reuse an existing PraisonAI agent instance to process multiple different queries. It demonstrates the flexibility of the agent to respond to various topics based on its defined instructions without needing re-initialization. ```python # Try different questions response = research_assistant.start("What are the benefits of exercise?") # or response = research_assistant.start("How does artificial intelligence work?") ``` -------------------------------- ### Get Data Visualization Recommendations with AI Agent Source: https://docs.praison.ai/docs/course/agents/17-data-analysis-agents Presents an AI agent (`VisualizationAdvisor`) designed to recommend optimal data visualization types. Its instructions guide it to consider data nature and relationships. The example shows how to query the agent with various data scenarios to receive tailored visualization suggestions and explanations. ```python visualization_agent = Agent( name="VisualizationAdvisor", instructions=""" You are a data visualization specialist who helps select the best ways to visually represent data. When recommending visualizations: 1. Understand the nature of the data (categorical, numerical, time-series, etc.) 2. Consider the key relationships or patterns to highlight 3. Recommend the most appropriate chart or graph type 4. Explain why your recommendation is effective 5. Provide suggestions for layout, color scheme, and labeling Common visualization types to consider: - Line charts (for trends over time) - Bar charts (for comparing categories) - Pie charts (for showing composition, use sparingly) - Scatter plots (for showing relationships between variables) - Heatmaps (for showing patterns in complex data) - Box plots (for showing distributions) """ ) viz_recommendations = visualization_agent.start( """ I have the following data and need visualization recommendations: 1. Monthly sales data for the past year 2. Customer satisfaction ratings across 5 product categories 3. Market share compared to 3 competitors 4. Customer age distribution What visualizations would you recommend for each of these datasets and why? """ ) print(viz_recommendations) ``` -------------------------------- ### Initialize PraisonAI agents.yaml Configuration File Source: https://docs.praison.ai/docs/features/cli This command initializes a new `agents.yaml` file in your project directory, pre-populating it with a basic configuration tailored to the provided task description. It streamlines the setup process for new AI projects by generating a starting point for agent definitions. ```bash praisonai --init "Create a movie script about AI" ``` -------------------------------- ### Visualize Basic AI Agent Flow with Mermaid Source: https://docs.praison.ai/docs/index This Mermaid diagram illustrates a fundamental AI agent workflow, depicting a start point, two distinct AI agents, a central processing step, and a final output. It visually represents the sequential and potentially iterative nature of agent interactions within a system. ```mermaid graph LR %% Define the main flow Start([▶ Start]) --> Agent1 Agent1 --> Process[⚙ Process] Process --> Agent2 Agent2 --> Output([✓ Output]) Process -.-> Agent1 %% Define subgraphs for agents and their tasks subgraph Agent1[ ] Task1[📋 Task] AgentIcon1[🤖 AI Agent] Tools1[🔧 Tools] Task1 --- AgentIcon1 AgentIcon1 --- Tools1 end subgraph Agent2[ ] Task2[📋 Task] AgentIcon2[🤖 AI Agent] Tools2[🔧 Tools] Task2 --- AgentIcon2 AgentIcon2 --- Tools2 end classDef input fill:#8B0000,stroke:#7C90A0,color:#fff classDef process fill:#189AB4,stroke:#7C90A0,color:#fff classDef tools fill:#2E8B57,stroke:#7C90A0,color:#fff classDef transparent fill:none,stroke:none class Start,Output,Task1,Task2 input class Process,AgentIcon1,AgentIcon2 process class Tools1,Tools2 tools class Agent1,Agent2 transparent ``` -------------------------------- ### Establishing Agent Process Guidelines Source: https://docs.praison.ai/docs/course/agents/04-agent-instructions Demonstrates how to provide step-by-step instructions for an AI agent's task execution, comparing detailed and generic approaches. ```text First analyze the data trends, then identify key risk factors, and finally make recommendations based on the client's risk tolerance. ``` ```text Just do a good analysis. ``` -------------------------------- ### Install PraisonAI with Both CrewAI and AutoGen Frameworks Source: https://docs.praison.ai/docs/nocode/installation This command installs PraisonAI with integrations for both CrewAI and AG2 (AutoGen) frameworks. It combines their respective features, offering comprehensive support for diverse agentic workflows and task management. ```bash pip install "praisonai[crewai,autogen]" ``` -------------------------------- ### Install PraisonAI with AutoGen (AG2) Framework Support Source: https://docs.praison.ai/docs/nocode/installation This command installs PraisonAI with the AG2 (AutoGen) framework. It provides multi-agent conversation capabilities and a robust code execution environment, leveraging PraisonAI tools for complex workflows. ```bash pip install "praisonai[autogen]" ``` -------------------------------- ### Quick Start for CrewAI with PraisonAI Source: https://docs.praison.ai/docs/framework/crewai Demonstrates the basic steps to set up your OpenAI API key, initialize a new CrewAI project with a specific task using PraisonAI, and then execute the defined agents. ```bash export OPENAI_API_KEY=xxxxxxxxxx praisonai --framework crewai --init "Create a Movie Script About Cat in Mars" praisonai --framework crewai ``` -------------------------------- ### Install PraisonAI Agents Python Package Source: https://docs.praison.ai/docs/mcp/openai Provides the command to install the `praisonaiagents` Python package using pip, which is necessary to run the provided examples. ```zsh pip install praisonaiagents ``` -------------------------------- ### Install PraisonAI Core Package (No Code Setup) Source: https://docs.praison.ai/docs/features/codeagent Installs the core `praisonai` package along with `e2b_code_interpreter`. This installation path is used when defining agent systems primarily through YAML configuration rather than direct Python code. ```bash pip install praisonai e2b_code_interpreter ``` -------------------------------- ### Complete PraisonAI DeFi Market Making Workflow Example Source: https://docs.praison.ai/docs/examples/defi-market-maker This comprehensive example demonstrates how to define agents, create interconnected tasks, assemble them into a `PraisonAIAgents` workflow, and execute it asynchronously. It illustrates a DeFi market-making scenario involving market analysis, arbitrage detection, liquidity optimization, risk assessment, and trade execution, showcasing conditional task flow and result handling. ```Python risk_assessor = Agent( name="Risk Assessor", role="Risk Assessment", goal="Assess trading risks", instructions="Evaluate potential risks and mitigation strategies", tools=[assess_risks] ) trade_executor = Agent( name="Trade Executor", role="Trade Execution", goal="Execute optimized trades", instructions="Execute trades based on analysis", tools=[execute_trades] ) # Create workflow tasks market_task = Task( name="analyze_market", description="Analyze market conditions", expected_output="Market analysis", agent=market_analyzer, is_start=True, next_tasks=["detect_arbitrage", "optimize_liquidity"] ) arbitrage_task = Task( name="detect_arbitrage", description="Detect arbitrage opportunities", expected_output="Arbitrage opportunities", agent=arbitrage_detector, next_tasks=["assess_risks"] ) liquidity_task = Task( name="optimize_liquidity", description="Optimize liquidity", expected_output="Liquidity optimization", agent=liquidity_optimizer, context=[market_task], next_tasks=["assess_risks"] ) risk_task = Task( name="assess_risks", description="Assess trading risks", expected_output="Risk assessment", agent=risk_assessor, context=[arbitrage_task, liquidity_task], next_tasks=["execute_trades"] ) execution_task = Task( name="execute_trades", description="Execute trades", expected_output="Trade execution results", agent=trade_executor, task_type="decision", condition={ "success": ["analyze_market"], # Continue monitoring if successful "failed": ["optimize_liquidity"] # Reoptimize if failed } ) # Create workflow workflow = PraisonAIAgents( agents=[market_analyzer, arbitrage_detector, liquidity_optimizer, risk_assessor, trade_executor], tasks=[market_task, arbitrage_task, liquidity_task, risk_task, execution_task], process="workflow", verbose=True ) async def main(): print("\nStarting DeFi Market Making Workflow...") print("=" * 50) # Run workflow results = await workflow.astart() # Print results print("\nMarket Making Results:") print("=" * 50) for task_id, result in results["task_results"].items(): if result: print(f"\nTask: {task_id}") print(f"Result: {result.raw}") print("-" * 50) if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Install PraisonAI Agents Python Package Source: https://docs.praison.ai/docs/features/autoagents Installs the necessary Python packages for AutoAgents, including `praisonaiagents` for core functionality and `duckduckgo_search` as an example tool, enabling web search capabilities. ```bash pip install praisonaiagents duckduckgo_search ``` -------------------------------- ### Install PraisonAI Agents Package Source: https://docs.praison.ai/docs/concepts/memory Installs the PraisonAI Agents package along with the 'memory' extra and 'duckduckgo_search' for web searching capabilities. 'duckduckgo_search' is required for the multiple agents example. ```bash pip install "praisonaiagents[memory]" duckduckgo_search ``` -------------------------------- ### Complete Example: PraisonAI Research Assistant Agent Setup and Usage Source: https://docs.praison.ai/docs/features/knowledge This Python example demonstrates how to set up a research assistant agent using `praisonaiagents`. It configures a knowledge base with ChromaDB for vector storage, OpenAI embeddings, and semantic chunking. The agent is initialized with specific instructions and documents, then used for conversational queries and direct knowledge base searches. ```python from praisonaiagents import Agent from praisonaiagents.knowledge import Knowledge # Configure knowledge base knowledge_config = { "vector_store": { "provider": "chroma", "config": { "collection_name": "research_papers", "path": "./knowledge_db" } }, "chunker": { "name": "semantic", "threshold": 0.7 }, "embedder": { "provider": "openai", "config": { "model": "text-embedding-3-small" } }, "reranker": { "enabled": True } } # Create research assistant research_agent = Agent( name="Research Assistant", instructions="""You are an expert research assistant. Use the knowledge base to provide accurate, well-sourced answers. Always cite the specific documents you reference.""", knowledge=[ "papers/ai_safety.pdf", "papers/llm_alignment.pdf", "https://arxiv.org/pdf/2301.00234.pdf" ], knowledge_config=knowledge_config, knowledge_sources=["research_papers"], # Named source markdown=True ) # Use the assistant response = research_agent.chat( "What are the main approaches to AI alignment?" ) # Direct knowledge queries kb = research_agent.knowledge_instance papers = kb.search("alignment techniques", limit=5) for paper in papers: print(f"- {paper['text'][:100]}...") print(f" Source: {paper.get('metadata', {}).get('source')}") ``` -------------------------------- ### Install PraisonAI Core Package for Declarative Setup Source: https://docs.praison.ai/docs/tools/langchain_tools This command installs the core `praisonai` package. This package is intended for use with the declarative YAML configuration approach, which is noted as an upcoming feature. ```bash pip install "praisonai" ``` -------------------------------- ### Install Dependencies for Multi-Agent MCP Server with Custom Tools Source: https://docs.praison.ai/docs/mcp/mcp-server Installs `praisonaiagents` with MCP support and `duckduckgo-search` for internet search capabilities, enabling custom tool integration in multi-agent setups. ```bash pip install "praisonaiagents[mcp]" duckduckgo-search ``` -------------------------------- ### Install PraisonAI Agents Package Source: https://docs.praison.ai/docs/course/agents/11-creating-your-first-agent This command installs the PraisonAI agents library using pip, making it available for use in Python projects. It's the first step to setting up your development environment. ```bash pip install praisonaiagents ``` -------------------------------- ### Initialize PraisonAI Agents for Web Search and Content Generation Source: https://docs.praison.ai/docs/tools/external/serp-search This Python example demonstrates how to initialize `PraisonAIAgents` with a `SerpAPIWrapper` tool. It sets up two distinct agents: a 'data_agent' for performing web searches on specific topics and an 'editor_agent' for generating content based on the search results, illustrating a collaborative multi-agent workflow. ```python from praisonaiagents import Agent, PraisonAIAgents from langchain_community.utilities import SerpAPIWrapper data_agent = Agent(instructions="Search about decline of recruitment across various industries with the rise of AI", tools=[SerpAPIWrapper]) editor_agent = Agent(instructions="Write a blog article pointing out the jobs most at rish due to the rise of AI") agents = PraisonAIAgents(agents=[data_agent, editor_agent]) agents.start() ``` -------------------------------- ### Install PraisonAI Core Python Package Source: https://docs.praison.ai/docs/features/selfreflection Installs the main PraisonAI Python package using pip, which supports configuration via YAML files for agent setup. ```bash pip install praisonai ``` -------------------------------- ### Quick Start: PraisonAI Math Agent with Python Code Source: https://docs.praison.ai/docs/features/mathagent This comprehensive guide details how to set up and run a Math AI agent using the PraisonAI Agents Python library. It covers installing necessary dependencies, configuring your OpenAI API key, defining the agent's role, goal, backstory, and tools, and finally, executing the agent to perform complex mathematical tasks. ```bash pip install praisonaiagents sympy pint ``` ```bash export OPENAI_API_KEY=your_api_key_here ``` ```python from praisonaiagents import Agent, Task, PraisonAIAgents from praisonaiagents.tools import ( evaluate, solve_equation, convert_units, calculate_statistics, calculate_financial ) # Create math agent math_agent = Agent( role="Math Expert", goal="Perform complex mathematical calculations", backstory="Expert in mathematical computations and analysis", tools=[ evaluate, solve_equation, convert_units, calculate_statistics, calculate_financial ], verbose=True ) # Create a task task = Task( description="Calculate compound interest and statistical analysis", expected_output="Detailed mathematical analysis", agent=math_agent ) # Create and start the agents agents = PraisonAIAgents( agents=[math_agent], tasks=[task], process="sequential", verbose=2 ) # Start execution agents.start() ``` ```bash python app.py ``` -------------------------------- ### Install PraisonAI with Agent Frameworks Source: https://docs.praison.ai/docs/nocode/auto Commands to install PraisonAI and its optional dependencies for specific agent frameworks (PraisonAI Agents, CrewAI, AG2) using `pip`, allowing for single or multi-framework setups. ```bash # For PraisonAI Agents pip install praisonai # For CrewAI pip install "praisonai[crewai]" # For AG2 (Formerly AutoGen) pip install "praisonai[autogen]" # For both frameworks pip install "praisonai[crewai,autogen]" ``` -------------------------------- ### Advanced Knowledge Module Initialization with Direct Parameters Source: https://docs.praison.ai/docs/api/praisonaiagents/knowledge/knowledge Provides an example of initializing the `Knowledge` module using direct parameters for detailed configuration, including collection name, storage path, chunking strategy, embedding model, and reranking, followed by adding multiple documents. ```python from praisonaiagents import Knowledge # Configure with custom settings knowledge = Knowledge( collection_name="technical_docs", storage_path="./my_knowledge_base", chunk_size=512, chunk_overlap=50, chunking_strategy="semantic", embedding_model="all-MiniLM-L6-v2", use_reranking=True, reranking_model="ms-marco-MiniLM-L-6-v2" ) # Add multiple documents docs = ["doc1.pdf", "doc2.md", "doc3.txt"] for doc in docs: knowledge.add(doc) # Search with custom limit results = knowledge.search( "explain neural networks", limit=10 ) ``` -------------------------------- ### Install PraisonAI Framework Source: https://docs.praison.ai/docs/js/typescript-async Instructions for installing the PraisonAI framework using popular Node.js package managers, npm and Yarn. This setup is essential to begin developing multi-agent LLM systems. ```bash npm install praisonai ``` ```bash yarn add praisonai ``` -------------------------------- ### Install PraisonAI Agents Package Source: https://docs.praison.ai/docs/examples/adaptive-learning Installs the `praisonaiagents` Python package using pip, providing the necessary libraries and tools to develop and run AI agent-based workflows. ```bash pip install praisonaiagents ``` -------------------------------- ### Install PraisonAI with AgentOps Integration Source: https://docs.praison.ai/docs/monitoring/agentops This command installs the PraisonAI library, specifically including the necessary dependencies for AgentOps integration. This enables the monitoring features provided by AgentOps for your PraisonAI projects. ```bash pip install "praisonai[agentops]" ``` -------------------------------- ### Simple Travel Planning Agent Example Source: https://docs.praison.ai/docs/agents/planning A concise Python example illustrating the basic usage of the Planning Agent. It demonstrates how to quickly set up an agent with instructions and tools to generate a travel plan for a specified destination and requirements. ```python # Example: Create a weekend trip plan from praisonaiagents import Agent, Tools from praisonaiagents.tools import duckduckgo agent = Agent(instructions="You are a Planning Agent", tools=[duckduckgo]) agent.start("I want to go London next week, find me a good hotel and flight") ```