📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

09 How to Use CrewAI from the Command Line

Techlatest dot net11:40

Transcription

Hi everyone, and welcome to this Crei tutorial brought to you by tech latestage.net.

Before we jump into today's demo, let's quickly recap what we have covered so far. We started by introducing the Cre framework, used for building powerful multi-agent systems. Then we moved to Cre Studio, a user-friendly GUI-based alternative to coding. And lastly, we covered Jupyter Hub, a collaborative browser-based environment for developing and testing AI agents.

Now, to simplify setup, uh, to simplify setup, Techest offers a preconfigured virtual machine that includes Crei, Crei Studio, and Jupyter Hub with GPU support, ready to deploy on Azour, GCP, and AWS. We also walked through deploying the VM and accessing all tools and demoed how to use CRI Studio for research and article writing. We also built a multi-agent financial analysis system that can gather stock data, design trading strategies, execute trades, and assess risk, working together using CUI inside Jupyter Hub.

Now, in this uh video, we will uh walk you through the default scaffold generated by Crei create command. If you are new to multi-agent systems or CRE, this is the perfect starting point to understand how things work behind the scenes. So let's dive in.

With the Create CRE command, you can simply get the scaffold of your Cre project ready. The default projects come with all the structure of agents, task, and crew ready to use. Uh, I'm here on my tech test VM SSH terminal. I can create a CI project anywhere I want. But uh, just to keep everything in one place, I will create it inside my setup folder. So, CD to our setup folder. All the setup files and folders are available here. Uh, like this Jupyter configuration files, and then CRU as studio, CUI, and we have Jupyter virtual environment also. So all these files and folders are under setup folder.

Okay. Now, when you run the command C AI create, it bootstraps a basic project for you, complete with agents, task, and pre-wired Python setup. Uh, it will ask you to select the LLM provider to set up. Enter the number of your choice. I'm going with option 10, Azure.

Now, complete other details here. If you choose any other model, it may ask you uh some more configuration questions. You can provide them right here, or you can skip them and set it later once the project is ready. So here, in my case, uh, let uh skip this setup uh here, just to show you how you can edit it later. Okay.

Now my project is ready. Uh, let's take a quick look at the folder structure. So, CD to qi demo folder and run ls command. We got this basic folders with knowledge, tools, by project.toml file, and this src folder, which is very important here.

Now, navigate to src and then again CD to cre demo folder, which is our project name. Right here, we have a config directory and mainly cre.py and main python files. Okay.

So, inside the config directory, we have agents and task.ml files. Let's start with agents. Mml. This is where we define the agents in our crew. So we have two agents here: researcher and reporting analyst. Each agent has a role, goal, and backstory. Role, a title including the input variable like uh, this uh, topic in a curly braces. Then goal, what they aim to accomplish. And lastly, we have backstory. This adds context and personality to how the LLM behaves. Okay.

Now, the topic within curly braces is a variable uh, here uh, which gets replaced with the actual topic we provide during the execution of this Creo. So, interpolation will happen at runtime. Okay.

Next, in uh, next is like taskml file, which defines what each agent needs to do. We have uh, two tasks: research task and reporting task. Each task is uh, each task includes a description uh, using variables like uh, here, topic within curly braces, an expected output, and the agent who will perform the task. Now, this structure supports multi-step, multi-agent workflows like research followed by analysis.

Now, let's uh, look at our Q. py file. Uh, this is where QAI wires everything together. So uh, this is my file. We defined a class called CUI demo and decorate it with the cre base. So CI knows it's a cre. Okay.

Now, at agent uh, this registers the functions as an agent. It loads the config from agents.yamel by name. Same goes for task. A task marks it for the registration, and we load its config using the task name. Okay.

Now, finally, the crew decorator builds the full pipeline, connecting all agents and task in either sequential or hierarchical process. Here uh, we are going with the sequential process.

Now, let's see everything using uh, now let's see main.py file, which provides four functions: run, train, replay, and test. This calls the crew with your inputs and kicks off the whole workflow. Okay.

Now, want to evaluate or fine-tune? Use the test and train methods. Test evaluates the agents using the eval lm, and train runs multiple iterations and logs the outputs.

Now you can add the required functionality in your project by editing agents uh uh, task, crew, and main files, and then you can run this crew to see in action, or uh, we can simply edit our main YAML file here and uh, provide the different inputs and play around. For this demo uh, we are going to run this uh, default setup here. Okay, we are not editing anything. Uh, just we will go with the default one. Okay.

So now, before running the c, we need to edit our environment file with the API keys of our LLM provider of choice. Okay. So for that, navigate to the root of your project. There uh, it already created the environment file. Do ls-a here. So this is the environment file already created. But we need to provide the API keys. So, edit the file using vi dot vi space env command. To enter the details, press I. It will enable insert mode. Copy-paste the API keys of your lm provider. Then save the changes by pressing escape key, followed by colon wq.

All right. Now we are ready to run our Cleo. You can run this uh, from terminal. To run this, make sure you are in the root of your project directory and then enter crew AI run command like this. You should see the output in the console as uh, shown here. Uh, so we ran the crew, the agent started working on the assigned task and provided a well-structured output. We asked for 10 bullet points here, and here we have our 10 bullet points on LLM train in 2025.

Now, on this tech setup, Jupyter Hub installation is also done, which uh, you can access directly in your local browser using the public IP of the VM. So, suppose you don't want to edit your agents, task, and other files by the terminal. Uh, you can access the same scaffold you created using create command uh, from the Jupyter Hub. Uh, now for that, just log to Jupyter Hub using Ubuntu user and its password. From the left pane, open your web project, and here you can edit the files by simply clicking it.

Now, after editing all your files and folders, you need to, if you haven't set your environment file, you can do it from here in, from Jupyter Hub as well. So for that, just open the new tab uh, in uh, this uh, Jupyter Lab and uh, open the terminal uh, in terminal, navigate to your root for uh, root of your uh, project, and then uh, open the environment file using the v editor. Same, same thing we did in uh, from the terminal as well. So, just to set the environment file, you need to uh, use the terminal from inside the Jupiter Hub as well. You can use it. Okay.

So now, navigate to your project and run Q run command from this terminal. So this is a great option to edit and run your queue of AI agents instead of going through SSH terminal.

That's it for this walkthrough. Uh, you have now a complete working scaffold for crew. You can edit it as per your use case and run the AI agents. We also have everything documented on our website. You can check various deployment guides. Then here we have Jupyter Hub user management guide, terminal guide for creating and running projects, and lastly, this Cre Studio quick guide. You can also refer to official documentation pages from this user guide.

So with this, we completed our video course on AI agents using PUS Studio and Jupiter with GPU support. Thank you for watching. If you like this tutorial, be sure to like and subscribe and leave your comments. Follow us on X, Medium, Twitter, LinkedIn, LinkedIn for more technical contents. Thank you so much.