Overview
This guide explains how to add logging and evaluations with Galileo to an existing CrewAI application. In this guide you will:- Set up a project with Galileo
- Load environment variables if necessary
- Add the Galileo event listener
- Run your crew
Before you start
To complete this how-to, you will need:- An agentic application built with CrewAI. This guide assumes you have a
run()function as your entry point.If you don’t have a CrewAI application, you can follow the Build your first Crew guide from the CrewAI documentation.
- A Galileo project configured, with relevant metrics configured
- Your Galileo API key
Install dependencies
To use Galileo, you need to install some package dependencies, and configure environment variables.Install Required Dependencies
Install the required dependencies for your app. Create a virtual environment using your preferred method, then install dependencies inside that environment using your preferred tool:Install
python-dotenv if you don’t already have this installed.Load environment variables if necessary
Galileo needs values like the API key and project name set as environment variables. If you are not already loading a.env file, then you need to do so.
You can skip this step if you are already loading the
.env file.Import the dotenv package
Add the following code at the top of your
main.py file to import dotenv and load the .env file.This assumes you are following the same structure as the sample CrewAI applications. If you are not, add this to the top of the file that contains the entry point of your application.
Add the Galileo event listener
To enable logging with Galileo, you need to create an instance of theCrewAIEventListener.
Import the Galileo CrewAI handler package
Add the following code at the top of your
main.py file:This assumes you are following the same structure as the sample CrewAI applications. If you are not, add this to the top of the file that contains the entry point of your application.
