Build Your First AI Agent in Python (From Scratch)
Skills:
Agent Foundations90%Tool Use & Function Calling80%Multi-Agent Systems60%Autonomous Workflows60%
Key Takeaways
Builds a simple AI agent from scratch using Python, with a goal decided by LLM, and takes actions based on tools advice, utilizing Grock as the LLM and implementing modular design with separate files for agent, prompt, and LLM functionality
Full Transcript
Hello guys, welcome back to my channel. So today we will going to develop uh agentic AI from scratch. Uh so we'll build simple tools. Uh it's not a complicated thing at all. So and it is a beginner friendly also. So what we are trying to build and uh you know uh first you know we will get to know the architecture first and you know we will you know uh we will you know do modular coding also. So we will have some uh genuine Python files where you know for that specific purpose we will have that and we'll package that in you know main.py. So yeah I mean this is a very beginner friendly you know um agents what I am trying to build from scratch. So you will also get to know once I once I will start with explaining the architecture and coding logics. uh so why I why I'm starting with you know very simple agents is because to understand the basics first right what agents is capable of and how we can you know ensure that you know the agents are uh you know how it is running in the loop or how it is you know interacting so those things are very important for you to you know um go into the agent part so first what I will do is I will start you know um explaining the architecture explaining the coding logics what I am trying to do and later we will straight away jump into the coding. Okay. Yeah. So first what I will do is I will just show the architecture first guys. Uh so if you guys see my screen uh so if you guys are seeing right so what I will do is so this is architecture guys. So what is exactly happening is that first what is our goal right? So what is our goal is the main part here. So what is the goal and let LLM think right? So LM can decide whether it can answer itself or it should act based on the tools advice right. because we are building multiple tools. So, LLM knows exactly LLM is intelligent enough to you know uh think like okay which can which tool is for what okay so that is also there and if that is not coming so what I can do is like we can just uh LLM can answer also that's the that's also there so LLM also can answer or you know LM can decide about whatever and afterwards what it will do it will observe guys so it will observe the results so what it will do is it will observe the results and it will keep in the memory that is very important. So when you remember anything it will store those kind of datas right? So it will store those kind of data so that AI or LLM will be enabled you know what can happen next right because when it has a memory then the data is stored stored in the LLM itself and LLM will become even more powerful right so that action will repeat again so that is the main architecture that what we are trying to build here so thinking is goal you should have one goal okay and you know LLM will ink and it should based on the acting it should you know take the tools right so which tool we will design based on that decision so it should take the tools and it will observe the results and it will keep on the memory and later it will repeat them right so that is what I am trying to build now okay so next coming to the code code right so what exactly I'm trying to build here so as as as this architecture says user goal is important The main py is like a package guys. So it's like a python package which will keep every file in the uh in in that particular package. So last May we will anyways run main.py only. But this is like a package guys. Okay. So agent package means it will have all the interact interacted files it will have in the loop. Okay. So agent py is the agent. So which we'll try to create the agents here. Okay. Uh so build prompt prompt also I will explain like what kind of prompts we can give for that uh you know this one and that will be llm. py is another llm. means which agent or which uh LLM we are using. For example, it can be grock, it can be open AI, it can be you know uh cloud it can be anything for here I'm actually using here grock guys. Grock is open source and also I have the APA key so I will just use grock here. Okay. And choose tool. So which tool it should choose right? So that will be coming part of tools. py. So we will instantiate some two tools. Okay. So I don't want to add it as like a you know one generic tool. We will have some one or two tools right two tools is good so to you know understand you guess the functionality how this agent works. So what I will do is I will just have the tools and next it will be result okay result how and memory update as I said each and everything should go in the memory so that LLM with tools or aentk things can become powerful. So why AentK is powerful guys? Because it has the memory update feature. Memory update features and tools calling functionality. So these two are very important in aent. Okay. Why generative AI and agent? The what is powerful in aentki is that so it has the you know tools integration capability which is which you can integrate the tools to that LLM and also it will update the memory guys. So memory.py is also very important and tools. P is very important here. So understand the agent uh you know approach. Okay. So next step is that looping pattern. So next step what is the next step? That's very important. So now so here what we are trying to build right lm brain. So we will create two tools. One is calculator and one is runshell. So calculator is for math evaluation and run shell is for system command. So we will create we'll try to create two tools where you know where LLM brain will work like calculator run shell and math evalation and system. So this will this is like a main architecture what I'm trying to say. So now we will straight away pitch into the coding things. Okay. So what I will do so here one agent uh you know uh folder is there. So let me delete everything here. So here agent uh folder is there. So what I will try to create is first I will try to create uh okay so this is folder structure guys what I'm trying to create now so init py which is very important okay and next what I will try to create is as I said agent py which we require agent py okay agent py is one of the things what I require and next what I require guys I require important thing that is llm py which is a brain right it should exactly decide right so where to go and all these things and next what I need to create I need to create memory py which is also very important which should store the memory as I said in the architectural diagram next another thing I didn't share this but schema py which is also very important I will I will tell you what is the importance of schema because see certain rule should be there right for creating anything certain rule should be there so that I will create in schema.py. Okay. So now next very important thing is tools.py. I need to declare tools right like calculator run shell. I want the tools. Uh so what I showed in the architecture diagram. So this one I'll create an agent. Okay. So outside agent outside agent I need to create few stuffs. So for that what I will do is I will try to create three files here. Okay. Which is main. py main.py main.py P means I told right package it will it will come as a package. So bake package means I mean it will interact with everything and it will you know last we need to run the main.p. Okay. And next what it will do guys. So two things are there. One is requirements.txt uh requirements.txt which is you know adding dependencies packages guys. So packages if you see my previous video also I I have explained why requirements.xt is required and next is very very important to store the environment variables in env is also very important. Okay. So this is a folder structure. So I have created two fold two folders. One is agent from scratch and agent folder. In agent folder we have llm.py agent. py memory. py schema.py py tools. py and in uh in outside that main. py is there and requirements.txt is there and agent. py is there and init. py is there. Okay. So first what I will do is I will create a virtual environment. So which is very important. So what I will do I will just go to new terminal and you know I will select cmd here. Okay. Uh one second maybe I just for this so that you guys will understand this how to create the virtual environment. Okay. So let us concentrate on creating virtual environment first and later we can you know do that. So UV in it in it means it's a UV is a package you know there actually we are doing the init part. So in it has been you know it has been successfully done. So now what I will do uv VNV agent agentic env I will create. So I'll create a virtual environment. So it will create one folder. So if you guys see here in the left hand side it has created one agentic.env folder. So where all these things are there. So what I will do is I will script dot I will click on activate bat and I will come to here. Okay. and I'll come to here and I will activate. So as soon as you activate guys uh so what it will happen is let me kill cls. So if you see here so the agentic environment we are inside agentic. Okay so this is very important. So you are inside agentic UI environment. So now you have already created the environment you know let me uh do one thing uh let me add like this. Okay. Uh you are already inside the agent environment. Now what you need to do is in terminal in terminal. So you need to type uh so first what I need to do is I need to add requirements.txt first here. Okay. So what I will do for that? So I'll just go to my requirements.txt which I have already created. So there actually I need to create three dependencies. One is grock. So as I said I'm using llm as grock. So the graph it dependency is very important. Pyatic is for schema right schema and python.env is for environment uh you know storage and everything right. So envos we will need to create the environment in we need to call the you know environment and file and we need to do right. So that's why python.v is very important. So three files which I need to you know get it in the requirements.xt. Now what I need to do is guys um now what I will do is I will just try to enter that in the so let me clear this first okay uh let me clear this first in it's cleared so what I will do is uv pip install minus R okay requirements .txt. So this command will inst you know uh do all the dependencies. So if you see right all the dependencies are you know installed in a fraction of second guys to be honest it's taking very less time and that's why we have the UV that's the power of UV actually. So it will actually install everything in you know very uh small time. Okay. So now as of now it's installed all the things now. So now we will concentrate on the very important part called coding part. So this is so this we have installed everything. So we'll start directly from coding. So first what I will do? First I will create my tools guys because tools are very important for the you know uh so what I will do I will just go to agents right agents tools. I will just go to tools.py now. Okay. So tools py what I will do? So I need to import some of the things here. Okay. Let me import sorry. So here I to cancel this. So import subprocess. So subprocess I will explain you guys why it is required. So import subprocess. Now diff what guys again I need to define first run shell. Run shell means guys. So for example if I if I do ls or you know if I do some something right it will list down the files right if you see it should it it will actually list down some files right so what this will do is so once this once this agent runs okay if you integrate with this tool so it will give the list of files in the current directory so that is what I'm trying to do in the run shell okay because I'm trying to do with a simple examples because you you guys can understand in a simple examples complicated codes we can still write. So we we have still time for that but understand the concept first. Okay, that is very important. So now run shell. So command you know uh str you know and here also I need to give strr. Okay. So what? Result equal to result equal to subprocess dot run. So I will just try to enter in you know different uh format so that you know uh I mean different line so that you guys you will understand these things. Okay. Uh or in the same line I can enter that's not a problem. Uh I'll just keep it this outside. So this one is fine. So see here uh all the things are there command what is the command? Shell and capture output uh which is true and text is also true I have given. Okay. So now what I will do is result return sorry return return return result. Okay dot SD out. SD out means we are printing that right? SD out or result std error. If it is result is std error, it should display the error. Okay. Otherwise, what should it should do? It should, you know, keep the um I mean it should actually result equal to uh it should actually print it. Okay. So next, so this is one tool guys. So this is one tool. Let me save this. So this is one tool. Okay. So next what I will do? Next I will create another tool which is calculator. Okay. So, div calculator expression here we need to give expression. Okay. Expression. So, what I will do is I will try to add you know uh I will try to add the comments also so that you guys will I mean numeric also. So what I will do is one second. uh so here what I will do is evaluate you know a mathematical expression mathematical expression see I'm writing each and every line so that you guys are understanding this because this is very important to in understanding the things very very easily and you know we should actually uh do very practically guys otherwise you guys will not understand example inputs okay so 45 for example I'm just telling 45 into 12 is one of the things right so which I can enter or you know if I want addition I will just enter 100 + 200 just giving one random example okay you guys can write anything what I require but yeah this is one thing okay so not now what I need to do guys is try try catch block we'll write first try Okay. Result equal to equal to what guys? Expression expression is enough. Okay. Written. Written str is return. Okay. Now exception. except accept exception as E. Okay. Uh so here what I need to do is I need to return what guys if error comes. Okay. What is the plan? Error evaluation expression. So that is also completed. So now try box completed. So now I last what I need to do is that I need to call the tools. All right. So I have defined tools here. Tools equal to okay tools equal to so what guys run shell calculator because I have created two functions here runshell and calculator so same things I need to you know assign these things as a variables so if you see this so if you see this this is my tools py which I have written so one is run shell and calculator so the same things I'm writing here so what is the logic of This this is a runial things and this is a calculator things and tools I am using run calculator. So hope you guys understanding these things. This is a very important steps in our coding. Okay. So this is tools.py. So next what I will do is that next I will write schema. Schema means uh so schema means what I will tell. So this is one step. So schema schema means so you should have some you know uh rules you know to write anything right. So when you call the action so what kind of uh you know what kind of thought what kind of actions or what kind of inputs is required right so inputs it can be string or any or actions can be only string so those are kind of rules we need to set up in the schema okay so schema is nothing but you are setting some rules for the input output or you know your uh uh any actions right so you are setting up some rules that is called schema guys schema guys okay when pantic we uh we have installed right. So that is where it will come into picture. So from pyantic again pantic okay import base model base model okay so next from typing okay import list dict any list I don't require as dict dict okay so this is a agent config so now so I writing a class called agent config which is a uh you know base model. Okay. So now thought thought can be what guys thought can be I will just write it as string. It it is only it is it will only you know uh take the value and give the value as string action again it's str okay next input input can be it we can write like dictionary dict string any so this will be my schema. So thought, action and input. So which is aentic concept what I'm trying to tell here. Okay. So this is schema. So this schema is completed now. Okay. Now what I will do guys is that I will try to write actual agent here. How we can write the agent which is very important concept. So please be um attentive so that you you guys will understand the full things full picture on the ground. So let me write agent.py. My tools got completed, schema got completed. Now I am moving to uh agent.py. Okay. Hope I understand. Uh hope everybody is understanding otherwise no problem. We will just have some you know uh I mean I will just um make you understand. Don't worry. Okay. Agent py from agent. Okay let me do one thing. Let me start with llm.py first because I need to call these things in the agent. So let me call llm only first. Okay. So in AJ llm. py what I will do is that uh I'll just do don't save lm.py. Okay. So what I will do import so import OS. Okay. OS is very important here because I need to import grock also here. JSON. JSON is also there. Import Grock from from from from sorry from grock. Okay. import gromp import okay from env load env so this is done so importing part is done now so now load what I need to do guys I need to load the environment variables using this load env okay so now what I need to do is I need to create one variable so let me create client equal to grock os dot get getting me uh grock API key. Grock API key I already set here. So as of now what I will do is I will take Grock API key from my environment file and I will copy paste here. Okay. So this is grov guys. So nobody should see that that's why I just wanted to you know hide that. But grock env will be stored in the environment. Okay. So that grav I have already stored here. So you guys can also see this gro API I'm storing in the environment and lm.py. So the same uh gro API is calling and it is assigned to client. Okay. So hope this is clear. And now what I will do is guys is that so let me go to llm.py and I have my system prompt ready. So to type that it will take lot of time. So what I will do is I will just copy this copy this system prompt and I'll paste here guys. Okay. Because again why to write right that I will explain this on a overall things right. So this is my system prompt. Uh let me do one thing. So hope you are able to see my system prompt. But yeah let me explain this in a deeper way. But yeah system prompt is the one which you need to understand. So you are an autonomous agent. You are always respond in a JSON's format. So thought, action and input as I said in the schema. Okay. So available tools is calculator is one of the calculator is one of the things which is expression 45 into 12. It is already giving 45 into 12. So this is expression which will you know run in the this one and shell commands. I should list the files in the directory. Okay. So files in the directory means for example guys I am in a terminal. So let me open new terminal right. So I am in the terminal now. Okay. So let me go to the terminal. So here after this agent from scratch what is my list of files. So that will actually call in the run directory. So that is also there. So rules action must be one of the calculators run shell finish. Okay these are the rules and never intend tool names and always return valid JSON. So this is my you know rules what I have set to the system prompt where all the rules should be uh you know what it will do is it will call the AI and it will go through the rules and now what it will do is it will set up everything. So that is very important. Okay this is the rules what I'm giving the LLM that please act act according to this okay so this is a system understood guys. Okay let me close this now. Okay now straight away we need to go to coding part. So this system prompt is completed. So now after the system prompt is completed, what you need to do is I need to create one function called def call lm. Okay. And what is the input guys for this? My prompt prompt will be my input and it's in the string format. Okay. So now what I will do? I will do dict and this one I will explain. uh so model equal to uh let me go to llama 3.1 instant which is I am using as this this one llama no and prompt and uh messages messages messages equal to ro user system prompt and ro user and temperature we can set and max token is not required temperature is we can give as of now we can give it as zero. Uh yeah let me check for this point 7 and content next what I will do content okay content I'll create another function called response dot choices okay message content so this will be my content and later so you need to convert that JSON string to Python dictionary so That's why I will just told JSON.loads what uh content because already content I have given in the above section content. Okay. So this is my llm.py which includes you know I loaded my gro API key and I have given my system prompt. You know I'm calling the lm using my gro. Uh so here I need to give client. chat dot completions dotcreated. Okay. So I'm creating calling the llm using this function which is uh model response equal to this and model messages and you know temperature I'm giving and content uh the final response it is coming in the content and I'm I'm just converting this JSON to Python dictionary. So this is my llm.py guys. This is my llm.py. Okay. So this this is completed now. So llm.py py is completed. Schema py is completed. Tools py is completed now. So now important section which is agent py. Okay. So agent py uh so what I will do? So from so now I'll start with agent. py from agent. Llm. Okay. Import call lm. Import call lm. Okay. from agent dots schema. So all the things I am just you know importing here import agent action. Okay. So from agent dot tools. Okay. Import import. I will just do tools here because tools I have already disc uh already instantiated there. So what I will do? I will just have tools here. Okay. From agent domemory. Okay. Let me also complete memory first then in that case so that I can run everything using agent dot this one. So memory is very simple guys. Uh let me go to memory. So what I will do is I will just create one class memory. Okay. So what I will do is def in itself. Okay. Self doe events. I'll add self dots. Selfevents. So now def add action def add self uh here what I will do event comma event sorry event str I will add event strr okay so self dotvent here I will add event here okay so now this is added now I will what I will do this instead of this I will add context here context context so self uh I just can add limit also here limit what int equal to five okay so this is there and memory py return join self dot events okay so I will add limits here minus limit Yeah, I think this is ready. Uh this much. Oh, so this one I'm just giving the context and adding those memories here. So this is what I am just adding that uh you know context and I'm adding the self events and I'm appending to the events what what it's already there and context also I'm giving and limiting this to five in five. Okay. So memory is completed guys. Uh if you can just see memory is also completed. Okay. Now what I will do? I will just go to agent now. So already I imported this memory class memory I have imported in the agent. Okay. Simple. So now what I will do uh so agent's memory is completed. One second. Memory. Yeah, memory is completed. So now I will go to agent agent. py. Yeah. And I will try to create one class which is agent. So which is very important. I mean I'm just creating one class def init self. Okay. So here what I will do I will add goal also because goal as I said in the architecture diagram goal is also goal is the one which is important what I need to do self dot goal equal to goal okay self dot memory equal to memory so this one I will add it as a steps here okay so now what I will do I will create another things called def step self okay So what what and all it should execute right in the uh in a agent for example. So first what it should execute is I will just give uh thinking okay what agent is doing I'll just think like thinking okay and prompt equal to what guys prompt equal to uh f okay uh f k goal equal to self goal. So that is also very important goes and next what it should do uh memory memory self memory self memory context. Okay. So next uh what should I do next also I mean I just adding this what should I what should I do next? Okay. So I'll just give respond in JSON. Respond in JSON format. Okay. So this is that this is completed now. So what I will do is I'm just starting this things and I'm just telling give the context and you know put it in the uh JSON formatter. Okay. So once this is done what I will do is I will just come this side and I will just enter uh raw response raw response you know call lm lm call llm that is also there and try okay let me check this raw lm go yeah now try try right so try What I will do? I will add this you know action equal to uh action equal to agentic action agentic agentic action dot sorry action equal to agentic action that corresponse. Okay. Now this one accept. Okay. So this is this is how it works. And uh now what I will do I will print invalid response and I will return the things. So this is try and this is accept. Except is the one which I to enter. Okay. I mean that's fine. Whatever it's there that should be fine. I think is we should understand the concept later. You can just see that. So return what guys return equal to true. So return equal to true. So you're just taking the raw responses and you're calling the agendic actions here. Okay. So now what I need to do print. Okay. So thought action dot thought what you want to display? So you are displaying the action dot thought. Okay. So now if action so based on the action you need to write the uh next steps here. Okay. So let me do one thing. Uh raw response. Okay. Now what I will do is action thought is done. So now uh if action dotaction finish. Okay. So action.action sorry if action.action in tools in tools right so now I think only this little is there I'll just add this as a step here so one second let me check that huh so what I I will do is I just had that backup so what I will do is that call llm is there okay I will explain from here so action in tools so what I am doing is I'm I'm creating the tool section here. Okay. Where I am printing the tools and I'm adding the memory here in the result section. Okay. So if the error is coming then tool error will come and else unknown tool will come. So this is return true. So basically what I'm trying to create is if the exception conditions are there you are creating the exception conditions or if the tools are coming it will it is adding the tool section here. Okay. So this is how it works and you know so this is how this agent is there currently. So this is much this much we have done. So this is this much is there in the agent. So which is agent llm memory. py schema. py and tools. py which is which I have already written here. Okay. So now coming to very important part which is main. py main. py what should I write. So main py it should have the goal. It should have the practice. So what I will do is from where important is I am I'm declaring from agent from agent dot aagent import agent. Okay. So def I need to include run agent here. Run agent. Okay. Run agent goal str you know. uh so what I will do here is guys I have this print statement and everything so I'll just from agent agent is already there so what I will do I will just enter these things okay so what I will do I will just uh so what I'm doing is guys so main py is there so agent a agent import agent. So run agent what it is doing it is starting the agent and it is giving the goals here. So here agent is the goal what I am assigning this is a goal here the goal can be it can be you know two things right one is calculator also and it can be uh run agent also so what I will do here max steps I'm giving only two because it can it will actually do two times right the agent will run two times for two in two outputs also so this is what I am trying to give in the main ml so it can be increased this max steps can be five max step test 10 I will show you guys uh that those things right so I'm just hardcoding this max steps as a flow so you can parameterize that also that's not a problem at all okay so this is agent uh this is the main important main py which we are getting from agent py which has uh looping for llm py memory py schema py and tools py okay so so this is the ar architecture guys I will try to you know run this command uh so I will just go to new terminal So here already existing terminal is there. So what I will do is I will try to run uh try to run Python. One second let me this do this first enhance this first so that we'll get the proper output. You guys can see I'll do just cls so that you guys can see my output. So python you know main.py. So basically what it is doing is it is calling the agent it will call the agent. Okay let me check gro.init some problem is there in the grock.init So takes one positional arguments but you have given two that's what it's telling okay let me check that agent py and lm pym client equal to this one right one second guys okay Uh okay guys, I think we can start now. Uh let me check whether these agents are working properly or not based on the structure what we have. Uh so let me go to my main folder and I'll just try to start I'll just try to you know enter this Python main.pa and see what happens guys. Okay. So basically it should call two tools uh which I have created now. So which I have configured in main.py PY and let us see what will happen. Okay. So if you see here guys uh so if you see here so as I given that it has thought I should calculate the evaluate expression. So basically where it will go is it will basically it will go to main.py here. Okay. So first agent first agent is what? So agent is calculate 45 into multiple by 12. So which is 540. Okay. So this will execute two results. So since I have given max step as two so it should it will execute two times. Okay. So hope you guys are getting my thought here right. So next what I'm doing is so it should actually tell that you know ls ls results right. So it should actually tell the commands here. So basically if you see here all my you know uh list of files are been displayed here. So this is this is how you know it is calling the agent properly and it is giving successful output here. Okay. So basically how it works is that I have called two things and you know it is delivering two things and it is integrated to the agent first and LLM is deciding which tool it should call right but here since I have given two agents right so one is calculator I have given and another is shell command examples right. So basically it is running two agents. So basically you we can just see how LLMs can be integrated with the tools and how it can be saved in the memories you know so that you know you don't want to you know uh what do you say uh you don't want to remember all these things so that you know that agent will be self-sufficient from next time onwards. So it will only list the files and it will al it will only when you call these tools it will only list the files and it will calculate the calculated examples right. So this is where this is what I wanted to explain you guys the multiple you know output things right when we are starting with multiple agents right so this is how it starts right so it will start and it will get the goal what is the goal and it will start with the goal and here what I can do is for example if I want five times for example if I want five times okay so what it will do is I will just explain here so it will run five times here so if I just do This see here guys if you're able to see my screen see here so it is already running five times 1 2 3 4 5 so this is how it's like uh you know we have created this agent and this is also we are listing down the directories here uh so what I wanted to say was uh so you guys see how this coding structure is there you know I will push all these things to my GitHub repository and I will share the GitHub repository but please go through this kind of coding because starting may you know you can't build any uh you know uh very very very uh big tools right big tools so first start with these things because these are like you know basic things what I'm trying to explain see listing files and calculator everybody knows everybody knows those kind of tools right so you need to actually think like you know uh you are a beginner right for example if you are starting anything right so you should not go to complicated codings or complicated building complicated agents okay so if you start building those things you will get somewhere you will get you know you will not get that information properly or somewhere you will feel like okay it is very you know uh difficult or something right so you will feel that but when you start with you know beginning very beginner friendly tools right for example calculator you guys know and listing of files you also you know you will just do this uh uh you know ls or you know if you guys do cd you'll go to create directory mkd those are the unique commands you guys know that because that is the very simple things okay let us leave uh shell command also let us calculate only calculator tool right so calculator tool everybody knows what kind of tools everybody knows right so it is like a beginner friendly applications what we are trying to build because next if you go to you know if I want to build complicated applications also you can relate to this kind of uh you know uh tutorials right tutorials means uh building tools. So building tools everybody can do like simple calculator is also one tool only you know that is not you know uh rocket science that calculator building is also tool see if I added addition next it will add like multiplication multiplication I have added addition also it will come you know I just need to give that prompt properly so as of now I have given prompt 45 multiplied by 12 so it is giving 540 so I have created my calculator agent so whatever the prompt you give it is giving the response for that Right? That is the calculator agent. So, LLM what it does? For example, LLM if you feed 45 into 12 also LM also will give the answer. But simple is that where you are calling that tool. So, how the LLM is calling that tool to make sure that it is self-sufficient to give that not self-sufficient to give the answer. It is calling the external tool. So, then LLM also will become powerful. Right? If external tools are uh you know uh embedded so LLM also will become powerful because LLM has lot of capabilities but in tools if it is integrating it will have even more big capabilities and also memory so it will add everything to the memory so next time if you don't want to add the context only you will get the context in the memory itself so it will add in a loop as I told in the architecture right so these are the simple things which you guys can understand learn those things you know uh so uh you know quickly guide those things you know very informative way so that you know you will get all the things in a proper way guys I mean you guys will get uh the information in a very beginner friendly mode so that you guys when you are building any complex agent you can relate okay I'm building one tool so using in tools py okay I'm building one agent in agent py so llm py is to uh so bas basically I'm using grock here sorry for so I'm using grock here but grock for that also we need to interact means we need to write a python file that is lmp agentp what we are doing we are getting all the things you know in the clear ecosphere and we are calling the agent okay so this is where I want you guys to understand the framework first ecosystem of how to build identicare framework Right? So then we can go to building complex things like multi there are different kinds of you know agentic applications we can try to build but this is the basic this is a foundation this is the framework which we need to follow see lang chain has langraphs everything is there okay if I straight away starts with lang chain and lang graph you guys will get confused okay that's why the basic framework I'm trying to explain here next if I build any complicated things also then exactly you will come to know that Chaitan why he's building that because he's creating an ecosystem right so this is where I wanted you guys to explain this is a beginner friendly application please go through these things and if anything is there please comment it out in the YouTube channel and if anything is there if any doubts is there I'm happy to connect with oneonone also that's not a problem so I will connect okay if anything is there let me know so that I will check check and this things will be pushed to GitHub repos also repository also so that you guys can see that what I have done exactly and you guys also can follow these things. Right? So this is uh this this is where I want you guys to learn as a beginner friendly so that you guys will understand in a later part of okay. So this is how I wanted to explain you guys and if anything is there please as I said uh please comment it out and if you like this please like this support me you know so that it it can reach to multiple members you know who are eager to learn. So if they are not aware of this channel it will be helpful for us. Please like, comment and subscribe to the channel for more updates. More updates are lined up already. So I am going to teach line by line what I have written, writing and you know what I am doing. I will try each line line by line and we'll try to build the identic applications and as of now I have just built one you know uh small things which can be done in terminal but again UI things and all we can we can do for bigger projects. I don't want this to be you know writing in the UI and all thing because this is very small uh logic I have built here but yeah as I said all the things are lined up so please subscribe to my channel and uh you know please like please comment so that everybody will uh try to understand everything uh it will reach for maximum basically uh and if anything is there please try to connect with me DM me in LinkedIn or you know uh directly comment it out in the YouTube channel. Okay. So, if anything is there, let me know. Yeah. Okay. Uh so, yeah, guys, that's all for for this uh today tutorial. Uh hope you guys have enjoyed this uh tutorial. Uh yeah, see you in the next one. Until then, goodbye. Take care. Bye.
Original Description
🔗 GitHub Code:
https://github.com/chethannj/AgenticAIFromScratch.git
In this video, we build a real AI agent from scratch using Python.
Instead of just calling an LLM, we create an agent that can:
• think about a goal
• choose tools
• execute actions
• remember previous results
You’ll learn how agentic AI systems actually work by implementing:
- an agent loop
- tool calling
- memory
- structured JSON outputs
We also integrate fast LLM inference using Groq and Llama models.
By the end, you'll understand the architecture behind modern AI agents used in tools like AutoGPT and other autonomous systems.
Project features:
• calculator tool
• shell command tool
• agent reasoning loop
• JSON validation
• modular architecture
This tutorial is designed for beginners who want to understand AI agents at a deeper level.
Subscribe for more content on:
AI agents
LLM architecture
agentic systems
autonomous AI
#AIagents
#AgenticAI
#LLM
#PythonAI
#Groq
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
More on: Agent Foundations
View skill →Related Reads
📰
📰
📰
📰
Navigating Claude Code: Subagents Done Right
Hackernoon
What’s the best way to trace AI agent decisions and ensure auditability in 2026?
Medium · AI
What’s the best way to trace AI agent decisions and ensure auditability in 2026?
Medium · Machine Learning
What’s the best way to trace AI agent decisions and ensure auditability in 2026?
Medium · LLM
🎓
Tutor Explanation
DeepCamp AI