👨‍💻

Setting Up a Crew AI Team using Lightning AI

Jun 29, 2024

Setting Up a Crew AI Team using Lightning AI

Introduction

  • Tutorial on optimal setup for Crew AI team
  • Techniques from Crew AI founder
  • Utilizing Lightning AI – a cloud-based code editor
    • Collaborate on code in the cloud
    • Power open-source models
  • Goal:
    • Build a Crew AI team
    • Replace GPT-4 with Mixol or Mistol

Initial Setup

  • Sign up for a Lightning account
  • Create a new studio: Code Studio
  • Entire environment is cloud-based
    • Avoids issues with Python environment management

Structure the Crew AI Code Framework

  • Source folder organization
    • Right-click: New Folder -> source
    • Create subfolders for specific AI teams, e.g., financial analyst crew
    • Sub-subfolder: config
  • Familiar environment: Similar to VS Code

Define Agents and Tasks

  • Use YAML files
    • Create files agents.yaml and tasks.yaml
  • Example Tasks:
    1. Research Company Task
      • Description: Use search tools to look up company's stock info
      • Expected Output: Relevant financial information
    2. Analyze Company Task
      • Description: Analyze financial info (profitability, liquidity, solvency ratios)
      • Expected Output: Thorough financial analysis

Define Agents

  • Agents describe roles and goals based on tasks
    • Example: company researcher, financial researcher
    • Set delegation and verbosity options

Main File Setup

  • Create main.py file
    • Import necessary libraries from Crew AI and Langchain for Grok
    • Define agents and tasks using decorators @agent and @task
    • Create and configure the Crew

Environment Configuration

  • Automatic Saves: Lightning AI benefits
  • Tools setup using existing libraries e.g., SEC_tools.py from Crew AI examples

Running the Project

  • Use Poetry for dependency management
    • Commands: pip install poetry, poetry lock, poetry install
    • Run with: poetry run financial_analyst_crew

Powering with Open-Source Model (Mixol)

  • Use Lightning AI GPUs
  • Access Studio Templates from Lightning
  • Use API Builder to expose endpoint
    • Incorporate Mixol model via Langchain llms.Olama
    • Change model definition in main.py to use Olama Mixol
  • Performance Check: Validate by monitoring GPU activity

Conclusion

  • Successful setup of Crew AI team
  • Switching from GPT-4 to open-source models with Lightning AI GPUs
  • Exposing API endpoints and integrating into projects

Final Notes

  • Credits: Lightning AI sponsoring the tutorial
  • Encouragement to like and subscribe