How to AUTOMATE LINKEDIN POSTS with CrewAI | CrewAI Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
we all know LinkedIn the most popular social network for professionals and we also know that there are times when we are not inspired and it costs a lot to create a good LinkedIn post to share with the community but what if I told you that there is a way to make a job easier and what if I told you that your new LinkedIn post could be generated by multiple AI agents collaborating the solution to a problem has a name crew AI in today's video we will use this library to automate the creation of a LinkedIn post about the latest llm released by meta Lama 3 ladies and gentlemen welcome to the neural maze hello everybody and welcome to anal maze in today's video we are going to investigate the capabilities and functionalities that crew AI has to offer and to do this we are going to follow the last art article I have uploaded into my website that you can see right now in the screen by the way you have a link in the video description as well the article I'm referring to is this one over here automating my LinkedIn post with crew Ai and as you can imagine the article is about how I created a crew of Agents using crew AI that generate LinkedIn posts but not any LinkedIn post because in this case this generated this artificial LinkedIn post must follow my writing style they must manifest some kind of personality in them but for those of you who have never played with crei before I strongly recommend you to read through the article right here because uh I'm explaining in detail a lot of the concepts that you may consider as the building blocks of crei such as what is an agent or what is a task right here what is a tool an example of tools uh what is a crew Etc uh and also providing examples and C the Snippets to make it easier to digest uh but in this video just to be honest I'm I will limit myself to give you a very high level description high level uh idea of how crew aai works but I'm not going to get into the detail of each one of the components because you have plenty of tutorials in YouTube and and the official documentation and as I was saying you could simply read through the article and I can assure you that if you finish this uh whole article you will have a decent level in crei so yeah as I was saying I'm not going to get into the details about crei here I'm just going to give you a very high level uh idea of the framework and then we are going to get into pie charm to see the code related with this with this article that basically is how to create this LinkedIn post because there are some interesting uh stuff in there so according to the official documentation crew AI is a framework for orchestrating agents AI agents for this purpose uh the framework defines several components that I have simplified in this diagram right here let me zoom in that's it in this diagram you can see all the main components in action on one side on the left we have three agents which are these orange robots which can collaborate with each other and have an assigned task you can see right there so you can see the first agent is assigned to task one and the second agent is assigned to task two and the third agent is assigned to task three in some cases these agents will be enable to complete their assigned task by themselves so they will need to use tools which you can see right there and these tools are nothing more than interfaces that the agent uses to communicate with the outside world if you have work with L chain in the past you surely know what I'm talking about but you have a catalog of all the tools available in crei in case you are interested in fact if you go here to the crei documentation and you get into the Core Concepts tools you can click the available crei tools and you have a list of all the implemented Tools in crei and of course you can you can also use the L chain tools uh in fact let me show you right here in the how to guides there's a tough really interesting about how to create your custom tools and this is something that I'm going to show you later because I have created my own custom tool for connecting an agent with LinkedIn basically and I need to I I had to to use um yeah some custom tools for this purpose so that's something that I'm going to to show you later if we go back to to the diagram there's only one thing missing here uh which is the the crew I mean we have been talking about tasks about tools about agents but what is a crew so really simple a crew is just putting all of these uh together basically and to show you how how it works to show you uh how all of this is implemented in crei I will give you a very simple example that I have taken from the crei documentation uh and you will see really quick how it works so let me zoom out okay so this is the code I have taken from the crei documentation and as you can see we are defining two agents here first of all the researcher agent and second the writer agent agent the researcher agent has uh a role which we need to Define in CI which is uh being a senior research analyst and also a goal discover Innovative AI Technologies as we said before some agents may need tools to access the outside world in this case we are defining the daao search run which lets the agent access some relevant information from the web using Dao search engine the second agent the writer is not using any tools because it just needs to access the context from the previous agent all the information gathered by uh the researcher agent and it needs to write engaging articles on AI discoveries as we have stated here in the goal then we need to define the tasks in this case since we have two agents we are going to have two tasks the research task and the write article task we need to provide a description for each one the first one it's identify breakthrough AI Technologies and the second draft an article on the latest AI Technologies and as I was saying before when we were checking the diagram we need to assign a task with an agent so for example here this first agent is assigned with a researcher this first task sorry is assigned with the researcher engine agent and this second uh task is assigned with the writer agent finally we are defining the crew by listing the agents and the tasks and we are kicking off the application by running this my crew. kickoff and the application the crew AI application will uh start after that okay so I think we have finished all this high level introduction to crei and we can move into the funny part which is uh the creating lcking posts you have it under the under this section right here uh if you want to to check the article uh but basically here I'm putting another diagram with the proposed architector that I followed in my in my repo so um here what you see are three agents you have a first agent which is called the LinkedIn scrubber agent you have a second agent which is called the web researcher agent and a third one which is called the LinkedIn influencer agent so what are these agents doing in particular so the first agent the LinkedIn sraer agent is going to connect to my LinkedIn profile by using a tool named selenium if you don't know selenium uh it's basically a tool that allows us to automate the web browser let's get back to the article so this first stent as we were saying it's going to use the selenium Custom Tool to do some web scrubing in my LinkedIn account it's going to log into my LinkedIn account it's going to get into my LinkedIn posts and it's going to download some relevant posts from all the posts that I have uploaded uh these past weeks and then we have another agent which is the web researcher agent which is really a really simple one it just uh uses the server def tool to download some relevant content or information from the web in my case uh the topic that the LinkedIn post is going to be about is uh the difference the advantages of Lama 3 over Lama 2 since uh meta released Lama 3 a couple of days ago uh I thought it would be funny to have a LinkedIn post about it um so this is the main goal of this web researcher agent yes basically to get some relevant content about the topic that we ask him and lastly we have this LinkedIn influencer agent which is the most important one because it has to access both the information gathered from the LinkedIn Scrapper agent and the web researcher agent to create a LinkedIn post that resembles my writing style okay so I think we are now ready to go so let's get into the code the code I'm going to show you right now is available in the neural maze GitHub organization which is the one that you can see see the screen right now if you go to the repositories you just need to look for this repository right here crew AI LinkedIn post uh you also have the link in the description by the way uh so this repository contains all the code related with this tutorial so you can simply clone the repository and you will be able to follow the tutorial or even clone it if you want to make some changes or uh customize it uh whatever whatever you want uh in my case I'm going to move into py charm because I think it will be easier to show you all the code all the relevant relevant pieces in there so that's what I'm going to do right now here we are in by charm I want to start by showing you all the agents that I created for this application and just a reminder remember that we wanted to create three agents as we saw in the article diagram before we want to create this LinkedIn Scrapper agent the web researcher agent and finally the LinkedIn influencer agent so that's what we are going to see right here in this uh python module the agents dopy that you can see right here so let's begin with the LinkedIn scriper agent right here so as you can see defining an agent in crew aai is extremely simple we just need to provide a roll description we just need to provide a goal in this case your goal is to scrap a LinkedIn profile to get a list of post from the given profile then we need to define a backstory this really improves the quality of the role play between the agents and finally we have to define a tool in this case we are not using any of the Native crew aai tools we are using some Custom Tool that I will show you right now to see the content of these tools to see the implementation of this tool you just need to go to this folder right here uh it's called the tools folder and inside just get into the LinkedIn dopy module inside you will see the implementation of this tool as I was saying and for this I'm using the tool decorator that crew AI provides it belongs to the crew aai tools library and it's really easy to implement as I will show you right now you just need to decorate a python function with this tool decorator and give a name to the given tool in this case I have named my tool scrap LinkedIn post so it's really self-explanatory and then you just need to implement all the logic that you want inside the python function let me show you a little bit about the logic that I implemented for this tool I'm not going to get into any detail here because it will involve getting into all the details about selenium and also beautiful soup and things like that and I don't think that's the main interest of this video but I will will show you a little bit about what the tool is doing underneath so as you can see the first thing that the tool is expecting is a couple of environment variables related with LinkedIn for example my LinkedIn email the password and the profile name that we are going to explore then uh if you keep scrolling down you will see that there is code related with uh selenium where we are going to automate a web browser browser and log into LinkedIn log into my profile using the username and password that we provided as the environment variables then we are going to get into the LinkedIn profile in this case I'm going to use mine and get into the recent activity all uh which means that we are going into all the posts listed that belongs to me and then we are going to scroll down through my different posts and get a sample of these posts like three or five posts basically to get a grasp of my writing style for the for the last of the of the agents as I was saying I'm not going to get into all of these util functions what it does because we are calling beautiful soup for paring the HTML and we are calling different functionalities from selenium what I will do instead is to show you this tool in action I have created a python script in this repository it's called run tool. piy and we are going to run this python script script because it will allow us to see how this tool behaves okay so let me just open a terminal right now and I will simply run this script so it's python run tool. pi and we wait for a couple of seconds and we should start seeing this tool in action so the first thing that is going to do is to open uh Chrome tab now it's going to access my LinkedIn now it's going to get into my LinkedIn profile it's inside my LinkedIn profile and now it's going to scroll down a little bit to get a sample of all my different uh posts if you look at the terminal right now you will see that the selenium tool has successfully downloaded some of my posts in LinkedIn and this information if we go back to the diagram is the information that the last of the agents the LinkedIn influencer agent is going to need to emulate my writing style okay so I think that's enough for this Custom Tool and I think we can go back to the agents file and let's explore the second agent this is really really straightforward really simple the web researcher agent uh the role is a web researcher basically and what it does is to the goal is to search for Relevant content about the comparison between Lama 2 and Lama 3 so I told told you this is my the topic that I was interested in uh then we Define a backstory you are proficient and searching for specific topics in the web selecting those that provide more valuable uh more value and information and then you define two tools in this case the scrap scrap website tool and the Search tool which uh if you go here uh you will see that these are not native crew AI tools for scrapping a a website using the serper API and finally we have the most important agent as we said before this is the I call it the doppelganger agent but uh if you go to the diagram it's basically the LinkedIn influencer agent and the goal of this agent is to create a LinkedIn post comparing LMA 2 and Lama 3 following the right in style observed in the LinkedIn post scrap by the lincolin post scrubber so it's a very clear very specific goal and as backstory uh you are an expert in writing LinkedIn posts replicating any influencer style uh by the way in this case I'm not using the typical GPT by default uh crew AI uses GPT 4 in this case I'm using Mr Large because I wanted to to try these these models these mistal llms now let's go to the tasks so tasks are really straightforward in this case we have three tasks each task is assigned to each one of the of the agents the first task the scrap linking task uh as you can imagine is assigned with the LinkedIn Scrapper agent the second task the web research task is assigned with the web researcher agent and lastly the create LinkedIn post task is assigned with the doubleganger agent with this LinkedIn influencer agent one of the important things that you have to pay attention to is this uh la this last line here line 32 because let's get back to the diagram as we said before the last agent need needs to access both the context of the first agent the LinkedIn squer agent and the second agent the web researcher agent and to do this we need to Define that the context of the last task of this task right here is going to depend on the context of the two previous tasks of the scrap scrap LinkedIn task and the web research task and that's exactly what we are doing in this line okay so I think it's time to show you the main file where we are putting everything together using the crew as you see in the screen uh the crew in the crew we are defining a list of Agents basically the three agents that we defined before and we are defining a list of tasks which are the ones that we have uh recently seen and then we simply kick off the crew and we are ready to go so let's run the crew right here Python main.py and let's see how it behaves so as you can imagine the first uh okay it's going to access the selenium tool again as we saw in in the Run tool. Pi that I saw you before it's going to get into my LinkedIn profile it's going to download again a sample of my LinkedIn posts as you can see right here and now the next agent which is the web researcher agent is going to search for results in this case for example uh you can see that it has successfully gathered some interesting titles for example Lama 2 versus Lama 3 an in-depth comparison this is a medium post we have here Lama 3 versus Lama 2 comparison different features the apps for rent uh so a lot of different titles a lot of different webs and articles that this agent is going to fetch and it's going to filter and when it ends we are going to have some relevant and high quality information about the differences between Lama 2 and Lama 3 we have finished this chain and now we are entering the last agent and here you can see the final result uh let's copy all of this and let's paste it into a Sublime time text okay here here we go so Lama 2 versus Lama 3 what's new and improved and it puts two emojis of llamas so yeah it seems to be working fine this week I've been diing deep into a world of Lama AI models comparing Lama 2 on the newly released Lama 3 blah blah blah it compares the tokenization uses sent piece and Lama 3 has transition to open tick token uh for efficient en coding of language this seems to be to be accurate uh okay it talks about special tokens performance improvements um resoning and code generation Etc so it's not the best um it's not the best LinkedIn post out there but still I think it's pretty decent I mean of course you will need to make a lot of changes and to tweak uh a lot of details but still I think we could say that it's uh quite decent okay so that's everything for today I hope you enjoy the video and don't forget to subscribe if you like the content and also don't forget to take a look at the website in case you're interested in these kind of topics because I will be uploading new articles soon having said that I think uh it is time to say goodbye so I guess I will see you in the next video a [Music]
Info
Channel: The Neural Maze
Views: 4,391
Rating: undefined out of 5
Keywords:
Id: oIb5JqZ5ylA
Channel Id: undefined
Length: 22min 38sec (1358 seconds)
Published: Fri Apr 26 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.