The RIGHT WAY To Build AI Agents with CrewAI (BONUS: 100% Local)

The RIGHT WAY To Build AI Agents with CrewAI (BONUS: 100% Local)

Optimal Setup for Crew AI Team

In this section, the speaker introduces the optimal way to set up a crew AI team using Lightning AI, a cloud-based code editor. The focus is on building a crew AI code framework and structuring the team efficiently.

Building the Crew AI Code Framework

  • To begin, create a new studio in Lightning by signing up for an account and accessing free credits.
  • Set up a code Studio within Lightning to leverage its cloud environment, eliminating python environment management issues.
  • Structure the crew in a modular way with separate areas for tools and yaml files defining agents and tasks.

Creating Task Definitions

  • Establish a source folder within which specific crews are named; e.g., "financial analyst crew."
  • Create subfolders like "config" to organize task definitions effectively.
  • Define agents and tasks by creating agent.yml and task.yml files respectively.

Defining Tasks for Crew AI

  • Structuring tasks like researching specific companies (e.g., research company task).
  • Detailing parameters such as descriptions and expected outputs for each task.
  • Crafting tasks like analyzing company data with specified metrics for financial analysis.

Setting Up Agents

Financial Researcher Agent Setup

In this section, the setup for a financial researcher agent is discussed, including naming conventions, roles, and goals.

Naming Conventions and Roles

  • The name of the agent is "Company Researcher," with the role named as "Financial Researcher." Explicit mention of using search tools is made to enhance efficiency.

Delegation and Verbose Settings

  • Delegation is set to false to prevent task delegation. Verbose setting is enabled to view all agent activities.

Agent Modification

  • The second agent is created by modifying the first one. The new agent is named "Company Analyst" with a goal to create detailed financial reports based on provided company information.

Agent File Creation and Setup

This part covers creating a main file that integrates agents and tasks together for a cohesive project setup.

Importing Libraries

  • Relevant libraries such as agent, crew, process, and task are imported from Crew AI project for file creation.

Grock Integration

  • Grock integration through Lang chain is emphasized for powering the project. Installation instructions are provided if needed.

Creating Crew Base and Definitions

Setting up crew base, defining agents, tasks, and crew for seamless project execution.

Crew Base Creation

  • A class named "Financial Analyst Crew" is created under crew base to manage agents and tasks efficiently.

Agent Definitions

  • Definition of agents like "Company Researcher" and "Company Analyst" are outlined with configurations linked to specific models for varied sources usage.

Task Definitions and Crew Formation

Defining tasks such as company research task and analyze company task along with forming the crew structure.

Task Definition

  • Tasks like company research task and analyze company task are defined linking them to respective agents for execution.

Crew Formation

  • The crew formation process involves integrating all agents, tasks, setting sequential processing mode, and enabling verbose output for comprehensive results.

Financial Analyst Crew Setup

In this section, the speaker demonstrates how to set up the financial analyst crew by importing necessary modules and defining the main file.

Importing Modules and Defining Main File

  • Import financialanalystcrew module.
  • Define the main file by passing in inputs, such as the company name (Tesla).
  • Obtain a Grock API key for further setup.

Setting Up Tools and Libraries

This part focuses on utilizing existing tools within the financialanalystcrew library and setting up SEC tools for analysis.

Utilizing Existing Tools

  • Copying SEC tools from examples library.
  • Creating a new file named SECtools.py and pasting existing code for functionality.

Poetry Integration and Project Execution

The speaker demonstrates integrating Poetry for project management and running the financial analyst crew project.

Poetry Integration Steps

  • Installing Poetry using pip install poetry.
  • Customizing Poetry settings with financial analyst crew name.
  • Locking dependencies with poetry lock and installing them with poetry install.

Running Financial Analyst Crew Project

This segment covers running the financial analyst crew project, resolving module issues, and observing successful execution.

Running the Project

  • Resolving module not found issue by installing LinkChain Grock.
  • Successfully running the project, obtaining information about Tesla's stock price, market cap, news, calculations, ratios, and metrics.

Exploring OpenAI Models

Exploring open-source models powered by Lightning AI to enhance capabilities beyond Grock integration.

OpenAI Model Exploration

  • Accessing Lightning Studios templates page for preconfigured models.
  • Observing GPU usage options for different model requirements like Mixol.

API Integration and Model Execution

In this section, the speaker demonstrates how to integrate an API into the code and execute a model.

Integrating API and Executing Model

  • To integrate the API into the code, import oama from Lang chain.llms.
  • Comment out a line of code and create a new instance called olama_mixol.
  • Running the model might be slow due to its size, but it shows that the integration is working.
Video description

This is the "golden path" for building AI Agents using CrewAI. If you follow this template, you'll be set up to use all upcoming features with CrewAI, such as an automatically created API for your agents. Enjoy :) CrewAI Lightning Studio: https://lightning.ai/mberman84/studios/sour-sapphire-39pg~01hnzq5jpxqckky30rmwwz0r3q/ Cloud IDE, Fine-tuning, Inference, Data Management and more! Try Lightning AI Studio FREE Today: https://bit.ly/3uBiWO9 Join My Newsletter for Regular AI Updates šŸ‘‡šŸ¼ https://www.matthewberman.com/ Need AI Consulting? āœ… https://forwardfuture.ai/ My Links šŸ”— šŸ‘‰šŸ» Subscribe: https://www.youtube.com/@matthew_berman šŸ‘‰šŸ» Twitter: https://twitter.com/matthewberman šŸ‘‰šŸ» Discord: https://discord.gg/xxysSXBxFW šŸ‘‰šŸ» Patreon: https://patreon.com/MatthewBerman Media/Sponsorship Inquiries šŸ“ˆ https://bit.ly/44TC45V Disclosures I'm an investor in CrewAI