Build & Deploy a Python AI Agent in 20 Minutes

Tech With Tim · Intermediate ·📰 AI News & Updates ·7mo ago

Key Takeaways

Build and deploy a Python AI agent using FastAPI, OpenAI, LangChain, and Vercel in 20 minutes. The agent is a tool calling agent with LangGraph that uses ChatOpenAI with the GPT-4 model for LLM. The application is deployed to Vercel and can be used as a chatbot agent with GPT-like responses.

Full Transcript

In this video, I'll show you how to build and deploy an AI agent in Python in a matter of minutes. Now, we'll not write every single line of code completely from scratch, but I will cover all of the important concepts, and all the code and demos that you need for this video if you want to follow along exactly will be available from the link in the description. What I'll be doing here is showing you the simplest possible way that you can actually deploy your Python application out. So, if you build an AI agent, someone else is actually able to use it. With that said, let's hop over to the computer and go ahead and get started. Okay, so the first thing that I quickly want to go over is just the architecture and the different tools that we'll use here. Once we understand that, we'll get into the setup and I'll walk you through the exact tutorial. Now, if we want to deploy something, typically we need to know what we want to deploy. Now, you can build a simple Python AI agent, but one of the easiest ways to access that, if you're not on your own local computer, is through something like a website. So, what we'll do for this video is we'll build a simple web interface for interacting with our AI agent, just like you would have for something like ChatGPT. We'll just have a simple chat box, and we'll have the ability to type in a prompt, essentially send a message to the agent, and then get a response back. Now, in order to do that, we're going to use a variety of tools. The first tool that we'll use is FastAPI. This will allow us to create a really simple API so we can communicate with our agent from this web interface, or even from a different interface if we wanted to build that in the future. We also need to have the agent. So, for the agent, we will use OpenAI. That'll be our LLM, so we'll have an OpenAI API key, which I'll explain later on. We'll use LangChain, and we use that in combination with LangGraph, which allows us to make a really simple tool calling agent that can actually go into the world and perform actions. Then, within FastAPI, we're going to use a really simple HTML template and a little bit of JavaScript code, which you can just copy from the link in the description, which will allow us to interact with our backend API, so the thing that actually kind of serves our AI agent, and we'll deploy all of this using Vercel, which is completely free, can be automated, and is very easy to set up. Okay, so that's the tooling. Now, what I'm going to do is go into the code editor {slash} IDE. We'll start setting it up, and we'll go from there. So, in order to get started here, open up any editor or code editor that you would like, and just create and open a new folder. In my case, I've just opened one here called deploy AI agent. Now, before we can do all this setup, we do need to make sure that we have Node.js installed on our computer. You'll see why in just 1 second. So, you can download it from this link right here. And then, what we're going to do is install the Vercel CLI tool. Now, what this tool will allow us to do is just deploy our application directly from the command line, so you won't need to create something like a new GitHub repository if you don't want to do that. Now, what I suggest is creating a new account on Vercel. I'll leave a link to it in the description. Again, it is free. It is very straightforward to do so. And then, once you've done that, what we're going to do is go to this right here where it says installing the Vercel CLI. Change this to NPM, which we'll now have installed if we installed Node.js. We'll just copy that command, and then we'll go back to our terminal here, so I'll just open that up inside of Cursor, and just paste that. So, NPMI {dash} G, which stands for global, and then Vercel, and that will install the CLI tool for us. Okay, so that was just installed. Now that we've done that, we'll simply just type the Vercel command to ensure that's working. What it will do, if it's your first time using this, is it's going to ask you to sign in and to go to the browser. So, sign in to your um Vercel account, and then you can just exit out of this command. So, I'm just going to hit control C, which will just quit out of that command cuz I'm already signed in and I've installed this tool in the past. Okay, so now we're kind of all set up with Vercel. What we're going to do is from within the directory where we want to create our project, so in this case, I'm in this deploy AI agent, I'm going to run the command, which is VC, standing for Vercel, and then a knit, and then FastAPI. Now, when I do that, what it's going to do is just create a boilerplate FastAPI application for me in this FastAPI project. What I'm going to do is I'm just going to copy the contents of this and just pull this into the root of this directory, so I'm just going to delete this FastAPI [music] folder. So, essentially, I have them all in this deploy AI agent folder. You don't need to do that, but I just want to have it in one directory. I don't want all these nested directories, so I've just pulled out all of these files into my main deploy AI agent directory. Okay. So, from here, you'll see that we have this main.py file. We can actually just go in here, and we can delete everything for right now, because we'll write that from scratch. Same thing with the readme. We don't need this. We can just delete it. [music] Perfect. Now, let's continue with the rest of the setup just after a quick word from today's video sponsor, boot.dev. It's an online learning platform designed specifically for backend development, and it approaches learning in a way that's far more interactive than the usual video-based courses. Rather than having you sit through hours of lectures, boot.dev puts you straight into hands-on coding. You'll work directly in your browser, building real projects while learning backend fundamentals like APIs, databases, and server-side logic using Python and Go. Now, what makes it stand out is the way that it borrows from game design. You'll progress through levels, unlock new content, and keep your momentum up as you go. The platform is filled with exercises and practical challenges, so you'll end up writing a lot of code, which is exactly what helps you improve. Now, all of the core content is free to access, and if you decide to commit to the annual plan, you can use the code techwithtim to get 25% off your first year. I've been going through it myself lately, and honestly, it's surprisingly addictive. Thanks to boot.dev. Now, let's get back into it. All right, so what we're going to do now is go into our requirements.txt, and we're just going to add the different Python packages that we'll need here for the rest of the video. So, we're going to say that we need Jinja2. This is a templating engine, engine, sorry, for FastAPI that will allow us to actually render some HTML code to the screen. We're going to have LangChain, cuz we're going to use that for AI agent. We're also going to have LangChain OpenAI, which will allow us to use the OpenAI package. We're going to have LangGraph, and then we're going to have python-dotenv, which will allow us to load in environment variables. Now that all of these are installed, we're good to go, or in the requirements.txt, at least, and we can close that. Okay, what we're going to do is we're just going to make a new file here called agent.py. And what we'll do is we'll write the AI agent first, then we'll write kind of the backend, or the API that will serve the AI agent so we can deploy it. So, I'm just going to copy in a few code snippets here. I will explain them, but I don't think it's too valuable for me to write it line by line, and if you want this exact code, I will have a GitHub repository linked below that you can check out where you can just copy all of the code. Okay, so what I'm going to do is bring in my imports here. Because we're going to make an agent in Python, we're going to bring in ChatOpenAI, which is going to use the OpenAI LLM. We're going to bring in tool, because we're going to make this a tool calling agent that has the ability to take some actions. And then, we're going to use LangGraph, which is just the easiest kind of pre-built agent that we can bring in that will automatically be able to call tools. Now, because I'm talking about tools, I do want to start with those. Now, a tool in our context is just going to be some function that the agent will be able to call. It's very straightforward, but what I can do is just copy in two tools that look like these, and these are simple functions that have a docstring, as well as annotated parameters that explain what they do. So, we have a tool called read_note. What this does is very simply open a file and try to read a note, okay? Then, we have write_note. What this does is open a file and try to add some content to the file. So, I'm just showing you two really basic tools where we have an agent that will be able to now read a note and write a note so we can kind of store some information persistently. This is like the most basic tool you could possibly create. You can chain them and make your own by following this exact same format. You decorate the function with this at_tool_decorator, which we imported right here. Name it something that's reasonable, because the LLM's going to look at that name to know if it should call it or not. Write a description on what the tool does inside of a docstring like this, and then put the types of the parameters, like what the what is it called, sorry, tool is going to accept, and what the tool is going to return, as well as just parameter names that make sense, so the agent knows which one to call and how to call it. Okay? So, now that we've done that, what we're able to do is just create a simple list of tools. So, we're going to say tools is equal to, and then in a list here, we have read_note and write_note. We're then going to create a system message. So, my system message is going to be this. You can change it to be anything that you want. This just explains to the agent what And then, we're going to initialize the agent and the LLM. So, to do that, we're going to write these lines where we're going to say LLM is equal to ChatOpenAI. We're going to put the model that we want to use. In this case, I'm just using GPT-4. We put the temperature. The lower the temperature, the less random it will be. And then, we're able to create an agent that combines the LLM, the tools, and the prompt, or the system message. Don't um mix this up with the prompt the user will send. This is just the first prompt that the agent will look at so it understands how it should be performing. Now, with all of this, we have the ability to run the agent, and the way that we can do that is with a function like this. Again, you can copy all of this from the link in the description, where we can simply run this function with some user input. What it will do is attempt to invoke the agent. When we invoke the agent, we pass a list of messages we want it to respond to. In this case, we just have one message, so I say, "Okay, the message is, you know, this right here," where the role is the user, and the content is whatever we had as the parameter right here. And then, we're just going to return whatever the response to that particular message is, which we can get using this format. If there's an error, then we'll return that. That's it, okay? That's our AI agent, and we can quickly test that if we want by just calling the run_agent function, and passing something in, like, you know, "Hello, how are you?" Okay? Now, in order for this to work, though, we are going to need an OpenAI API key, and we're going to have to store that inside of a .env file. So, we're going to create a file called .env, and we're going to put inside of here open AI _api_key and we're going to place an open AI API key here, which I will show you how to get. So, in order to get an open AI API key, you'll need to go to this link right here, which is platform.openai.com/api-keys. You can then press on the button create new secret key. This will require that you have a credit card on file. It will cost a few cents. It's very inexpensive if you want to use this. You also could use a local LLM. You can replace this with whatever you want. is just the absolute easiest way to do it. So, I'm going to go create new secret key. I'll just go with test or something or test two cuz I already have one called test and I will delete this key afterwards so that you guys cannot use it. Okay, so I'm going to copy that. I'm going to paste that inside of my environment variable file. And now what I'm going to do is just add one line of code to the beginning of this file where I'm going to say from .env import load.env and I'm going to call the function load.env by simply adding these two lines. I'm now going to load in the environment variable that I defined inside of this file. And what we're able to do now is run this code. Now, we will need to install all of the requirements. So, what we could do is say pip install -r and then requirements.txt. If you want to use a dependency manager, go ahead and do that. If you're on a Mac or Linux, you can try the pip 3 command. This should install all of the dependencies into your global Python kind of interpreter, which is not always the best practice, but for this video just really quickly, that's what we'll do. And then we can simply run this agent.py file and see if it works. So, I'm going to say python and then agent.py. Again, if you're on a Mac or Linux, you would change this to python 3. So, I'm going to go ahead and run that and we're hoping that we're just going to get some kind of response. And actually just gave us a warning here on kind of a deprecation thing. We don't need to worry about that. But, what I do need to do is print out whatever this was cuz if we don't print it, then I'm not going to see what the response was. So, I'm just going to print the response here. Let's wait and see if we get it. And it should tell us something that says hello, I'm an assistant and you can see that it is indeed working. Okay, so we're going to remove this print and this function call. And what we're going to do now is move on to write the API so that we can actually serve this content on some kind of front end and then we'll be able to deploy it. All right, so now we're moving into our main.py file. From here, we're going to have a few imports. Again, I'm just going to copy in the code just to keep it a little bit faster. So, what I'm going to say is from fast API import these things which we need for setting up the API. I also don't want that open. I'm going to bring in this Jinja templates, which is going to allow me to render some HTML. I'm going to bring in a base model from Pydantic. You'll see why we need that in a second. And then from my agent file that I've written right here, I'm going to bring in this run agent function, which will allow me to, well, run the agent. Okay? Now, what I'm going to do is initialize the application as well as the templates. So, what I'm going to do is say app is equal to fast API and I'm going to say that I have these HTML templates that are inside of this directory called templates. That means that I should make a new directory called templates, which is where I will store the HTML that will kind of put for the front end and that will display on the screen. Now, what we're really going to quickly do is also just define two request and response models. Now, this is going to allow us to kind of define the type that our API is going to accept when we invoke the agent. If you're unfamiliar with an API, essentially this is a service that we're able to provide to something like a web application where it can call some route. In this case, it can ask, for example, for the front end, what does it look like? Give me that HTML code. Or it can ask to invoke the agent. So, we're just writing essentially the request type and the response type that will happen from our API for one of the particular routes. This is not a full API tutorial. I know it's a little bit of a vague explanation, but the API allows us to kind of serve and deliver content in a protected way where a user calls some path like, you know, /api/agent or something and then they get some response, which is whatever the agent said. Okay? So, what we're going to do now is we're going to define our home route. So, this home route is what's going to serve the HTML template. So, what we're going to do is just say, okay, app.get. We're going to put a slash. We're going to say async define home and then this is going to take in some request. And what we're going to do is say return templates.template_response and then we're going to have the index and then the request. Now, what this is going to do is it's just going to render an HTML template for us called index.html so it will show that on the screen. We'll be able to see that in 1 second, but first we'll need to actually write the index.html file, which we'll do in 1 minute. Okay, so this is like the home route for actually seeing the website. Then we're going to have another route. This is going to be at app.post, which is the HTTP method that we're going to use. We're going to call this /agent and what this is going to do is invoke the AI agent with a prompt. So, if someone calls this, it's going to give us a response that tells us what the AI agent said. So, essentially all we're doing is calling this run agent function with whatever the prompt was that the user passed into this function and then we're going to get the result. You can make this as complicated as you want, but these are the only two routes that we need for our API and that pretty much completes the code. Okay. Now, the one thing that we're missing is this index.html file. So, what we'll do is we'll go in this templates directory and we'll just call this index.html. The way that it works inside of languages or sorry, frameworks like fast API is that you can have something called a template. And the template is essentially just an HTML file that's written in a certain format, looks very similar to normal HTML, that allows you to render things like variables onto the screen. In our case, we're not going to use any fancy templating syntax, but what I'm going to do is I'm just going to copy in a very slim 85-line HTML file, which again, you can find exactly from the link in the description in case you want to copy it precisely. It has a little bit of CSS styling. We just define the title of the webpage and then we have a really simple form. The form just has a text area and a button and then we have some div where we'll render the response. As simple as you can possibly get. And then I have a little bit of JavaScript code. You all zoom out so you can read it all. Where essentially what I'm doing is I'm getting the form. I'm looking for the user's prompt input. I also I'm just getting the div for the response so I can render the code there. When the form is submitted, what I'm going to do is I'm just going to put a little bit of loading indicator so we can see what's going on. I'm going to send a request to my back end, so to this route that we just wrote. I'm going to call the /agent endpoint with the post type. I'm going to pass in the prompt the user provided and then I'm going to get the response. Now, if the response is valid, what I'm going to do is I'm just going to put that response inside of the response div so the user can see it. That's it. Just allowing me to have some dynamic kind of content on my site. So, when you press a button, we send a request. This endpoint gets called, which then goes here and calls this function, gets the response from open AI, gives it to us and puts it on the screen. That's literally all that we're doing. Now, the only thing we need to do if we actually want to test and run this application is we need to import Uvicorn from the top of this file. And then we need to just paste this line right here, which is uvicorn.run and then app, host, and port and just put these exact same values. When you do that, it will now be set up to run and what we're able to do is go here and just run the code. So, we can say python and then main.py. Again, python 3 if you're on a Mac or Linux. Go ahead and hit enter and then it should run the server for us. If we open this now by just copying it into our browser, so let me do this here and just open it up. We should see that we get something. If for some reason it gives you an issue with this is 0.0.0, just put localhost:8000 and it should pop open the UI now and we can say something like hello world, can you save a note saying hi? And then just go ahead and press on send. Uh and let's see if we get a response back. Okay, give it a second. It says I have successfully saved your note saying hi. And if we go here, we'll see we have this note file now that says hi. So, the agent is working. We're able to use it from the browser. Very straightforward again, we just need to run that application. Now, what we're going to do is deploy this, which you're going to see is extremely fast to do. So, what I'm going to do is I am just going to get out of this by hitting control C. That's going to shut down the server for us. And I'm just going to remove this Uvicorn line by just commenting it out and just commenting the import because we're not going to need this when we do the deployment. Now, I can close everything else. So, just close it all. And what we're going to do is go into our terminal now and we're going to run a command that essentially just deploys this application to Vercel. So, to do that, we can simply type vc and then deploy. Now, when we do that, it's going to ask us if we want to set this up and deploy. We're going to type yes. Then we are going to go through here and pick what team. So, I guess I have some teams. I'm just going to go to my projects. Again, it's free to do this. We are not going to link this to an existing project, so we'll type no. For the name, whatever you want, so I'll just call it deploy AI agent or something. Okay? In which directory is the code located? You don't need to type anything cuz it's in the root directory. So, we hit enter. It says, do you want to modify these settings? We're going to type no. Okay, do you want to change additional settings? We're going to type no or just n. And then it's going to deploy the project for us and create a new file or create a few new files, sorry, that we're going to have in this directory. Now, what it's going to do is give us a few links here so we can actually check out the deployment. So, what we'll do is we'll just go to this inspect link that it's provided and we'll just open this up in our browser. So, I'm just going to open it and we should be able to see the deployment and you can see that it looks like it was deployed successfully. So, let's open this up. And when we just press on that preview, we now can type something. So, maybe we type something like hello world. And let's actually see if this works and you can see that it's working completely fine. Now, one thing that you might want to be a little bit careful of is that we actually, when we did this, deployed this .env file, which contains our environment variables. Now, while you can do that, it is possible that you could leak this environment variable file when you do this deployment due to how Vercel does the employment. So, one thing that we might want to do for future deployments just to make sure that we're not leaking these values is just create a new file called dot and this is going to be vercel ignore. Okay, so let's do this. Inside of this file, we're just going to type something which is dot env. That just tells this vercel to ignore this environment variable file. And now when we deploy, it will not deploy the environment variable in this file. Now, the reason we're going to do that is because we will just manually add the environment variable to the deployment in an encrypted and in a safe way. So, in order to add the variable properly without deploying this environment variable file, what we're going to do is just type vc and then we're going to type env and then add. I believe that's the command. We're going to see if that's the correct one in 1 second. And then we're going to put the name of the variable we want which is openai_api_key. So, if we do that, okay, looks like that is the correct command and we type enter. We can now copy our openai API key. Maybe we want to use a different one for deployment, production, whatever. So, I'm going to paste that in right here. And then what I'm able to do is choose where I want to use this key. So, do I want to use it in the production, preview, deployment? I just want to use it in all of them. So, I'm just going to select all of these by going over them, pressing space, and then pressing enter. And now it's added these variables. Now, what I can do is redeploy the project. So, I can say vc deploy. When I do that, again, it's just automatically going to deploy this for me. And then I'm able to view this in my account as well as just by looking at the preview links right here. Okay, there's also a few other commands if you want to look at like the logs or something. So, what we'll do is again, go back to the inspect link, just open this up, and then we should see that we have the preview. So, let's open it here and we can say, you know, save a note for me or something. Save a note that has a random fact. Okay, let's go ahead and send that and see if this works for us. Okay, give this a second cuz sometimes it is a little bit slow and it says there's an issue with the notes, you know, I can't find the file system, it's read-only. Okay, so there might be a problem with using those particular tools with vercel. To be honest with you, I didn't try the note um component because I think the file system for vercel, especially on the free tier, is not set up properly. However, we could just change the tools to be literally anything that we wanted to, right? So, if we go back to the agent, you can just make any tools and just change them in this list and then the agent will just be able to use them. So, you know, this was just a simple example. You don't have to use these, I assume. None of you are wanting these in production anyways. So, you can just change the tool to something else that maybe like grabs the weather or calls another API or does anything pretty much other than dealing with the file system and then that should work. But, I can also just say, "Hey, how are you?" and just use it like a normal, you know, kind of chatbot agent like I would use GPT. And you can see, you know, it gives me the response. And anyways, you get the idea. I'm just trying to give you kind of a setup and a base here for how you can actually deploy an AI project in Python as fast as possible. This is not the most secure, it is not the most scalable, but if you're just trying to look to get a hobby project up and running as fast as possible, you want to demo it to other people, I think this is a pretty useful guide/tutorial that hopefully got you there. So, with that said, guys, I'm going to wrap up the video. If you enjoyed, make sure to leave a like, subscribe, and I will see you in the next one. [music] >> [music]

Original Description

Click this link https://www.boot.dev?promo=TECHWITHTIM and use my code TECHWITHTIM to get 25% off your first payment for boot.dev. In this video, I'll show you how to build and deploy an AI agent in Python in a matter of minutes. We'll not write every single line of code completely from scratch, but I will cover all of the important concepts and all the code and demos that you need. Want to make real money with coding? I share high-signal insights on careers, monetization, and leverage in my free newsletter. Join here and get my guide How to Make Money With Coding instantly: https://techwithtim.net/newsletter 🎞 Video Resources 🎞 Vercel: https://vercel.com/docs/cli?package-manager=npm NodeJS: https://nodejs.org/en OpenAI Platform (API Keys): https://platform.openai.com/api-keys Code In This Video: https://github.com/techwithtim/BuildAndDeployAIAgent ⏳ Timestamps ⏳ 00:00 | Overview 00:33 | Tools & Architecture 02:14 | Setup & Install 06:30 | Writing the Agent 12:09 | Writing the API 15:00 | HTML Template 16:48 | Testing the Code 18:00 | Deploying to Vercel Hashtags #Python #AIAgents #SoftwareEngineer
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Tech With Tim · Tech With Tim · 0 of 60

← Previous Next →
1 A* Path Finding Algorithm(Visualization)
A* Path Finding Algorithm(Visualization)
Tech With Tim
2 Python Programming Tutorial #1 - Variables and Data Types
Python Programming Tutorial #1 - Variables and Data Types
Tech With Tim
3 Python Programming Tutorial #2 - Basic Operators and Input
Python Programming Tutorial #2 - Basic Operators and Input
Tech With Tim
4 Python Programming Tutorial #3 - Conditions
Python Programming Tutorial #3 - Conditions
Tech With Tim
5 Python Programming Tutorial #4 - IF/ELIF/ELSE
Python Programming Tutorial #4 - IF/ELIF/ELSE
Tech With Tim
6 Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Tech With Tim
7 Python Programming Tutorial #6 - For Loops
Python Programming Tutorial #6 - For Loops
Tech With Tim
8 Python Programming Tutorial #7 - While Loops
Python Programming Tutorial #7 - While Loops
Tech With Tim
9 Python Programming Tutorial #8 - Lists and Tuples
Python Programming Tutorial #8 - Lists and Tuples
Tech With Tim
10 Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Tech With Tim
11 Python Programming Tutorial #10 - String Methods
Python Programming Tutorial #10 - String Methods
Tech With Tim
12 How to Overclock a NVIDIA GPU
How to Overclock a NVIDIA GPU
Tech With Tim
13 Python Programming Tutorial #11 - Slice Operator
Python Programming Tutorial #11 - Slice Operator
Tech With Tim
14 Python Programming Tutorial #12 - Functions
Python Programming Tutorial #12 - Functions
Tech With Tim
15 Python Programming Tutorial #13 - How to Read a Text File
Python Programming Tutorial #13 - How to Read a Text File
Tech With Tim
16 Python Programming Tutorial #14 - Writing to a Text File
Python Programming Tutorial #14 - Writing to a Text File
Tech With Tim
17 Python Programming Tutorial #15 - Using .count() and .find()
Python Programming Tutorial #15 - Using .count() and .find()
Tech With Tim
18 Python Programming Tutorial #16 - Introduction to Modular Programming
Python Programming Tutorial #16 - Introduction to Modular Programming
Tech With Tim
19 Python Programming Tutorial #17 - Optional Parameters
Python Programming Tutorial #17 - Optional Parameters
Tech With Tim
20 Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Tech With Tim
21 Python Programming Tutorial #19 - Global vs Local Variables
Python Programming Tutorial #19 - Global vs Local Variables
Tech With Tim
22 Python Programming Tutorial #20 - Classes and Objects
Python Programming Tutorial #20 - Classes and Objects
Tech With Tim
23 Cool VBS Script to Prank Your Friends!
Cool VBS Script to Prank Your Friends!
Tech With Tim
24 How to Overclock an AMD GPU
How to Overclock an AMD GPU
Tech With Tim
25 Best GPU'S For Mining Ethereum (2018)
Best GPU'S For Mining Ethereum (2018)
Tech With Tim
26 Recursion and Memoization Tutorial Python
Recursion and Memoization Tutorial Python
Tech With Tim
27 Ethereum Mining Rig - Hardware Guide
Ethereum Mining Rig - Hardware Guide
Tech With Tim
28 Pygame Tutorial #1 - Basic Movement and Key Presses
Pygame Tutorial #1 - Basic Movement and Key Presses
Tech With Tim
29 How to Install Pygame (Windows 8/10)
How to Install Pygame (Windows 8/10)
Tech With Tim
30 How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
Tech With Tim
31 How to Mine Ethereum 2018 - WORKING (Super-Easy)
How to Mine Ethereum 2018 - WORKING (Super-Easy)
Tech With Tim
32 Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Tech With Tim
33 Pygame Tutorial #2 - Jumping and Boundaries
Pygame Tutorial #2 - Jumping and Boundaries
Tech With Tim
34 Pygame Tutorial #3 - Character Animation & Sprites
Pygame Tutorial #3 - Character Animation & Sprites
Tech With Tim
35 Pygame Tutorial #4 - Optimization & OOP
Pygame Tutorial #4 - Optimization & OOP
Tech With Tim
36 OBS Studio Tutorial - Best OBS Settings
OBS Studio Tutorial - Best OBS Settings
Tech With Tim
37 Linear Search Algorithm - Python Example and Code
Linear Search Algorithm - Python Example and Code
Tech With Tim
38 Make Any Mic Sound AMAZING! (WITH OBS)
Make Any Mic Sound AMAZING! (WITH OBS)
Tech With Tim
39 Binary Search Algorithm - Python Example & Code
Binary Search Algorithm - Python Example & Code
Tech With Tim
40 Pygame Tutorial #5 - Projectiles
Pygame Tutorial #5 - Projectiles
Tech With Tim
41 Pygame Game - Mini Golf
Pygame Game - Mini Golf
Tech With Tim
42 Pygame Tutorial - Projectile Motion (Part 1)
Pygame Tutorial - Projectile Motion (Part 1)
Tech With Tim
43 Pygame Tutorial - Projectile Motion (Part 2)
Pygame Tutorial - Projectile Motion (Part 2)
Tech With Tim
44 Pygame Tutorial #6 - Enemies
Pygame Tutorial #6 - Enemies
Tech With Tim
45 Pygame Tutorial #7 - Collision and Hit Boxes
Pygame Tutorial #7 - Collision and Hit Boxes
Tech With Tim
46 Pygame Tutorial #8 - Scoring and Health Bars
Pygame Tutorial #8 - Scoring and Health Bars
Tech With Tim
47 Cloud Mining vs. Hardware Mining - 2018
Cloud Mining vs. Hardware Mining - 2018
Tech With Tim
48 How to Install Pygame on Mac OSX (Fast-Simple)
How to Install Pygame on Mac OSX (Fast-Simple)
Tech With Tim
49 Pygame Tutorial #9 - Sound Effects, Music & More Collision
Pygame Tutorial #9 - Sound Effects, Music & More Collision
Tech With Tim
50 Pygame Tutorial #10 - Finishing Touches & Next Steps
Pygame Tutorial #10 - Finishing Touches & Next Steps
Tech With Tim
51 How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
Tech With Tim
52 How to Create a Button in Pygame [CODE IN DESCRIPTION]
How to Create a Button in Pygame [CODE IN DESCRIPTION]
Tech With Tim
53 Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Tech With Tim
54 Pygame Side-Scroller Tutorial #2 - Random Object Generation
Pygame Side-Scroller Tutorial #2 - Random Object Generation
Tech With Tim
55 Pygame Side-Scroller Tutorial #3 - Collision
Pygame Side-Scroller Tutorial #3 - Collision
Tech With Tim
56 Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Tech With Tim
57 How to Create A Message Box in Python - Tkinter
How to Create A Message Box in Python - Tkinter
Tech With Tim
58 Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Tech With Tim
59 How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
Tech With Tim
60 Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Tech With Tim

This video teaches how to build and deploy a Python AI agent in 20 minutes using FastAPI, OpenAI, LangChain, and Vercel. The agent is a tool calling agent with LangGraph that uses ChatOpenAI with the GPT-4 model for LLM. The application is deployed to Vercel and can be used as a chatbot agent with GPT-like responses.

Key Takeaways
  1. Open a new folder in the code editor
  2. Create a new account on Vercel
  3. Install the Vercel CLI tool using NPM
  4. Type the Vercel command to ensure the CLI tool is working
  5. Create a new file called agent.py
  6. Define two basic tools: read_note and write_note
  7. Initialize the agent and LLM with system message and prompt
  8. Run the agent with user input
  9. Use FastAPI to set up the API and Jinja2 for templating
  10. Define request and response models for API
💡 The video demonstrates how to build and deploy a Python AI agent in a short amount of time using pre-built tools and services, making it accessible to developers with intermediate level of expertise.

Related Reads

Chapters (8)

| Overview
0:33 | Tools & Architecture
2:14 | Setup & Install
6:30 | Writing the Agent
12:09 | Writing the API
15:00 | HTML Template
16:48 | Testing the Code
18:00 | Deploying to Vercel
Up next
How I Cleared CA Intermediate with ArivuPro! 💯📚
ArivuPro Academy
Watch →