How to Build AI Agents Using Python | AI Agents Tutorial | Build AI Agents Using Python |Simplilearn
Key Takeaways
This video teaches how to build AI agents using Python through an AI agents tutorial
Full Transcript
[music] You have used chat GPT a 100 times. But have you ever wondered what actually is happening behind that one message you type? How it understands your intent, retrieves context and produced intelligent response in seconds. And that's the power of building an AI agent. A system that does not just reply but thinks, remembers and acts. In this course, we will be learning how to build that kind of intelligence step by step. We'll understand exactly how modern AI assistants work behind the scenes and more importantly how to create your own. We'll start with the fundamentals of what an AI agent really is. Then move on to setting up your environment, building your first agent, adding memory, connecting real world APIs, routing task, running parallel operations, and chaining prompts for complex reasoning. And by the end of this course, you won't just have a theoretical knowledge. You'll build a complete fully functional AI interview coach powered by Gemini capable of asking questions, analyzing answers, storing strengths and weaknesses which will be generating professional reports. This course is practical, hands-on, and designed so that everyone with basic Python skills can follow along and create real AI system. Here's a quick quiz for you to answer before we start this course. What do you think an AI agent is? Is it a chatboard that talks? A program that can think, act, and use tools, a robot used in movies? Let us know your answers in the comment section below. Now, before we start coding, let's understand the most important question. What exactly is AI agent? An AI agent is a system that can understand input, think or reason, take actions, learn from interactions, and optionally remember things. Think of AI agent like a smart assistant that does not just chat. It does tasks. It can call an API, fetch weather, understand context, plan steps, analyze response, and make decisions. Examples of some of the AI agents you're already using is Siri or Google Assistants, Chat GBT with tools, recommendation systems, customer supports, and also automated interview trainers. In this course, we are going to build agents like these but customized for your cases. AI agents are the next big wave in automation and productivity. They matter because they can automate repetitive task, make intelligent decisions, work across applications, perform multi-step reasoning and also personalize your responses. They also can handle real world workflows. Companies now rely on agents for customer service, interview screening, scheduling, task, finance automation, and more. Learning this skills gives you a huge edge in 2025 and beyond. Now, don't worry. You don't need to be an AI expert. All you need is a basic Python knowledge, basic understanding of installing libraries, an interest in building AI tools, a free Google Gemini API key, which I'll tell you how to get it, and that's all. If you know how to write simple Python functions, you are ready. Now, before starting, make sure that you have Python installed, which is at least 3.7 plus version. So, for that, just visit python.org.d downloads and you can download the latest version from here. Now how to check Python is installed it's Windows R cmd and you can just give Python and a version should be printed. Here mine is 3.13.7. Anything which is 3.7 plus version works good for this. So after this you have to install few of the Python libraries. So first let's just install OpenAI itself. So it is pip install open AI. So it installs all the packages. Next we have to install some generalpurpose libraries which make HTTP request pip install requests. So let's move ahead with that. PIP install request and next we are using and fast API. So for that we need to install flask. So again pip install flask and also fast API. So pip install fast API. Next we also need env which is for storing your key in which we have to read it in the program side. So for that we have to install python.env. So for that pip install dot python.env. Okay there was an error. So it's env. So since I've already installed this, it's already showing requirements already satisfied. Git is also necessary for version control and cloning repositories. Now you can download git from gcm.com. So this is the interface and here you can see installed for Windows. You can just go ahead and download it. Make sure which windows is portable with yours. Just click on it and download. Now how to check if the git is installed? The same way as we checked for Python, we just need get version. So here you can see it is 2.52.0 Windows.1. So this means that your git is also ready to go. Now to use open AI models, you also need an API key. So for that you can use open AI or even Google. Now to get the API key, you can just visit platform.openai.com. Create your account here. Enter your email ID. give a good password and you'll get this interface. Now here on the left side you can see API key. So you can just click on that and there is a plus button which you can click on and you can create your key. So you can give a name and a project as required and create a secret key. So let's create a key for now. Let's say I'm using a test and the project saying default and create a secret key. Here you get an option of copy. So just copy it. Now whatever project I will be doing I'll be storing into a folder. So let's create a folder. So you can go to the core and create a new folder. Let's say default or test. And the first thing that you have to create is a env folder to store your API key. So envir open it. Now e folders are used to store specifically your API keys. So you can give API encaps is equal to and paste the key that you have copied from open AAI. So let's just save this and then next again I have to create a py folder. So let's just say it is app py which is a python. So and yes and let's give a simple program. So firstly the first step is you have to import function load. [snorts] So from env import load env. So this will be common for all kinds of programs since you have to load it from av function. Next let's import openai since that is the one which you are going for. For Google also we'll use a different programming style. We'll come back to that open. This imports all the OpenAI Python SDK. So we can make API calls and then we have import OS which imports OS modules to access environment variables from the system. And now to load environmental variables from ENV file. We have another code. Let's say we have load env. And this reads the env file and loads all the variables. Next we have to get the open AI key from the environment. So let's just say open AI API key which is equal to OS get env. Now here you have to input the folder name that you have given. Not exactly the folder name but we have given API key is equal to so and so key. So input that this fetches the value of the open API key from the environment. Next we have to use this key on our open AI API call. So for that it is open AI do API key is equal to open AI API key. Now this sets the open API key so that the SDK can automate requests. Now let's just see an example of API call to open AI. So for that we need response is equal to openi dot completion dot create and let's just give engine is equal to text three and then let's give prompt also prompt is equal to say this is a test let's give the maximum number of tokens also >> just >> now here response is equal to open ai dot completion dotcreate. This calls the open API to generate a text compilation. Now which text compilation it is specified in the engine which is text003. You can use anything as you wish. And then I'm giving a prompt which is say this is a test and the tokens also have been mentioned which is five. So this limits the output to maximum five tokens or words. Let's just at last print the responses. So it'll be print response dot choice. Now this prints the resulting text response from the AI removing extra spaces. Now after getting your API code or a key, optionally you can download any cloud or local developmental tools. For instance, we have Docker. If you are deploying your AI agent in a containerized environment, you will need Docker installed. Apart from Docker, you can use even Hiokco, AWS, Google Cloud. Now let's move on to setting up the project directory. If you have already not created a project directory, the structure the files are discussed. Firstly, we'll need av folder which contains the open API key. And then we have to have a Python folder which runs the main Python script. So here it is app. py. And next optionally we can create a text folder which stores all the requirements. So you can just run the requirements and you will have all the Python libraries or other libraries which are required. And next again optionally you will be needing a readme.md which is a project documentation. So on the go you can store what are the changes done in the program or any information about the project can be stored in that too. Since the API key from OpenAI requires money. Here's another way out which Google API key which is free. So let's see how to get the key. So first you have to visit ai.google devmini API and create your folder with just an email and a password. So here you can see the option of get API key. So you can just click on it and here you can see my previous keys. If you want to create a new one again here's an option of create API key. So you can just click on that name your project and chat vote create a key and you'll be creating a key. Now how do you copy that? Just copy API key option is there. Now make sure for your security purposes do not share your API key with others since they can misuse it. Now the next step is to copy this API key. Go back to the ENV folder and you can see open API key. Just change that. Now from here you can just copy your API key. Go back to the folder where av was created and you can just give Gemini API key is equal to and paste the key over there and you can just paste the key over there and save it. So this key will be used throughout your coding program since we can call small small functions to access this particular key. Now after getting the key the next important part is to install Google generative AI. So for that just go open command prompt and open your folder over there. So it's cd the location and enter. So it'll navigate to the folder and then here the code to install Google generative AI will be pip install Google generate AI and I'm giving a particular version with this. You can go with the latest version and just run the code. And as you can see, it'll get installed. Now to check really if this is installed, just run pip show Google generative AI. And here you can see the version, name, summary, homepage, author, etc. All the details should be displayed. Now let's just start with coding a simple program. So where will the main program go? It's app. py. So let's start with importing Google generative AI. So for that we have import Google dot generative AI as gen AI. Next we have to import env. So we have from env import load env. And next obviously we have to import the OS. So import OS. Next we have to load the key. So for that we have load env. Now we have to get the value of the API. So for that we have API is equal to OS get envy. What is the name that we have given API key. So this retrieves the value of Gemini API key from the environment variables. And let's give let's say suppose there is no key available we'll have a backup repeat. So let's say if we don't find any key we should have a backup of printing an error message. So for that if not API key if there is no value in the API key let's say print an error message. So what should be the error message? Let's print error no API key found and let's exist and let exist from this group exit loop. So this loop prints an error message if there is no API key and exit the loop. So after this loop let's configure Gemini API client service. So for that we have Genai dot configure API key which will be equal to API. Now the next step is to create a generative model. So for that we can use model is equal to gen AI dot generative model and let's give a name of the model. So we'll use models from Germany the 2.5 flash which is the latest one. So this is specifying which model to call. Next we have to define a function which is chat with agent and the values which is going in is the prompt that we given. So we'll use a try loop for this. So response is equal to model dot generate content and the prompt. [clears throat] Now this generates a content from the given prompt itself and then let's just print the given information AI response and let's see what the output will be which is response dot text. Now for the except loop we have except exception as e here if there is no such kind of information let's just print error and at last let's call the main function which is if name is equal to is equal to main slash then we say we have to call the function what was the function name chat with agent and let's give a prompt Let's say tell me a funny joke AI joke in one sentence. So this will be the prompt that we are giving in and the AI will go through the sentence and give the information as provided. This is the main block where we are calling the function. So let's just run this code. How do you run this code? Again, Python the folder name py. So there is an invalid syntax of the main block. So let's just rectify that. So I had missed out on the double dash. So I have fixed it. So let's go back and say it's showing an error. So we'll check that out. So let's just run the program again. Now what was a prompt that was given? It was to ask or tell a funny joke about AI. So the reply was why did the AI break up with the calculator? it felt like it was just adding to its problems. That's is the prompt given by the generative AI Google model. So make sure to check with the code if there is any error coming just copy and paste the error in chat GBT or Gemini. So it'll give you what are the corrections to do and why the error occurred. So this way you will have an understanding of what the problem actually is and how to sort it out. Now that our first agent is working, let's go one step deeper. An AI agent becomes powerful when it can fetch real world data like weather, time, calendar, events, emails or even stock prices. Here you will learn how to make an external API call from our agent. Now the first step is to install requests which we have already done. So let's just install it again. pip install requests. The request library allows Python programs to communicate with any external API whether it's Google calendar weather or even custom back end. Now to run this program let's create another folder of Python in the same folder itself and let's say API tools and yes you have to change this and open it. Now let's start with the coding part. Let's say we have to develop a program which prints the date and time. So for that the first part would be to import requests and next let's define a function get current time. So for getting the time we are defining this. Let's not pass any parameters now. And then we'll give a URL where the actual time has been present. So here's the link where the actual time will be running which is a API. this API endpoint that returns the current time for the Asia or Kolkata time zone. Next we have to send a HTTP request. So for that we have response is equal to request to get URL. So from the URL we are getting the time which is the response basically. And then another response that we want is the response dot raise for status. Now this raises an error if an API calling fails. Suppose if they're not able to get the time, it shows an error message. Next we have data which is equal to response file. Now this converts the JSON file into a Python program or even a dictionary. And then we are returning return data date time. So this is the coding for retrieving the date and time. Now here's an important thing. Never run this file directly. This function sends an HTTP get request to public time API, receives a JSON response and extract the current time. This is how your agent will interact with any real world data sources. So next let's just create another file to integrate the API to call the agent. So again let's just create a folder which says agent API call again it should be a python so py and yes now after creating the agent API call here's a small program that I've integrated with it the first sentence again it's importing Google Gemini AI then I've imported env imported OS this and all is a normal thing that you have to do in every Python folders and then we have from API tools import get current time. This imports our custom function that fetches the realtime data. Next we have loadenv which again loads all variables stored inside the env file into the environment. And then we have generative AI configuration which configures Gemini API using the key stored in the environment. Next we have model. Again I'm mentioning the same model which is Gemini 2.5 flash and then we are defining an agent with API with the prompt in it. So this is a function that processes user input. For example, if the user asks call API tool. Next we have if time in prompt do. So here what happens? This checks if the word time appears in the user's question which is a very case-sensitive process. And then we have given real time is equal to get current time which is calls our external API function to get realtime data and the prompt also we are breaking that down which is equal to prompt plus is equal to realtime data current time is equal to real time etc. So this adds the fetch time into the prompt sends extra context to the AI model. And then we have response is equal to model dot generate content within the prompt. So this calls Gemini to generate a response based on the updated prompt. And then we have return response.ext which returns the text response back to the user. And lastly we have the main module which ensures this code runs only if the prompt is provided. I have given a prerequisite code or a prompt which is what is the current time right now. So this will be a prompt. You can change the prompt to whatever you want. Now in this entire date and time here's what we did. If the user message contains the word time, we call an external API which is get current time and we insert the real world data into the AI model prompt. Then we have the agent now which responds using both reasoning and external information. So let's just if you run this part of the program which is API call which is agent API call you will be able to see the current date and time as per your prompt. Up until now, our agent has been completely stateless. It responds to each prompt independently and forgets everything after it replies. Real intelligent agents need memory. Memory allows an agent to remember user preferences, recall the past tasks, track multiple step activities, understand long-term context. Next, we'll build a long-term memory for our agent. Short-term memory exists only during a single run and resets when the program stops. Whereas long-term memory persists permanently, meaning the agent can read about you and remember it across multiple sessions. We will implement long-term persistent memory that saves information even after you choose the app. Our memory system will use a very simple and reliable structure. The first one is a JSON file. So as you can see we have agent memory JSON which stores all the past conversation. Next we have a memory manager that reads and writes to this file. The agent retrieves the last three to five interaction for context. Memory grows over time just like a human brain. Now firstly we need to create three Python files which is memory manager which stores and retrieves memory. Then we have agent with memory where AI agent logic which is uses memory. And next we have test memory agent py. This runs the entire conversation. Now we'll see what's there in memory manager. py. Now you can consider this as a brain storage. The first purpose is this file stores and retrieves long-term memory. It has code to create a memory file which is agent memory.json. And it also has a function to save the interactions. It also has the functions to load the past memory. Now this file exists because the memory should be independent from the agent logic. This file is like the database of your agent. So firstly we have import JSON here. So imports all the JSON module to read and write. Next again basic is import OS imports the OS module to interact with files. And then we have the memory file. This is the name of the JSON file where the agent memory will be stored in it. And next to create memory file if not exists we have another code. So if not OS.ath exist memory file with open memory file, W as fjson dump history. So here what happens is it checks if the memory file already exists. If not creates a file in write mode and then writes an empty JSON structure. So here in JSON dump it initializes a list where memory records will be stored. So if you don't have any JSON files existing in the folder where your program is, it creates an empty JSON folder. So in future you can store all the interactions in it. Next, we have a function which is save to memory which takes the input as user text and agent response. And we have save users plus agent message into a long-term memory. Now this memory is getting saved into the JSON program. Now this function is getting stored into the JSON file which we have created or it creates by default. Next we have with open memory file, R as F. This opens memory file in read mode. And then we have data is equal to JSON do.load. This loads the JSON content into the Python dictionary. Next we have data history.append which is adds a new memory entry which is a dictionary or a history list. Similarly we have users with user text which stores the user's input and agent which stores the agent response. Now if you come down here again we have with open memory file again w as f JSON dump data f indent 4. So this opens the memory file again writes the updated memory back file and printed. Next here again we have another function which is get recent memory. This retrieves the last memory. Again this with open memory file. This opens a memory file. Read existing data. loads the JSON file into a Python dictionary and then returns the last n conversations which has happened recently. Now let's just save this and move on to the second file which is agent with memory. Again here we have all the basic libraries which is Google generative AI as geni dnvos and then we have memory manager also we have imported save to memory and get recent memory which we have mentioned in the previous one. Now this file is the thinking unit. This file defines how agent uses memory to answer the users. This fetches the code the last n memories from the memory manager py and also the code that combines memory plus users question. It also has a code that sends the enhanced prompt to Gemini. Then it also stores new memory again through memory manager py. The information that it processes will be past memory, current user questions, the AI responses and even the updated memory. And talking about why this file, it's because the agent needs a clear place that handles reasoning, context building, prompt creation. This file is like the AI brain. So as I mentioned all the basic libraries are imported. So here we have load.env and API key and also genici configure API key. This is also very normal as you have already executed this. And then model also 2.5 flash it's the same. Now coming here we have a function which is EI agent with memory with user input and the past memory is equal to get recent memory. So here it defines a function that takes the user's new message load the last three interactions which is past memory and then it retrieves the last stored conversation entries from the memory and then we have memory text is equal to with double quotes. This creates an empty string to store formatted memory text. And then we have from item in past memory. Memory text is equal to plus f user item user agent item agent. So this loops through each memory entry adds both user message and agent reply into the memory text. Now again continuing we have final prompt is equal to f. You are an AI agent with memory. Here is your past memory. So this insert a conversation history to the prompt. This will be the starting of your conversation. And then we are moving on to now answer a new user message. So this inserts a new user question into the prompt. Now here we have response model.generate content which is combined prompt to Gemini to generate a response and then we have answer is equal to response.ext. This extracts the text output from the model. And then to save both user query and AI answer, we have save to memory user input, answer which is stores the latest user messages and AI response. This updates the JSON memory file. So the agent remembers it later and then we have to return the answer. Now talking about the third file which is text memory agent. So let's open that also. So this I would call it a chat interface. This is a file you actually run. So what and all it contains? It contains a loop asking the user for the input. It passes the input through the agent with memory dot which will be called in the program and then it displays the agent response. It also keeps the chat going. And what information does this handle? It handles user messages, AI responses. Now here no memory is stored. It delegates storage to other files such as the JSON file which will be created. Now this file exists because students needs clean simple entry point to test the agent. From agent with memory import AI agent with memory. Now let's start with the programming part. So here you can see from agent with memory import AI agent memory. This imports the main functions that handles memory, builds the prompt and generates a response and saves the conversation. Next, we have print AI agent with memory text exit to quit. Here it displays a welcome message and instruct the user how to quit the program. Then we are entering into a while loop. This starts an infinite loop to keep the chat running. And then we have user message which takes a input from the user every time they are typing something. Now there is a if loop. If there is a message called exit, it breaks the loop directly. Or else it will be reply is equal to AI agent with memory user message. So this sentence basically sends a user message to the AI agent with memory and the agent responds and updates the memory. And lastly we have to print. So we have print the AI response on the screen. Now let's see the back how did we do this entire three files. So we have user then we did test memory agent py which will send a message to agent with memory. py combines the memory plus the question and requests the pass memory which is the memory manager. py provides the memory returns the pass memory to agent with memory. py which will be generating reply plus saves new memory. Again this memory will be sent back to the user which is called in the test memory agent py where the answer will be displayed. So let's just run this folder which is test memory agent and see what the output looks like. So here firstly I'm navigating to the folder and then we have python what was the name agent test memory agent. So we have test memory agent. So let's just run this. So you can see AI agent with memory type exist quit. So let's just say hi my name is Susan. So here the agent replies saying okay Susan I'll remember that your name is Susan. Let's say my age is 32. So it is remembering the age as well. And let's say I work in the domain let's say data science. Now it is remembering three information. Let's ask if the AI actually remembers. So let's just ask what my name, age and domain that I work in. So as you can see your name is Susan. You are 32 years old. You work in a domain of data science. So it actually remembers our past three conversation. You can increase the number of conversation as per your wish. Up until now our agent can remember information, call external APIs and generate the responses. Now we are adding three powerful capabilities. The first one being prompt chaining. Second one being routing and third we have parallel task execution. These techniques are what real world AI assistants use to break down task. pick the right tools and work more efficiently. These techniques are what real world AI assistants use to break down task, pick the right tools and work more efficiently. In prompt chaining, the agent doesn't try to do everything in one go. Instead, it performs multiple steps and uses of the output of one step as input the next one. Now, let's take an example. Now if you input explain Python decorators and give an example without prompt chaining agent tries to answer everything at once often which is messy. With prompt chaining agent breaks into clear steps which is understanding the concept explaining it generate an example code and even summarizing it. [snorts] So let's write a code for this. So again starting with the basic import variables which is Google generative AI as genai we have env to read the API key and also import OS and again we are loading the envi key specifying the model. This is basic again repetitive in all other programs as well. Now here we have a function which is dfch chain prompt which defines the function named change that performs prompt chaining and then for step one we have step one is equal to model dot generate contact f break this task into clear steps. So here it calls the gemini to perform the step one of chaining and here f break this task into clear steps. This is AI returns a stepby-step breakdown of the user's task. So we are asking the Gemini directly what parts can this question be divided into. So it'll give us an answer and next we have print ln step breakdown one. So this prints the breakdown so that user can see how Gemini structures the task and then we moving on we have step two which is step two is equal to model.generate content. Now here this will call Gemini again for step two and AI produces a detailed explanation using the step breakdown and we are also printing the detailed explanation of the step two. Again coming to step three we are asking the agent for final summary. So here again we are calling the Gemini AI returns beginner friendly summary and also we are printing that final summary. This is return step three. The final results will be returned in this step. Now again main part of the program which calls and runs the entire program which checks if the file being executed directly or imported. And then we have chain explain Python decorators with an example which runs the chaining function on an example prompt. So here we have already given the prompt of explain Python decorators with an example. So you can change this as per your wish and check if it follows all the steps. So let's just run this folder and see what will be the results. So again how do you run the program? Same way Python the folder name is prompt chain agent py. So we had asked a question of what is a decorators. So we need three-step explanation with the summary. So let's see if that is given here or not. So here you can see step breakdown. Let's break down the explanation of Python decorators into clear easy to follow steps. We have step one introduction of what decorators are. Then we have prerequests which is understanding the building blocks which is the second step. And we have the third one which is building a simple decorator. And then followed by fourth step which is applying a synthetic sugar. 5 6 7 it is divided into multiple steps which is handling argument and return values and then sixth one should be real world examples real world use cases and as I remember the last part should be summary so let's just check with that so here you go there is a summary provided on entire Python decorators so much of information we have acquired due to chaining process Now coming to the next powerful capabilities which is routing. Routing means that the agent decide which tool or method to be used based on the user query. This is how chat GPT decides whether to use the browser, use Python, use memory or even use image features and it also specializes in using specific tools. We built a simple router using Python keyword detections. So let's go through the code. The first one again basic things which are imported which is Google generative AI envoss. The extra thing which is imported is API tools which we are getting get current time. So as as you remember we had done a program which gets the date and time we are using that here. And then continuing with load envi configure the model that Gemini should use. Coming down here we have a function which is router agent which passes through query. So here this function that routters the query to a current logic and then we have if time in query dot lower which is if the user's message contains the word time. This will call a function to fetch realtime data and returns it. Then we have another if statement if explain in the query which is if the message contains the explain then it asks Gemini to generate a simple explanation of it and then it returns the explanation back. Then we have default fallback which is response is equal to model.generate content query.ext. If no condition is matched then just ask Gemini normally. Then we have returned the responses and again we are calling the function and the input that we are giving is what is the time now which is a question and then we have also given another input which is explain recursion. So let's just test both the outputs. So here again python what is the folder name by router agent py let's just run it. The two question are what is the time now and what is recursion. So let's see if it answers. So here you go. The current time is so and so it is already displayed and then you have recursion. So imagine you have a task instead of doing the whole thing yourself you figure out how a tiny part etc. This is all regarding recursion. In short, recursion is a function of instructions that solves a problem by calling itself with a simpler version etc etc. So we've got an answer for both the question. So according to the keywords that you are using in your prompts, it generates the kind of answers which is suitable as per your prompt. Now the next thing we are going to see is a parallel task execution. Gemini supports running multiple prompts at once which is parallelization speeds up the agent. If the agent needs to do four tasks do them at the same time instead of one by one. Now let's put this on code. Firstly starting with the normal importing Google generative AI as genai from env import the envos. The only thing which is imported separately which is import concurrent futures which allows running the prompts parallelly and then normally we have load.env and this is regarding the Gemini API key geni.configure API key OS etc. We have also mentioned the model name. Now here we have a function which defines the sends or returns only text output and then we have generates content and returns only text output. It's basically uh one text at a time but with four routers. So yeah we are entering one prompt which asks the Gemini to generate the answer for it. And then we have the prompts. Prompts such as summarize Python into 200 words. This is for execution part. Explain AI agents in simple terms. Give a motivational quote. Write one in line definition of API. So these are list of tasks that will be executed parallelly. Again if you come down here we have with concurrent dot futures thread pool executor as executor. Here it creates a thread pool to run multiple operations simultaneously. And then we have results is equal to list executor dom map ask gemini prompts. So here maps each prompt to ask gemini function and execute them in parallel. All the results are collected into a list format. And here for the result we have for rn results loops through each a generated response and then we are printing the same response in a loop. So let's again run this and see if all the four prompts will be able to get it at one go. Now let's just run this program. Now here you go. All the four prompts which is answered within a few seconds. Instead of writing one prompt and waiting for the answer, writing another prompt, waiting for the answer, you can get all the four prompts answer at one go. With these additions, your agent can break down the task, choose the correct tool and even execute multiple task at the same time. Also, it will respond professionally and intelligently. These advanced capabilities bring your agent much closer to real production level AI assistance. Now, with all the knowledge that you have gained, let's build a end-to-end project. Let's say that you have to build a complete AI interview coach using Gemini and Python. This assistance will act like a real interviewer. Ask question, analyze your response, store your weaknesses and generate a professionalized feedback. Let's name the project as EI interview preparation coach. Mainly let's have a project structure for this. So again as we did in the start create a folder with all the necessity files required. Starting with I already have here env which stores the Gemini API key. We have roles py which has list of different roles and store the keyword. And then we have interview agent. py which is a main agentic logic. And then we have memory manager. py again it's a long-term strength or even a weakness memory. Followed by we have tools. py which is tools like time scoring keyboard check etc. Then we have router. py which routes task analyzes questions and feedbacks and finally we have mock interview py which runs a full interview session and then by default interview memory.json which stores the interview history. So let's get started with the final project. First let's start with creating folders and files. So you can just create such files and then as usual env file load your Gemini API key. The second file should be roles. py. Here in this Python code, you can enter the domain and couple of domains for initially providing the chatboard with options of which interview you want to practice for. So here you can see interview roles. I've given it software engineer, Python developer, data analyst, machine learning, cyber security, cloud engineer, project manager, digital marketer, and HR manager. And I've also included some of the key words related to these roles which is OP, DSA, algorithms so that the AI would be able to fetch questions based on these topics or even keywords. Now coming here you see a function to let the user pick a role and then we have a greeting message saying welcome AI interactive coach and it also say print the role to begin your mock interview with. Now we have all the roles in the list here interview roles. So here dot key. So we are going to list all the interview roles that we have created. And then for looping we have for i, r in enumerate roles. Start is equal to one. This here loops over all roles with numbering starting from 1 to 9 since I've given nine different positions or interviews. And then we have print f. So it prints each role number and a title case. So this will print nine HR manager eight digital marketer such like that. And then we have choice int input enter a number of roles. So if you enter 1 to 9 any number it fetches question based on the specific domain that you have been choosing. And then we have ro is equal to roles choice minus one. This maps the number to a correct role in the list. And then we have print and then we have print you select. So displays the selected role to the user. So whichever role that you have selected it will print back again. And then we have return role interview roles which is returns both the role name and its meta data. So here is about the roles which is the basic starting. Now since the initial part moving on to the next one will be tools. py. So here you have df keyword math score and comma keywords. This is a function to count how many expected keywords appear in the user's answer. And then we have scores the user's answers based on the keyword presence. More keywords is equal to higher score. And then we have answer is equal to answer dot lower which converts the user's answers to lower case for case sensitive matching. And then we have match is equal to sum one for k in keywords. If k dot lower in answers then return match. So here it returns the number of matched keywords. So if you give an answer to a particular question it has a pre-built keywords. So it matches the entire keywords and gives you a score. Next here we have function to generate score. Keyword score, difficult which is equal to medium. Here converts the keyword count into final score out of 10. Now difficult slightly adjusts the scoring curve. And then we have base is equal to keyword score into two. Each keywords adds two points to the base score. And if difficult is equal to is equal to hard base minus is equal to 1. And else if difficult is equal to is equal to easy base plus is equal to 1. So if the interview difficult is hard, we reduce the score slightly. If the difficult is easy, give a small bonus. Now to keep the score between 1 and zero we have return max one and minimum 10 comma base and moving on we have another function which suggests which important points the users have missed. So for that we have answer is equal to answer dot lower which is lower case the answer for uniform matching and then we have missing is equal to k for k in keywords if k dot lower not in answer. So this creates a list of keywords that did not appear in the answer. And then we have missing list is equal to an empty array dot join missing return f you have missed these important concepts which is the missing list try including them next time. So here it gives a feedback saying these are the concepts that you have missed and try to include them in your next answers. The next function will be def classify strength or weakness score. So this classifies performance strategy category based on the score. We have basic rule to classify users performance. If the score is greater than or equal to 7, we are returning strength or we are returning weakness. So basically we are judging based on the answer if your score is a strong one or a weak one. Next coming to here the last function we have the fsh short feedback. This gives a short qualitative comment which is simple quantitative feedback based on the score. So here we if it is greater than or equal to 8 we are providing a feedback excellent answer with strong and clarity and then if it is between 6 to 8 we are good answer but can be more detailed. And then we have decent attempt but lacking key concepts. And if it is less than four, we have weak answer need major improvement. So this is the feedback. Next we have memory manager. py. So let's open that. Here long-term strength or even weakness memory is adapted. So starting with again basics of the basics are important which is JSON. Since it is a memory py you need a JSON format. So we are importing JSON's well and good in the first place itself and then as usual we have operating system which is import OS and then we are loading in a memory file which is interview memory.json which is a repeat which is a file name where all interview memories will be stored. Now to create the memory file if not exist this checks if the memory already exists or not. If not it creates an empty file which is interviewed memory dojson and the history is empty strength is empty and weakness is also empty as per now. So as we have the conversations or as the interview takes place the memory will be stored in the JSON format. Now coming on to the next function which is df save interview record role comma question user answer feedback. This is save one Q&A record to long-term memory with open memory file R as F data is equal to JSON.load F. This entire loop loads the existing memory file contains into the Python dictionary. And then we have data which is history, role, question, answer and feedback. These are the things that can be stored in the JSON format. So this adds a new interview entry into the type of the interview conducted, the questions asked by the AI, the user's response, the full feedback which is score, strength or even weaknesses. Then coming down we have with open memory file WSF JSON dot dump data f indent is equal to 4. Here this saves the updated memory back to the disk with formatting. Next we have another function which is save strength and we have with open memory file R data is equal to JSON.load F data strength dot append strength with open memory file W as F and we have JSON dod dump data F indent is equal to four. So again here it loads the current memory into the dictionary adds new strength data into the strength list and also writes updated strength back to the file. Similarly we have save weaknesses. It's the same code just it is replaced with the weakness function or weakness information. And lastly we have function which is get memory summary which is retrieves memory for personalized reports with open memory file R as f return JSON.load. This returns an entire memory including history strength and weaknesses. Now let's code interview dot interview agent. py again here also basic imported functions which is google.generative generative AIE environment system and then we have from memory manager import save interview record save strength save weaknesses from tools import so many tools so here all the memory manager all the classes that we have defined or even functions we which we have to use it in the entire program we can call it here and then we have load envy about the API key these three are again a constant in every program. So here we have function which is generate questions role prompt is equal to f. So here Gemini generates one interview question removes extra spaces and returns. Next we are moving into function two which is analyze user answer to the interview question. Here again we have role specific important function and then we have data which is difficult, easy, medium or hard and we have different scores. So first score user answer based on the keyword matches convert keyword this and all we have already performed we are just calling it. So again as you can see provide a short analysis until here it is called then you are an HR expert. This is a prompt given for the Gemini and senior interviewer. Evaluate this answer for the role of whichever the person has selected. The candidate answer the final score is also been printed. strength, weaknesses based on the keywords and also provide a short analysis which is two to three lines which will be printed after the interview is done. One sentence on how to recruit will be received this answer. One actionable improvement trip make feedback helpful but not harsh. So these are the instructions or the prompt that we are giving to Gemini. Then we have AI feedback is equal to model generate content analysis prompt dot text. Then we have to store the strengths and weaknesses in long-term memory which has already been created in a previous program. So here we have store strong answers, store weak answers etc. So you can go through this code and we have what are the return values? We have score improvements, brief feedback and AI feedback all via Gemini. So these things will be returned back to us. Next we have router.y. So let's just check what and all goes into router. py. Here we have from interview agent import generative question analysis answer. So this import question generation plus answer analysis. Then we have to import functions to save interview results plus load the summary. So we have a function for that and we have a class which is interview router. There's a main class that controls the interview flow of it. And then we have a class under class we have the first function which is in itself ro and ro data. So here the selected interview role example if you select software engineer etc. it will be stored here or asked here or even looped here we have role as metadata and keywords will be selected counter for how many questions totally. So as you can see here we have from interview agent import generate question and analyze answer and then we have from memory manager import save interview record get memory summary. So here this imports question generator plus answer analysis and also here it import functions to save interview results plus load memory summary. Then we have initialized an entire class which is the main class and under which we have first function which is init. Here the selected interview role for example if you select a software engineer or data science or something like that will be iterated. Next we have role which is metadata keywords etc. Next we have counter for how many questions total interview questions truly only when waiting for stores and active interview questions. So here this is basically the limits that we are setting suppose the amount of question maximum answers waiting for the answer current question etc. So for this we have initialized in init ro and we have passed the parameters of self ro and ro data. Next here we have the next function which is df next step which passes the parameters of self user input is equal to none. And here we start the interview question which is ask first question. So here we have given if self dot question count is equal to is equal to zero return self dot ask new question. So if the waiting for an answer it analyzes it basically. And then for the second question again we have
Original Description
🔥Michigan - Applied Generative AI Specialization - https://www.simplilearn.com/applied-ai-course?utm_campaign=ReplaceWithWQLzDDNEBGY&utm_medium=DescriptionFirstFold&utm_source=Youtube
🔥Professional Certificate Program in Generative AI and Machine Learning - IITG (India Only) - https://www.simplilearn.com/applied-generative-ai-course?utm_campaign=ReplaceWithWQLzDDNEBGY&utm_medium=DescriptionFirstFold&utm_source=Youtube
🔥Advanced Executive Program In Applied Generative AI - https://www.simplilearn.com/applied-generative-ai-course?utm_campaign=ReplaceWithWQLzDDNEBGY&utm_medium=DescriptionFirstFold&utm_source=Youtube
In this video, you'll learn how to build an intelligent AI agent from scratch. We’ll guide you step-by-step through the process, starting with understanding the fundamentals of AI agents and setting up your environment. You’ll create your first AI agent, integrate real-world APIs, and add memory for personalised interactions. We will also dive into advanced features like prompt chaining, routing tasks, and parallel task execution to make your agent more efficient and powerful. By the end of the video, you’ll have built a complete AI Interview Coach that can evaluate responses, provide feedback, and remember past interactions, giving you the skills to develop your own AI-driven applications.
00:00:07 Introduction to the video
00:02:29 Introduction to AI Agents
00:04:24 BASIC SETUP AND REQUIREMENTS
00:00:00 Creating and Running an AI Agent
00:12:37 working with api calls
00:25:20 Memory & Retrieval
00:37::00 Advanced features and tools
00:48:05 Final Project
In this course, you’ll discover how to build a sophisticated AI agent using Python. Starting from scratch, you'll explore key concepts like memory management, API integration, and task routing. As you move through each module, you’ll create a fully functional agent that can interact with users, remember past conversations, and even analyse responses using external APIs. By the end, you’ll have
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Simplilearn · Simplilearn · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Ethical Hacking Full Course 2026 | Ethical Hacking Course for Beginners | Simplilearn
Simplilearn
AWS Full Course 2026 | AWS Cloud Computing Tutorial for Beginners | AWS Training | Simplilearn
Simplilearn
Data Structures And Algorithms Full Course | Data Structures and Algorithms Tutorial | Simplilearn
Simplilearn
SQL Full Course 2026 | SQL Tutorial for Beginners | SQL Beginner to Advanced Training | Simplilearn
Simplilearn
Microsoft Azure Full Course 2026 | Azure Tutorial for Beginners | Azure Training | Simplilearn
Simplilearn
Shopify Tutorial For Beginners 2026 | Shopify Course | shopify dropshipping | Simplilearn
Simplilearn
Six Sigma Full Course 2026 | Six Sigma Green Belt Training | Six Sigma Training | Simplilearn
Simplilearn
🔥Feeling Stuck? How Upskilling Can Boost Your Career! #shorts #simplilearn
Simplilearn
Growth Hacking In Marketing | Learn Growth Hacking Marketing Strategies | Simplilearn
Simplilearn
🔥Cracked 3 Job Offers with One AIML Course! | 20–30% Salary Hike #shorts #simplilearn
Simplilearn
Top 10 Must-Have Figma Plugins for UI/UX Designers in 2026 | Figma Plugins | Simplilearn
Simplilearn
Business Analytics Full Course 2026 | Business Analytics Tutorial For Beginners | Simplilearn
Simplilearn
Simplilearn Reviews | Getting future-ready with course in Artificial Intelligence | Roopam’s story
Simplilearn
Generative AI Full Course 2026 | Gen AI Tutorial for Beginners | Gen AI Explained | Simplilearn
Simplilearn
Full Stack Developer Course 2026 | Full Stack Java Developer Tutorial for Beginners | Simplilearn
Simplilearn
Simplilearn Reviews | How David Went From Seasoned Engineer to AI Innovator #GetCertifiedGetAhead
Simplilearn
Complete Social Media Marketing Strategy for 2026 | Social Media Marketing Strategy | Simplilearn
Simplilearn
🔥Top 4 Cybersecurity Certifications You Need! #simplilearn #shorts
Simplilearn
🔥Cloud Engineer Salary in India 2026 | City-Wise Breakdown #shorts #simplilearn
Simplilearn
Digital Marketing Full Course 2026 | Digital Marketing Tutorial For Beginners | Simplilearn
Simplilearn
Full Stack Java Developer Course | Full Stack Java Developer Tutorial for Beginners | Simplilearn
Simplilearn
Social Media Marketing Full Course | Social Media Marketing Tutorial For Beginners | Simplilearn
Simplilearn
How To Create LLM Chatbot Demo 2026 | Build a LLM Chatbot From Scratch | Simplilearn
Simplilearn
Digital Supply Chain Management Certification | Supply Chain Management Course | Simplilearn
Simplilearn
AI Agents Full Course 2026 | AI Agents Tutorial for Beginners | How to Build AI Agents | Simplilearn
Simplilearn
ITIL Full Course 2026 | ITIL 4 Foundation Course | ITIL Tutorial For Beginners | Simplilearn
Simplilearn
Generative AI Full Course 2026 | Gen AI Tutorial for Beginners | Gen AI Explained | Simplilearn
Simplilearn
ITIL Full Course 2026 | ITIL 4 Foundation Course | ITIL Tutorial For Beginners | Simplilearn
Simplilearn
Simplilearn Reviews | Integrating AI & Music | Diego's Story
Simplilearn
Digital Marketing Full Course 2026 | Digital Marketing Tutorial For Beginners | Simplilearn
Simplilearn
SEO Full Course 2026 | SEO Tutorial for Beginners | SEO Training | SEO Explained | Simplilearn
Simplilearn
PMP Vs CAPM: Which Certification Should You Choose? | PMP Vs CAPM | Simplilearn
Simplilearn
Complete Data Analyst Roadmap 2026 | How To Become A Data Analayst In 2026 | Simplilearn
Simplilearn
Generative AI Full Course 2026 | Gen AI Tutorial for Beginners | Gen AI Explained | Simplilearn
Simplilearn
🔥5 Jobs That Are Most Likely Safe from Layoffs in Today’s Market #shorts #simplilearn
Simplilearn
🔥Git vs GitHub – What's the Difference?
Simplilearn
What Goes Behind Building the Likes of Uber and Netflix? | Product Management Tutorial | Simplilearn
Simplilearn
AI Agents Full Course 2026 | AI Agents Tutorial for Beginners | How to Build AI Agents | Simplilearn
Simplilearn
Full Stack Developer Course 2026 | Full Stack Java Developer Tutorial for Beginners | Simplilearn
Simplilearn
Product Life Cycle 2025 | Stages Of Product Life Cycle | Product Life Cycle Tutorial | Simplilearn
Simplilearn
Project Management Full Course 2026 | Project Management Tutorial | PMP Course | Simplilearn
Simplilearn
PCB Design Course 2025 | PCB Designing Explained | How To Make PCBs | Simplilearn
Simplilearn
Python Full Course 2026 | Python Data Analytics Tutorial For Beginners | Simplilearn
Simplilearn
🔥Top Product Management Skills You Need to Succeed in 2026 #shorts #simplilearn
Simplilearn
SQL For Data Analytics 2026 | Essential SQL Commands | SQL Tutorial For Beginners | Simplilearn
Simplilearn
Simplilearn Reviews | Paving Way To Success With AI & ML Course | Soumik’s Upskilling Journey
Simplilearn
Six Sigma Full Course 2026 | Six Sigma Green Belt Training | Six Sigma Training | Simplilearn
Simplilearn
Learn Snowflake In 45 Mins | Snowflake Tutorial | What Is Snowflake | Snowflake Explained
Simplilearn
🔥ML Career Tip – How to Start Learning Machine Learning in 60 Seconds! #shorts#simplilearn
Simplilearn
🔥Agile vs Waterfall in 60 Seconds #shorts #simplilearn
Simplilearn
Excel Full Course 2026 | Excel Tutorial For Beginners | Microsoft Excel Course | Simplilearn
Simplilearn
What Are AI Agents? | Types Of AI Agents | AI Agents Explained | AI Agents Tutorial | Simplilearn
Simplilearn
How To Create a Product Roadmap In 2026 | Product Roadmap | What Is Product Roadmap | Simplilearn
Simplilearn
SQL Full Course 2026 | SQL Tutorial for Beginners | SQL Beginner to Advanced Training | Simplilearn
Simplilearn
🔥What Is Phishing? #shorts #simplilearn
Simplilearn
Cloud Computing Full Course 2026 | Cloud Computing Tutorial | Cloud Computing Course | Simplilearn
Simplilearn
Simplilearn Reviews | Overcoming Rejection & career plateau to finding a New Job : Bhaskar Banerji
Simplilearn
Six Sigma Full Course 2026 | Six Sigma Green Belt Training | Six Sigma Training | Simplilearn
Simplilearn
Generative AI Full Course 2026 | Gen AI Tutorial for Beginners | Gen AI Explained | Simplilearn
Simplilearn
VLSI Design Course 2026 | VLSI Tutorial For Beginners | VLSI Physical Design | Simplilearn
Simplilearn
Related Reads
Chapters (7)
0:07
Introduction to the video
2:29
Introduction to AI Agents
4:24
BASIC SETUP AND REQUIREMENTS
Creating and Running an AI Agent
12:37
working with api calls
25:20
Memory & Retrieval
48:05
Final Project
🎓
Tutor Explanation
DeepCamp AI