Build AI Agents with Docker, Here’s How

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
my name is David Andre and here is how to build AI agents with doer the release of Claud 3.5 Sonet just started an entirely New Era of AI agents few days ago anthropic released this state-of-the-art model which is far better than GPT 40 I'll show you how to build AI agents with Sonet 3.5 to automate any part of your work or life you have to build agents now in a few months open AI will released GPT 5 pouring gasoline on the agent Revolution now is the time to learn this if you wait the opportunity might be gone but David I don't know how to code well I designed this tutorial so that anyone even non programmers can followon yes there will be code however I will explain everything simply and easily now that 3.5 Sonet exists you don't even have to write the code this is a historical moment and I'm not ere exaggerating the arrival of AI agents will fundamentally change how Computing is done before we only have developers and apis well now we have deaths apis and agents the fact that developers no longer have to be in the loop will let us automate nearly anything but you have to build safe agents because runaway behavior is perhaps the biggest risk when building AI agents so maybe an AI agent deleting some important files or a AI agent messing up your system you know all of these can happen Docker fixes this it lets you build and deploy your agents in separate containers every single professional developer uses Docker and so should you plus I was lucky enough to have Docker sponsor this video now sonid 3.5 few days ago and thropic the AI company which is perhaps open ai's biggest competitor released the best large language model in the world it's better at speed cost and performance it destroys gbt 40 which is open ai's best model in all of these areas another question I hear all the time is David which AI agent framework do I choose and the answer is just pick one and get started the real benefits will be unlocked when you master one of the agent Frameworks deeply now for this demo I will actually not be using any framework and I'll explain why later now here is why you need doer for building AI agents Docker ensures that your agents run on anyone's machine with containers you create a controlled environment for your AI agents so nothing crazy can happen knowing how to use Docker will give you a huge Edge over other agent developers because let me tell you a little dirty secret most agent developers are still not using Docker agents with Sona 3.5 why is it such a big deal all the agents you built in the past when a new better llm comes out you just switch the API which takes like 2 minutes right and since Claude 3.5 Sonet just least it's only a matter of time before everyone switches so take advantage of this window for agent building the the benchmarks that matter the most are reasoning code and instruction following and of course Sonet 3.5 excels at all of these now when it comes to do you have to learn these three fundamental concepts number one a Docker file which is you know super simple it's a set of instructions telling Docker how to build and run your application number two a Docker image this is a snapshot of a fully configured system ready to be ex exed number three a Docker container which is a runnable instance of a Docker image isolated from your host system and if this is confusing don't worry it'll make a lot more sense when we actually build the agent in a bit almost all Tech startups and even big tech companies use Docker so if you're not using Docker you will get outc competed by someone who does by the way it's just super valuable to have Docker on your resume of skills whether that's on LinkedIn or just your CV you have to be part of the future AI agents aren't some far off dream the agent Revolution is happening right now don't get left behind because 99% of people will never build a single agent therefore miss out on all the benefits so let's get to building the next part of the video will show you how to build an AI agent with Sonet 3.5 step by step all right so the first thing we need is vs code if you don't have it installed just you know type in vs code download into Google which will bring you to this page you can choose your operating system if you know how to install a video game you can install vs code all right so here I have a simple test file hello. py the reason I'm doing this is because I want to show you on a simple file how to use Docker containers understanding it now will set you up for Success when you build complex agents okay so let me tell you what we're going to be building right the most requested agent of all time on my channel is an agent that builds large data sets for llm fine tuning and by the way I'm open to building any agent so if you want me to build a specific agent comment below and I might build it in the future so we have this project we need to create a Docker file for it so new file and name it Docker file no extension important this is very important let's use Sonet 3.5 to help us out so I'm in the anthropic console right here console. anthropic docomo World python file and I want to create a Docker file for it so even if you have nothing you can use Sonet 3.5 you can use this amazing AI tools to help you get unstuck so let's look at the docker file right so the first thing we need is to set the base image we're going to do from python I'm going to do 3.11 it doesn't really matter then we need to set the working directory for the container work there/ app super simple again I'm using help of Sonet 3.5 so if you get stuck at any point just you know you can type it in or you can take a screenshot of your entire screen and just like you know have the AI help you out the only excuse is just laziness because like you can help you can have the AI tools do the work for you do the programming for you next we need to copy the python script to The Container again super simple copy hello.py and then dot CMD and then Python and hello py and we just do contrl s and boom that's it that's our Docker file saved now we need to do the docker image and this part is even easier to build the docker image open a terminal so I'm going to do that in vs code open up a new terminal and let's let's do Docker build- D and we can do hello Docker this is just the name of the image you know you can name it anything and then dot enter and this is going to start building our Docker image and seems like we're done in 1.2 seconds and actually if we go to our Docker desktop which uh I highly recommend you download it's the first link in the description this is an amazing piece of software because it lets you see your containers and your images in Docker super easily so a lot of people are scared of the terminal you know using the terminal can be intimidating so download Docker desktop again first link in the description you'll see all the images and containers all we need to do is Docker run and then the name of our image we don't have to run it in vs code right so obviously we have our vs code terminal but you might be thinking okay it's the terminal you know it already knows our file no no no the docker container is completely separate it can run anywhere on any server any machine any computer any phone this this is why doer is necessary for building a agents so what we need to do is Docker run and then the name of our image so even if you forgot your image go into your Docker desktop click on images and you have the image name right here so let's open the terminal Docker run hello- Docker enter and boom our code executes this is the beauty of Docker man you have to learn Docker it's actually amazing so again Docker desktop is the first link in the description go and download it because it will make everything so much easier so now let's get to building our agent because again as I said this has been the most requested agent of all time so let's create a new file let's do agents. py empty python file you can close these again it's an agent that will take a sample CSV file or sample data set and it creates thousands or tens of thousands lines of CSV in a new data set and outputs it right so if you have like another suggestion of agent I should build in the future comment below so the first thing we need to do is obviously import the libraries import the necessary libraries exactly and for this we need to do import OS import CS V because we're going to be working with CSV files and then last but definitely not least import andth piic and by the way if you do this for the first time what you have to do is you have to open a terminal and you have to install the package right so do pip install and thropic for the first time you have to do this in the terminal you hit enter every time you install a library or any dependency you should put it into a requirements txt file so it's literally requirements.txt so let's copy the anthropic and you can put it here now we have the Imports finished we have the requirements file this piece of code will set the API key and it's super simple like if not meaning if there isn't API key in the environment variable it will ask the user you know please input your anthropic API key so now obviously we have not done this part we we don't have any environment variable right so we should do that right click new file. EnV be very mindful of what I'm doing pay close attention you it has to be named exactly this way inside of the environment varable we have to set the anthropic API key so you thinking okay David but I've never used API Keys what do I do chill out it's very easy take a deep breath okay go into the anthropic console so it's the same console actually I'm using Sonet here but instead of the workbench as you can see here here we're in the workbench here we go into the settings and click on API keys on the left you will log in with the same account you use for mopic so even if you use claw. a you will log in with the same account if you don't have account just register like it's very seconds right so create key can name it Docker agent create key boom and copy I'm click on copy and let's control vrl s that's just like that environment file finished and by the way never share API keys with anybody I will delete this key before uploading the video so now that we have the API key set okay so this block of code will create anop client so we create a new variable named client and we do anthropic do anthropic and another variable named Sonet and you don't have to do this I just like to do it for organization purposes and we name it CLA 3.5 Sonet and by the way if you're wondering like where do I get the exact name of the model for the API well just go to anthropic documentation so docs. anthropic ccom on the left scroll down to models click on models and as you can see you have all the model names for the API so Sonet 3.5 is here you know Opus is here high C so literally just copy this and this is how you get the exact model name so you can use it in your code oh by the way one tip with the anthropic API key if you're doing this for the first time what I recommend is adding your credit card and charging like $5 that way you don't run into any issues so now let me show you the first function we're going to use so this is a function that's going to read a CSV file it's going to be example file we're going to provide the agent right so we create an empty list then we open the file in read mode then we create a CSV reader object and then we iterate for every Row in CSV reader we append in other words we add a new row to the data list so you know to this list we add a new row for every line in our CSV and then we return the list once it once it has all the rows okay very simple function now we need a second function this time for saving the CSV file right this one is for reading in this one for saving it so again save to CSV uh this time we we take three different parameters instead of one so the data the output file and the headers and by default it's set To None meaning if we don't specify it's fine it will assume there are none but we can overwrite this right and this line this line of code is my favorite such a cool line of code man so we we set a variable mode and the mode equals W which is right mode if headers meaning if we have headers else it's a pend mode so actually this is very good because you understand the three main modes for working with files read you can only read it you cannot change anything right this gives you the most power you can delete lines you can add lines you can change anything about the file a which is append you can only you cannot mess with the current data you can only add stuff at the bottom so here this line of codes so beautiful man it decides the mode based on if we have headress because if we don't it just do append if we do um it's right mode okay next we open the file again output file this time we set the mode for the variable and we set it as F we create a new uh you know object as before if the headers were provided in the parameter in the argument when calling the function we will write a new row headers so the first row will be you know obviously the headers of the CSV file but if they aren't because if there aren't this is skipped and then we do a simple for Loop for every Row in the CSV reader we do data split lines so split the data string into rows and then iterate and then we write all the rows now I know some of you might be like oh my God what is all this code like I'm getting lost here is a simple tip what you should do right anytime you don't understand anything you can use either CH GPT or enop but don't get overwhelmed so what you can do is you can take a screenshot put it inside of here right you can Lally do like let's say I don't understand uh the Imports right or whatever let's say I don't understand the docker file well I'm just going to take a screenshot of this go into cat GPT paste it inside boom and like explain this I am a beginner programmer I have no idea what any of this means answer in short right boom and you can do the same obviously in the enthropy console so here I pasted the last function you can I can do like explain what this code does in simple terms and I do enter and like this like look at this this code defines a function called save to CSV that saves the data to a CSV comma separate values file here is a simple explanation it takes three inputs it decides whether to write it so like not knowing how to code is just an excuse it really is because you can get you can learn everything with these uh tools but even if you don't want to learn learn it you can just use them like paste a screenshot let's say you have uh you know you're stuck you're getting some error take a screenshot paste it inside describe what's happening and it was explain right this is a Docker file used to create a Docker image for a python application here's a breakdown super simple so if any part of this video you feel like okay this is over my head this I'm getting overwhelmed pause take a screenshot go into the anthropic console or inside of C gbt doesn't really matter paste the screenshot inside and you know ask it and it will explain it's really is amazing and it's it's kind of crazy how many people still don't take advantage of this feature take advantage of the screenshots the vision capabilities of these models are just wild okay so now let's get to building agents we have the two functions for the CSV but the best part is obviously building AI agents so first I'm going to do an analyzer agent which is going to analyze the data we give it to gather insights and to you know learn the formatting so as you can see we have some underlined stuff we'll take a care of that when we get to it so as you can see create an analyzer agent and again this is simple def meaning we Define a function named analyze agent which takes the sample data as the parameter okay so message this is how you ping the anthropic API so this is the syntax again you don't have to learn this because it's all in the docs it's all in the docs so you can go into arobic documentation click on quick start and literally scroll down right there's like explained everything so how you know P install ropic we did that you know export API key and this is how to get a message right it's all in the docs anytime you're stuck at anything just look up the documentation for it literally this is exactly what I'm doing I don't even remember it myself I just I just look up the documentation when I need something right so again use the documentation use the models it like the combination of these two there's there's very few things you cannot build with a combination of documentation and AI models actually anyways let's get back right so model we set the model to onet this is our variable we said earlier then we do Max tokens which is the response right limit the response to 400 tokens uh each token is like roughly one like one word translates to 0.7 no one token translates to 0.75 words right so each word is roughly 1.33 tokens so this will give you like I don't know 350 words roughly right and we we don't need more than that in a response temperature you know this is basically the randomness or creativity as you can think about it for for the analyzer I want to do low 0.1 it's very low and as the comment says to be that way the agent is more focused and more deterministic less random now this is the system prompt right as you can see like okay David but why is it underlined well because the variable does not exist so let's fix that I'm going to put this into a separate file just you know so you can see it's more organized easier to understand so create a new file let's do prompt. py new python file for the proms let me put the comments prom. py at the top that way you can always see what's happening and I actually have the proms prepared so here are all the proms we're going to be using I'm not going to read through it all but if you want you can get the code the promps and the docker files inside of my community it's going to be linked below everything is in there including all the stuff I've built in my previous videos anyways let's continue now we have it you know we have the analyzer system prompt generator system prompt but they're not showing up here and that is because we need to import right so we do from prompts import and then Asterix which Imports everything prompts it automatically notes is the proms P1 py file because it's in the same directory and we just import everything from it so all the four variables we have inside we import it right so now if we scroll down it is no longer white you know it can identify the prompt beautiful then for the messages this basically is like the history of the chat so here you can have like so many messages you can have roll um user and then roll assistant roll user roll assistant and you can have an entire chat history in here but since this is the first message it's very simple we just do roll user so this is the message from the user and then we send it the content is the analyzer user prompt so here we have the system prompt now we're using the user prompt which is this part of the code and we format it because you know we have some variables in built in here so we do that format and then sample data equals sample data which we pass as an argument in the function okay and then last at the end we just return message. content zero and text this is you know the syntax to get just the text of the message and nothing else okay so this is our first agent built all right so here is the code for the generator agent very Sim very similar but uh we have some more data so this time we have three different arguments analysis result which is the result of the analyzer agent as it takes our sample CSV you know with the examples analyzes it it will return an analysis this is we're going to pass that to the generat agent so that it can see it then simple data which is the same you know it's the data we provide and then the number of rows in other words what we should like the badge size basically how many rows we want the generator agent to generate and just to give you example like you can you can you know do the same inside of Sonet here so we can maybe change this up um let's delete this and let's like generate 50 lines of CSV for the samp data set let's do for fitness exercises whatever and here you can see like it just generates 50 lines right so exercise category equipment difficulty muscle group calories burned per 30 minutes recommended reps recommended sets so pretty forough CSV for you know such a simple prompt as you can see it just generates lines of code and here we got stuck uh you know here we got stuck because as you can see in the model settings we only did 800 so if we up that to like 3,000 if we do again it will generate all lines all 50 Lines no problem so we just check you know boom so yeah 30 I have like said default to 30 obviously you can override that but uh yeah it can be more it can be probably 50 probably 70 as well anyways again model Sonet this time Max tokens we increase it here we only 400 here we do, 1500 um you know if you want to do more you can do even more you can do 3,000 whatever depends obviously it's kind of correlated with this how many rows you want to generate temperature this is pay attention because here we have a super low temperature here we have a super high temperature to get the you know more creative diverse output because we don't want all the lines of CSV to be the same we wanted to create synthetic data a new data set so we want some you know Randomness some creativity system prompt we attach the generator system prompt this one and then again roll user and the content is this prompt which has three variables actually so as you can see see um let's look at it generate and then variable number of rows so let's let's do like generate furly new CSV rows and then we pass in the analysis from the analyzer agent and then the sample data which we give it okay and here is actually very important to include something like this like do not include any text before and after data just start by outputting the new RS no extra text if you don't you have to be like explicit like this otherwise it will say like here is the data and that can mess up the whole thing right it should just output the CSV no no extra comments okay so now we've figur configured both of our agents as you can see the reason I'm not using any framework is because it's actually like a pretty simple team of Agents I mean you might say like okay this is intimidating we're already like 75 lines of code but like relatively speaking you know we're only using two agents here so we we don't need like anything like Advanced tools any you know Advanced team of Agents uh you know it's very simple and what I need is like control over it I need like consistency so with anytime you introduce any agent framework it's complicates things right and it especially if you haven't built the framework yourself if you don't have like intimate knowledge of the how it works it adds complexity to the project and that is often not a good thing so sometimes it is best to not use any framework and in this case I made a decision to not go with any agent framework and just you know do it myself so now that we have the agent bills let's go to the main execution flow in other words where the program actually starts doing stuff right because so far we've only defined functions and if we don't call the functions they will not do anything okay so main execution flow first we need to get input from the user so file path meaning where is the CSV file and what what's the name of the CSV file we do enter the name of your CSV file so in our case uh let me show you what I have so I have the like a super simple file so this is the file and you might be like okay I don't have a sample data set chill out okay I created this literally with jgb so as you can see these are the headers first draw is headers so fret type this is for cyber security indicator of compromise severity level and mitigation steps so as you can see it's just 20 lines and this was literally created with cgbd so I mean I'm going to show you how to do it from scratch right so let's open up a new chat and I can do create okay give me 10 ideas for a s simple data set for llm fine tuning and if you have your own use case you obviously don't need the ideas because you already know right okay so let's do let's do this customer service emails this is used for for basically every business right so let's go with idea number one create a create a new data new CSV data set with 30 rows with u let's do five different columns okay so this is different from our data set because as you can see we have 20 rows you know obviously excluding the header and then we have four different columns right in the header now I'm doing 30 and five and it's using Code interpreter to create this right so it Imports the P library and it decides the columns email ID customer inquiry customer name support response blah blah blah and it creates the sample data so obviously if you want a high quality data set you probably should go through this yourself you should look at it it's like all is correct all is high quality because the higher quality the examples you feed into our agent the better output will be so again you can use either of these probably I would use Sonet 3.5 because it's a lot more creative so you would use the exact same prompt you know uh create a new data set CSV dat set 30 rows and you would do it in Sonet but doesn't matter if you Sonet or cgbd both will work and then you get a downloadable link to the CSV but yeah basically this is what we feed it this is what we give it as an example we give it examples of how it should look like when it's perfect so obviously if you do it manually you know you have more control if you Outsource it with ch gbt it's going to be some there's going to be some Randomness it's not going to be as high quality right so I would recommend at least 20 examples in the sample data set ideally 30 50 the more the better and go for it yourself make sure it's as high quality as possible because it really will determine everything so here we get the file path so we basically ask the user input enter the name of your CSV file so in this case I would type in input. CSV then um by the way I'm I'm going to run the agent at the end so don't worry all of all of that I'll show you how to put it into Docker and how to run it and how to actually take this agent yourself so even if you don't want to take my code I mean if you want the code obviously in the community but if you don't want to take the code and you just want to run the container you want to run the agent in the docker container I'm going to show you how to do all of that so watch until the end then we do the file path right so the os. path. join and we basically get the path of this file so this is going to be in the docker container right the agent py and then it goes into SL app so if you remember Docker file SLA and then in in data it's going to be so file PA then the desired rows so this basically again Ask the user with an input any times there's input we ask the user for the input and then we do int meaning it takes it and converts it into integer now if you're experienced programmer you might be looking up at that okay David if somebody enters a string you know something that's not a number or a decimal point whatever it will throw an error and that is correct it will throw an error if it's not an integer if somebody inputs like a word or whatever but I just want to keep keep it simple like literally one line of code okay now we need to read the sample data so we do sample data variable equals read CSV so we're calling upon the function the first function we've built we're calling upon it and we pass the file path as the argument and then we do a string of this you know a new variable but this time it's a string because this is going to be a list of lists so we need to convert the 2D list to a single string and this is going to do that so this is a new line character that join with the comma join Row for every Row in Sample data this is like a you know complicated syntax but again you don't have to understand it in fact Sonet 3.5 wrote this I didn't even write this line so like chill out anytime you see something complicated chances are Sonet wrote it and I just used it because it works you just you just need to keep like a overview of the project you're basically like a CEO or a manager and you need to keep in you need to know like what each part does right you need to understand what what each of the files is for you know what each function does but if you like don't understand some complex syntax it's absolutely fine like in the future we'll just use English to program all right next this is perhaps the simplest part of the code just some print statements to update the user so we do print and then launching team of Agents you know kind of giving the user some info what's happening then we need to analyze the s data using the anal agent so analysis result we declare a new variable and we assign it the output of the analyis agent so we call this we call this function and then we return the text from it right and we save this into the variable then we do analyser agent output a simple print statement to kind of update what's going on then we actually give it the analysis result and we you separating line that way U you know there is some spacing you'll see when we run the agent you'll see see that's why I'm putting these new line characters everywhere that way it's like nicely nicely separated by the way this process of me pasting in stuff and not doing any tests this is completely different from how I actually build agent the way I built it is I went from Super Basics I literally did one anthropic API call which was like you know tell a joke or something trivial and then once I got that working I started building on top right I added the proms into separate files run a bunch of tests until it's working then I added a second agent you know second API call ran a more tests all of like until it's like working perfectly for like you know three different times in a row then I what I did is I connected the agents then I tested that so the building process is very different from you know when I've already had have it built and I'm just like showing you what I've built and like pasting in blocks of code if you're building something start small start with the super minimal viable product whether that's you know what we did at the start just like a simple hello python file so we like get the docker container working maybe then you add you know you add the anthropic API key and you get a successful API response then you maybe add the function to read the CSV file and you feed that into the first agent so you can see like okay the agent can work with the CSV file you you start small and then you add complexity until you have you know hundreds of lines of code and the stuff is working because if you don't do this if you go to you know Sonet and you just ask like hey build this you can you can do that like you can go here and type in you know all of this you explain the scope of the project type in all the functions you need all of the functionality you want your agent to have and it will build it the thing is that if it doesn't work and you have like 200 lines of code you're kind of screwed because like good luck debugging that especially if you're not a good programmer so if you're a beginner start small don't rush through it don't be tempted by like having Sonet do everything in the first try everything in one prompt no start small get the basic working once you have something trivial working something useless you know tell a joke or or whatever then add one more functionality and then add one more and test it like run five 10 different tests you know testing the code at every point of the process and when it runs when it runs successfully only then add more stuff otherwise you just get lost and you know once once you have 100 lines of code and you you don't understand the project deeply and intimately intimately you will be overwhelmed like Beyond overwhelmed you will know you will not know what to do so don't get to that point you have to keep a pulse on the project you have to understand what's going on so now let's do the output so we need to Output the file again super simple part you know definitely compared to the functions so we set up the output file so new variable output files equals app data new data set. CSV this is the name we could name it anything could name it uh xdxd doesn't matter I can just leave it but yeah whatever new data set. CSV U that's good letters we get them from sample data and zero so obviously in programming the first U line or the first item in analist is obviously index zero so we get the headers from the sample data and then so by the way just you know make sure you actually include headers in your SLE dat so as you can see I have headers here if you don't um you will get the first line you will get this which is not the headers so make sure you include head anyways then we save the output file using the save to CSV function the reason why we pass an empty string as the first argument is because we're using the function to initialize the file just to get the file created and to add the headers not to add the actual data inside that will be done by the generator agent next we simply set the badge size two integers right so we decide on the badge size again it could be more it could be 50 it could be 70 uh I just keep it 30 for Simplicity and this is basically the number of rows we ask the generator agent to generate each time it runs and then we do generate rows so this is a counter to keep track of how many rows we have generated so far so obviously we set it to zero because we start with zero rows generated now this is the main part this is where the magic is done a wild Loop so we generate the data in batches until we reach the desired number of rows so this keeps running while generated rows is smaller than desired rows so you know the user obviously sets the desired row so you decide how many rows you want let's say let's say you want 5,000 right so as long as we have generated less than 5,000 rows this Loop will keep running so first off we calculate how many rows to generate in the next badge so we basically set the minimum value either batch size or this this is only for that you know when we're approaching the end it might be U less than the badge size so this is obviously the main part here we create a variable and we call the generator agent and we pass it everything right the result of the analysis from the an analyzer agent the sample data in the string format and how many rows it should generate then we append the data meaning we add it to our file which only has headers you know when the first time it runs it only has headers but then every time it runs again it already has some data so we do save to CSV again we this time we don't pass an empty string this time we paste the generated data the output from the generator agent again output file but we don't need to include the headers because we've already done that and then we simply update the generated rows because we need to keep track of this integer other it would run forever it would just the wild Loop would never end right right so we need to upgrade it and we just do plus equals which means you know we add the rows to generate so how many rows were generated in this uh run in this badge we simply add it to the number of generated rows in total and then we simply print out the progress update so print generated number of rows out of desired rows beautiful and the last thing we need to do is inform the user that we're done so when we're done it's going to print out this state M all right so our agent is finished but before we can test it we actually should build the docker container first and that is because as you can see we've already uh you know we've already built it with Docker containers inside in mind so you'll have you would have to change all of this um you know the the files if you wanted to run it locally but this is built for containers so let's build the docker file for the agent okay so again let's use let's use this right uh I have a project I have a python project and I need your help to build a Docker file for it here is the code and I'm going to show you actually a cool thing that many people don't know variables inside of the enthropy console so we have the code here and actually let me take a screenshot um let me take a screenshot of our Explorer of all the files we have inside right I'm going to do like this boom and it it sees What would have right but here is the code you do this and I put it um just you know so it's organized and this is basically variable so we do code and then if I want to run it it's going to ask me for the variable right so here I do the agents. py it's going to be set as the variable boom now it's green so it you know sees it um I can say on the screenshot you see all the files in my project and we also uh uh um we can do this um the actually you know what I can just give it all the files whatever the the only thing in my requirements. EXT is anthropic what else it needs to know you just give it everything right I can say like I've built the project with python 3.11 you give it all of the information you have right uh let's say okay the environment variable right um I do I don't want to include the EnV file in the python I mean in the darker image so it will exclude it it will ignore it and it will do that by its own so you know I'm just specifying it let's see okay and that could be it let's see okay do you need to know anything else from me if not uh write the docker file and again I'm just going to use Sonet to help me write the docker file right so based on the information provided I can create a Docker file for the project and as you can see this time it's a bit more bit more long bit longer because we have we have more complicated project but that's fine because I didn't write it keep in mind I didn't write it I just had it right for me so okay let's delete this let's change this up so you know Pon 3ot 11 slim same working directory um it takes all the requirements and copies them into container then it installs all the dependencies then it copies the Python scripts creates a directory for the data and sets the environment variable for python uh I don't know if we need this unbuffered mode uh I'm not sure okay wait maybe let me change this the code will ask the user to input their their own their own API key okay maybe I I should have clarified that we'll see we'll see if the docker changes in any way yeah it it removes that line so yeah even simpler beautiful but yeah as you can see uh 1 2 3 4 5 six seven seven lines and we have the docker file finished so now let's build the docker image all right so let's see if um yeah Sonet gave us the instructions how to build this image all right so super simple we can name it like Docker agent whatever but yeah let's pull up the terminal Docker build build and let's do Docker agent agents and Dot this is going to build the docker image for this last time it took 1.7 seconds but obviously this time we have a bigger project more dependencies more lines of code and it's finished how how many 9 seconds less than 10 seconds beautiful so now we can run the docker container I should probably specify this like also give me a do docker ignore file first because the docker ignore file which we haven't yet created new file. Docker ignore this will tell Docker what it should not package in the image and in the container right so we don't want the environment file to be there as you can see um we have a bunch of stuff so yeah okay Docker ignore environment and then um EnV and that git ignore yeah if you if you had it you know connected to GitHub it would not get the git file so this is good we have the docker ignore file beautiful um I'm going to copy the docker file because I've already made it so this is the docker file that I've pre-prepared as you can see basically two lines more we expose the port and we do copy everything from C current directory and then we also in the PIP install we install all of the requirements which in this case it's only anthropic but let's say you used um an agent framework crei you would have crei in here right so all of the envir all of the environment all of the requirements are in this text file so we install them so this is super simple so now uh let's build it out Docker buildt and we do Docker agents Dot and this will overwrite the current image we'll update it right based on the docker file so we can actually see it inside of our little app here Docker desktop we he are the images right 0 seconds ago created dock agents status unused so we have haven't used it yet it's 178 Gaby megabytes sorry that would be pretty crazy Yeah 178 megabytes Docker agents but now we can run it right so again let's let's open up a completely different terminal one we haven't used yet let's do anaconda prompt so as you can see we are in base no environment we are not in the same directory what you need to do is you need to run it because we need to give it a vol what's call it volume right because okay I'm going to explain this here we have volumes in here right and basically containers can use volumes to store data right so we can create a volume here we can do um CSV files I'm going to show you how to do Let's do let's do files whatever data sets data sets Okay create and here this is a volume where we can put inside some files now you can do this either through the docker desktop app or you can just do it from command line um I'm going to show you how to do it from the command line from the terminal because when we're launching you can do it like a parameter when you're launching the Docker container so you do Docker run and now we do need to do it because this is a iterative it needs to get the input right if you remember in our code we ask for input multiple times so for example here we need the name of the CSV file and then we ask for desired rows how many rows they want to generate so we need to to be in interactive mode now we need to do WV which sets the volume and you might be like okay where do I put the volume okay so you need to create a folder you obviously you can use the volumes in the app but I'm just going to show you how to do it through a default folder right so here I have a simple folder on my PC Docker and I have the files here so uh you can obviously put your own file here that you created with the system I told you either with cgbd or Sonet but basically here you would put the you would put a test file so all of these are test files customer service emails uh c yeah C okay so these two I have test files and now we can access these when we give it the directory so the way to do that is you right click on the file and you click on details I mean actually it's in general so here the location this is the exact location of the file so you copy this and you put it in here and then you do colon slash appdata and then you do the docker image so we do Docker agents and that should be it right let's do enter beautiful so it wants our API key and the reason for that is because uh it doesn't know the environment variable so we have the API key in here but it we we put it into the docker ignore so the the that EnV file is ignored meaning it's not built into our image meaning because of this line of code at the start if you have a good memory you remember if there is not um the anthropic API key in the environment enable we ask the user for the key so this is working as exactly as intended so let's copy the Key contrl C uh in the terminal you actually cannot do control V you have to right click enter now we need to enter the name of our CSV file file so we have uh two files in this folder test input and customer service we can actually test both you know to see that the agent works well we do test input. CSV you have to put it exactly don't make a mistake here number of rows I'm going to do 65 and the reason for that is you know I'm doing 30 so we're going to see if it can run three times we're launching the team of Agents so now fingers crossed we get an anthropic API response okay so this is the analyzer agent as you can see um analyzer agent output I'll provide a concise summary okay so formatting it analyzed how the data set is formatted what the data set represents the data set is a catalog of various cyber security threats yes and their Char characteristics how the data how new data should look beautiful and now uh generating new data generated 30 out of 65 so if we go into the folder we should see a new data set beautiful we see a new data set. CSV which okay it's finished so that was pretty fast I mean only 65 rows but if we go in here we have a brand new data set of 65 obviously plus one is the header new cyber security threats that we could use to train our find we could fine tune any llm with this okay so let's double check that it works by doing the different file right so do CLS and again Docker run erative and then volume and for the volume we need to give the folder so again um this time we'll do the customer service one I'm going to delete it because we're going to create a new one so copy the location of your file wherever your file is stored copy that boom then do semicolon slab SL dat if you remember this is exactly what we did in the code right so let me pull it up here uh SLA SL data so this is just you know doing what we have in the code that way it's in the same directory and then you simp simply put the name of the docker image in this case Docker agents and if you forgot what your image is called open up your Docker desktop click on images Docker agents in use boom and you can see the containers here created four minutes ago um yeah so Docker agents and hit enter boom it needs the API key so let's create a new one blah blah blah create a key copy key right click enter CSV file let's do the different one okay so let's close these uh yeah let's do the customer service CSV so customer service. CSV boom let's do more arows let's do 110 this time uh okay and it's launching our team of Agents so this is so good because it's in a container meaning you can run it yourself so I'm going to put this actually on dockerhub which let's do that now doer H and you know what let's um let's use let's use our friend by the way this I what I just did is I added the conversation right so right now it's not adding automatically you might be used from chbt that is like automatically storing history it's not doing that in the console and that's because you can change the prompt and like only add it when you're happy with it right so if you're happy with this response and you want it to be referenced in all future conversations you simply click on add to conversation it moves it to the left and now you can ask another prompt and it's in the history of the chat so this is you know why the console is more advanced and why you know in chat GPT is automatically saved so people don't have to do this but let's see now I want to make my Docker container available to the public to everyone watching this video shout out let's do especially to ones who subscribe Wing wi subscribe if you haven't already okay how do I do this um tell me how okay I'm I'm going to do um tell me how to use dockerhub I edit this prompt instead of moving that one into conversation because that one had incomplete information so I don't want to move it um into permanently into our chat history okay so we created a dockerhub account you know I just literally used my Gmail super simple it's the same account actually used for Docker log to dockerhub on your local machine dock login okay so let's do that CLS Docker login boom login succeeded okay and that is because we have already Docker installed tag your Docker image your image needs to be tagged with your Docker Hub username yeah so okay I should use the same name so images Docker agents it should be exactly this name right but I would like to use a different name um for the container I make public all right we run it again so this is why why you sometime you often times you don't put the conversation to the history because you update the prom because your prom was incomplete okay so this is how we do it Docker tag Docker agents your dockerhub username which in this case um it's just David Andre 1 somebody took David Andre um unfortunate Docker tag Docker agents and then we do the username right okay slash and then the name we want deviate Onre one slash and I'm going to do data set agent and what it column latest latest yes okay let's do enter okay push detect image to Docker Hub Docker push your Docker username all right Docker push and then David Andre one/ data set agent latest enter once the push is complete your image will be available on dockerhub anyone can now pull and user image with Docker pull okay so let's do that click on your repository uh my profile data set agent beautiful this is the command this is literally the command Docker pull David Andre one data set agent latest so what I'm going to do actually I'm going to go into my Docker desktop delete the containers right so let's delete these two that are based on this image so we have no containers and I'm also going to delete the image by the way boom boom delete this image now in a terminal let me run this and I'm going to pull my own container which is on the docker Hub even though I deleted everything from my computer right so now if I go to Docker um yeah so now I see this um image David Onre data set agent latest so now uh I should be able to run it okay so so let's try it let's try it this is so good so Docker run obviously iterative and then we do the volume which again we need to get the file so uh this is closed and this okay so again let's do this the customer service one boom boom colon app SL dat uh uh and now we we need to change it up because I'm not using you know it locally I'm not using my local one like I would do like hello Docker I'm using this one right so we have to do exactly this I have to do David Andre 1/d set agent since uh it's no longer I'm using you know the one I downloaded from the docker Hub enter and inic API key okay dude this is so exciting it's kind of crazy let me let me get a new one okay boom again create a new API key create a key copy paste it in enter name of the CSV file customer report CSV customer service oh my God okay whatever um that's a mistake on my part yeah customer service 500 let's do big time and we're going to launch our team of agents and this is it this is it you can run this on your own machine because it's on dockerhub you can pull this repo and run this team of Agents as you can see I'm generating a brand new data set for this time is the customer support before is the cyber security you can be do it for anything any use case you have in your business and you can have it automatically running generating data synthetic data for LM fine tuning so wow this is actually amazing guys if you want to learn more about Ai and Docker I'm going to leave this below how to containerize a generative AI application Docker has some amazing resources about AI definitely read this in check this out it's going to be linked below the video first link is going to be Docker Hub second link is going to be this uh documentation so make sure to read it thanks doer for sponsoring this video and thanks to all of you for watching Until the End have a great day
Info
Channel: David Ondrej
Views: 38,258
Rating: undefined out of 5
Keywords: David Ondrej, david ondrej, AI, ChatGPT, artificial intelligence, ai, Artificial Intelligence, OpenAI, chatgpt, chat gpt, Chat GPT, Elon Musk, AGI, midjourney, david ondrej podcast, GPT-4, GPT, AI revolution, new society, david ondrej new society, david ondrej community, make money with AI, AI Agents, ai agent, Docker, docker, docker desktop, docker tutorial, docker ai, docker container, docker containers, sonnet 3.5, claude 3.5 sonnet, Anthropic, API, Python, VS Code, Dockerfile
Id: AhPXGKG4RZ4
Channel Id: undefined
Length: 51min 58sec (3118 seconds)
Published: Thu Jun 27 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.