I Built a ChatGPT Chatbot in Python — 1-Hour Course
Key Takeaways
Builds a ChatGPT-style AI chatbot in Python using Streamlit, OpenAI API, and chat memory handling
Full Transcript
Hello. Uh yeah, just want to check my audio and the video is proper. Hi. Uh, I'm audible guys. Can you just ping me? Am I audible in the uh live chats? Okay. Okay. Thank you. Uh, okay. I think we can start. Um only thing is I just wanted to check whether all are um all is correct or not and hope my screen is visible and uh yeah welcome to the sessions. Uh so this is like uh we are going to build uh our own AI chatbot lives right. So we have few requisites uh to the session right. So basically what we are trying to build is the uh initial part of initial skeleton of you know charge okay it's like not more advanced it's like a initial setup of chity what we are trying to do and uh one thing what I can explain is that so this session will be useful for the uh users who are like uh just a beginning uh in their AI career and uh you know they their students Right. So they will they will have this these kind of sessions and also uh so if people are like you know started their career in AI space so they actually get a help from this kind of sessions and also it's like a beginner friendly no worries like if you don't know any technical stuffs also that's not a problem. Uh I will start from scratch. Okay. So there is no not at all a problem where you can start uh like uh scratch we can start from the beginning. that's not a problem at all but um you you just want to have some of the basics of Python. I think that's uh that will also come like in this session only like for example if you don't know that experience of Python also just wanted to uh explore this kind of ideas and you know uh we can just do it that's not a problem at all for in this live session okay so yeah I mean we can start with you know uh for any application right uh so architecture is very important right for any application so what I'm trying to do is like I will just explain the basic basic architecture of the application what we are going to build now. Okay. So because the uh the basic thing is that architecture of the application. Okay. So if you look into my screen there is a architecture diagram already there already in your screen where first what is chatbot right? User will ask any question and the uh API will you know respond to that message right? That is that is nothing but chatbot right? So basically what is this architecture is looks like like user will ask any questions and that will actually go to the UI right it's it's a front end right for any application three major component will be there one is UI one is API and another one is uh back end right so this this is not this is part of application right so basically this is what is happening in the AI chatbot also okay so when user asks any question it will go to the web browser and it will go to the streamlit app. Streamlit app is the Python's front end you can tell. So there are different types of Python front end like flask we have and different types of app but simple is streamllet for the beginners. Uh streamllet I suggest streamllet because it's a beginner friendly application. So next what we have is the python back end which is like a open ai client. So we will going to hit the open API open API client which is powered by chat GPT you know we will have the API key and everything I'll show you like how to you know fetch the API key and all and next what we are going to do is we will have the streamllet application again coming with the response you know and web browser will show the AI reply okay this is what we are going to build currently so this is what is the application architecture diagram so if you don't understand this slightly if you Right here I have almost written the structure of the uh structure of the data. So user will be there. It will go to streamllet. It will go to Python code. It will call the Python code. It will call the open API GPT and it will back come back to streamllet and next it will go to the user. Okay. This is how the applications architecture will be there. Okay. So we will going to build this uh live right. uh in this kind of architecture we are going to build live and I will show each and every step. So if any steps if your guys are like getting mistaken so you just start with this things because uh I think this is important right because if you don't understand the architecture of any application you are not able to build that application okay so this is where I want you guys to understand this and uh if you have any questions please type in the comments so that you know I can reply for everything and simple also that's fine right because we are starting as a beginner beginner friend okay Sure. Okay. We'll going to start first with creating the uh we have almost set the environment. I will explain what is the environment environment things. Okay. So first important thing what we are going to do is we will we need to create one virtual environment in our application. Right. So what we need to do is that we need to create one virtual environment. For that first we will see whether Python is getting installed in the application. Okay. So here if I type Python version. Okay. So Python is already installed in my application. Okay. Maybe Python application. Installing that application is very easy for you guys. Uh one second guys. Yeah. So Python installation is very easy for the applications what we are trying to do. So just if you round back to the terminal here. One second. Sorry guys, one second. I'll just go to the terminal view. Okay. So, Python is very important in this stuff, right? So, what I am trying to do is I will just start with Python version. Okay. So, Python version it's already installed in my machine. Okay, this is one thing what I wanted to tell. Okay, next what we will do? We will create one virtual virtual environment. For that we have one command called python- m vnv vnv. VNV is nothing but creating the virtual environment inside the python. Okay. So once after you click on this okay suddenly if you see the left hand side left hand side you have the VNV created that VNV structure has created from the VNV command. If you see in the left side right that VNV folder is already created in this application. Okay you you see here this VNV application that VNV folder is created for us. So it's creating just give a couple of minutes it will it's creating now. So once that is created, I will just explain you guys. Okay. Uh okay. Yeah. So it's created now. VNV is created. VNV means virtual environment. I will tell the necessity of virtual environment why we will create. Okay. So for example, you wanted to build different tools inside one space, right? one space means you want to build one chatbot, you want to build one a trip advisor, you want to build some other uh content in the AI space right so if you want to build like that right you want to have the virtual environment because every time the dependencies of the application will not be saved for example here I am using some dependencies and some of the other stuffs we will use another dependencies so we can't tell like that like what dependencies we need to have so for that what we will do is we will create a virtual environment. Virtual environment means that is own your own private space what we are trying to do right so where you can install the application in your virtual environment okay that is why we will create virtual environment for each and every applications okay now how to activate this environment okay so you have created one virtual environment so how to activate this environment so if you go to the scripts and here right here there is one command called activate okay so you click this and copy relative path and come here and just click on this. I mean you just copy that path. Okay. Whatever the path we have. Okay. And click on enter. Okay. So as soon as you click enter so you see here VNV has been activated. It means that you are already in that virtual drive virtual environment. Right? So that is where it's very important for us. Maybe I can can just zoom in here. So leave about the old code here. So if you see here, right? So VNB has been activated for your application. Okay. Understood? Understood? Till here guys. Uh if anybody has not understood uh you guys can start, you can you guys can you know click on the chat and you guys can start. Okay. So this is the way we have activated the virtual environment. Okay. So till here this is till here it's a creating of the virtual environment. This is the step. Okay. So, next step, moving on to next step. Okay. Now, we need to create the dependencies now for this application, right? What are all the dependencies we want to create for this application? That is the main thing. What is the important thing what we need to capture here? Okay. What what dependencies we need to create? So, there will be three dependencies for this application. Okay. One is first what we will do? We'll create one uh we'll create one text file. I'll explain why we are creating the text file. Okay. So, one second guys. Okay. I will go here. One second. Uh I will just create one folder called uh sorry uh file called requirements.txt. Okay. Requirements requirements.txt. Okay. Uh I'll refresh this. So automatically that requirement txt will come here. Okay. So this is requirement.txt. So what are all the things what we need to create here. Okay. One is you want streamllet, right? That is your front end. You want streaml in the application. Okay. Next you want is open AI. Open AI means you need to call the open API API. Open AP open AI API right for that you need open AI uh dependency okay and uh these are the installation of package guys okay so python next env so this one I will explain so when you want to you know fetch the APIs from the open API right you want to have it in a secret uh basis right so for that we are using pythonv uh this one dependency okay this is this is how it created okay so now coming to here right uh just uh okay so I have created this okay so now coming to this whatever the dependencies what I have created okay uh let me delete this it became like a duplicate for this okay so these are all the dependencies which we need to create okay now what I want to do is how to install these dependencies into the Python this is a very important steps so you have already come into the virtual environment So now how to install? Okay. So for that I will use pip install minus r requirements.txt. So this is a command guys. Okay. So for python has already installed. So this is a command which I am passing because requirements.txt I have three com three this one I will pass it and I will you know I will install it. So as an as soon as I do right so dependencies will start to download. Okay if you see here right so dependencies is getting downloaded guys. Okay so it will take some one or two minutes to download all the dependencies just we will wait for that. Okay uh so it's downloading all the dependencies with respect to streamlit openai and python.env. PNB just we will give couple of minutes one one or a couple of minutes so that it will download everything okay and before that if anybody has any questions uh if you guys have any questions please uh raise your hand or you know whatever you want to do you just type it right because it's basic right so everybody will have some some more the other questions like if it is pretty basic also I can answer that's not a problem because even I learned from the scratch right even I had lot of questions before learning these things so it's it's good that if you have any questions you guys can ask in the live session okay uh okay uh so the dependencies are getting downloaded so let it download the dependencies for 1 minute and we'll start okay so let it download And I will just explain like how to fetch you know uh open API key before that right. So we can use this time to how to fetch the open API key. Okay. So let me switch to my chrome. One second. Sorry. Sorry. Sorry. Let it download. I'll just put it in the hold. One second. There is some glitch in the application. One second. One second, guys. Give me one minute. I'll just come back. Uh guys uh can you just comment out whether my screen is blank or is it visible? Just can you comment out uh some technical glitches there? Uh one second. Let me start from beginning. Another one is displaying but I don't know why visual code is not displaying. One second. Let me start from the beginning guys. Yeah, sorry. Yeah, it's visible now. Uh yeah, sorry for the glitch, guys. Uh I think now it is okay. Yeah. So I think it's downloaded now. Okay. It's downloaded. So what we can do is uh we have just downloaded that and yeah I mean uh guys again the thing whatever I am going to share right now. So this one actually uh I will put it to the Bitbucket uh sorry Git repository. Okay. So don't worry about the coding things uh so that you know you guys will get the things whatever you required. So now I think the dependencies got downloaded. Okay. Uh just straight away we will go to the coding part. Uh so it will be helpful for everybody to start with the coding part. So let us start with the coding. Okay. First what I will do is I will create one uh command called uh uh sorry I will create one Python file. Okay. I'll create one Python file where I'll start with them. Okay. So what I will do I will just create one Python file in the like a chatbot. Okay. I'll create one for uh Python file called chatbot. Chatbot py I'll create that. Okay. So yeah chatbot py. Maybe I'll just rename this to py. Okay. Yeah. So this is a Python file what I'm trying to create. Okay. Um so what I will do is that I will start from fresh. Okay. Whatever is there. So uh important stuff is that so first what we need to do is first what we need to do is we need to import some of the libraries. Okay. Here we need to import some of the libraries that I'm trying to do. One is that import OS. Okay. OS. OS means guys uh so for example if you want to do that right you have stored one env file uh so basically env file will have the API key okay so API key will be secret key okay which we can't share okay I will maybe I will explain you guys how to fetch the API key at the end of the session uh maybe you guys can try that but again uh API key you guys can also do okay two types of API keys we can generate one is that one is free sourced Right? Free source is like grock and different kinds of APIs will be there. That is like a free sourced API keys which we can fetch. Okay. Another one is that open API. Open API will have around like if you recharge for $5 or something. So you can just uh you know hit the APIs numerous amount of times that is also there. Okay. I will at the end of the session I will show you guys how to fetch the API key also. But as of now we will concentrate on the code. Okay. So this is the package what we are trying to import that is import OS okay so this is like a uh you know to read the environment file we will use another thing called from env import so this is the uh another uh library which we are trying to use which is from env import which is to read that environment open API key okay that is the another source of this one next we want what We want UI, right? UI means we want streaml. Streamlit to we want it as it is, right? Next what we want like we want open AI. Open AI, right? Open AI is what like we are importing from uh open AI. Open AI is the library which we are trying to address. Okay. So now uh this is like a importing part. Okay. First OS means we are trying to import that. Okay. And from env we are importing the this one is like guys this is like a reading the this is just used for reading env file. Okay. So maybe I'll just comment it out so that you guys can understand. So this one is like uh UI. Okay. This is UI and this is the open API key. Open API key. We are open API client client key which we are trying to fetch. Okay. So this is like a this one. Okay. Now how to load the environment variables? You have imported all the stuffs. So that is important. So what we will do is first what we will do we will load the environment file. For that what we will use is load load.env. Anyways we have declared that is a function generic function which we are trying to do that. Okay that is like a load.vironment file that that we are trying to do. Next what we will do? Next we will fetch the API key right API key from the env file that is very important. Okay. So open key equal to OS dot OS means we have already imported that get get env get env means that is a environment variable and already I have described the open a key in this right in this env. So that is getting fetched from the API key. So my API key variable will have this content. Okay. Whatever the stuffs we have. Okay. So this is important. Okay. So maybe uh for beginner friendly things I will just start with this and maybe uh what I can do is uh next I will show you guys how to uh do the uh this one also. Okay. So now how to initialize the open API client. Right. Because now we have imported the open API key from the open AA component. Okay. Now how to initialize that? Okay. For that what I will use is I will use client. Client is like a just you know uh is a variable. Okay. So what I will use is I will open AI. Open AI is the variable what I want. So API key API key is like a variable. And what is the API key? API key is the fetched one API key. So that will be our API key. Okay. That is another part. Okay. So now first what you understood is this is like a guys this is initializing the openi initialize open ai client. Okay so understand this this is very important. So we need to initialize this openi client. Okay that is one thing. Okay second thing is so first we have initialize the open client. Now what we need to do we need to uh you know initialize the streamllet right because that is like a UI for us that is very important. Okay. So already ST has been we have the variable called ST okay ST so what we can do is set okay set config page config set page config so we need to in instantiate the title now title is very important guys okay so title is page title you know chatbot with streamllet and open is can be the f I mean that can be the page title so that one we can start page icon also we can start So we can start with multiple stuff. So we can enter multiple parameters here. Maybe I'll I'll uh I'll start with that whatever the things are there. And next what we can have is title. Title st. Title will be like you know what can be the that is a page title what I have given. Page title means it will come in the browser. Okay. So uh say title means whatever we have the this one. Okay. So title will be your person what what can be there your personal your personal yeah let it be like a robot thing okay personal chatbot okay next what I can do is uh yes I will write I mean you can ask anything for the robot right so for that I will just ask what ask me anything or something like that I can add okay so next so this is very important important. Okay. So now I have added these things whatever the stuffs what we want to do. Okay. Initializing the open AI client and streamllet I have invoked. Okay. So this is the first step. Okay. Second step is I want to create the chat history. For example, if you remember right in chat J also if you want to have the history of the previous messages right. So you will have the creation of the chat history there. Okay. So that is very important in any chatbot. So you need to create the chat history for them. Okay, that is very important. Okay. So now to create the chat history. So the next what is the thing is like creating the chat chat history. So that is very important guys. Creating the chat history is very important. Okay because when you want when you didn't create the chat history then it will become like a uh so it is like a starting from fresh. Okay. So now for that we'll use messages. Messages is like a using term if messages. Okay. So messages means what I will tell is uh so basically how it works is for example if you have one chat okay what is my name for example. Okay so I will type my name is Chetal. Okay next what it will is what are what are your hobbies? What are my hobbies? It filter. So, so instantly chat uh instantly that AI chatbot will remember my name and tell Chan has a hobbies like Chetan has hobbies of cricket, batmitt or TT like that. It will just mention my name. For example, first if I introduce my name for that. Okay, next message it will address me as Chetan only. Okay, I will show you guys once this application got created. I will show you guys how to how that messages work. Okay. So that it will be easy for you guys. Okay. So this is like a messages. This is uh this are this is the variable. This condition I am adding saying that if messages not in uh session state. Okay. So next I am putting that all the messages in array. Okay. Array this one is very important. So this I am creating the one array. So ST session state dot messages. Okay. So this one I'm creating. So this one once that is created. So creating chat history I have done. Okay. Now now I need to display the previous messages. So for example if previous messages are there for example you will open multiple chat windows right? For the uh for this one. Okay for that I will use for loop. Okay for message in st messages. This is very important guys. Okay ST state messages. And so there will be a two sections here. One is like a role and one is content. Okay, that is very important. So role means for example if you want to give any role for that particular user right I told Chan that is my username for example content means what content I'm trying to add to the messages that is very important okay so if okay this is a condition if message role equal to user okay SD markdown that as a message content so this is like a chat message what I'm trying to do okay st dot st dot one can st chat message chat message so that message content it will get added here okay this is very important and else what I am trying to do else I will try to do the market language this is very important guys so let me add that this is a snippet uh this else condition also I'm adding so here the messages uh content will be every every And this will be same always. If else let it be aligned properly. Okay. So this is the one stuff what I wanted to tell you guys. Okay. This is the displaying the previous messages. Okay. So till here any questions or anybody has anything. Uh so AJ is asking import OS is used to deal with files with using Python. Yes correct. Oh, you're not able to see me. Okay. Sorry. Sorry. Due to my Okay, hopefully you are able to see now. But uh yeah, sorry guys. It's fine. I mean content is important but yeah uh yeah hopefully you guys are able to see now. Um okay now what I wanted to tell is guys so if messages import important thing is that messages important thing is the message section what I'm trying to address here. Okay this is important displaying the previous messages. Okay. Now what I will do? I will get the user input. User input is the one which we which is very important in the streamllet, right? Because we need to have the user input otherwise uh there will be nothing, right? So what I will do I will just start with user input first. Uh what I will do is that okay first I will do user input accepting the user input. Okay. So now for user input what I will do is I will section the user input uh term right. So what I will do I will chat input the message type your message here what message you want to type right that is very important in terms of user input. Okay. So what I will do? So I will add one condition saying okay uh so if the message contains the whatever the contains is this one is there. Okay you add that message to that particular thing or otherwise what you can do is you can just do the sample [clears throat] stuff. So whatever we want to do okay that is very important. So because when you add that message right so when you type that message you want to for example if user is adding to the history for example chat history. Okay. So you want to show that message in the proper way. So for that actually what I'm trying to do is I will start with one condition called if user input. Okay. ST dot session state. Okay. Uh this is the code. Okay. ST dot session tok uh session state. Okay. Contain user input. Ro user contain contain user input. So this is your input and this user whatever is there append to the main program. That is very important guys. Okay. Uh so next what I will do uh I will start with uh next we are added the message. Okay. Now we need to show that user message. So how to show that user message that is very important. So show user message in the chat. So you accepted that. So how to show the user message that is very important. Okay. So for that what I am trying to do is with with st.m message user this is correct sorry st dot message user uh so this is a condition so now st dot market down user input so this will add actually show the user message in the chat that is very important okay so till now what we have done is I'll just go through a briefs One thing is that first what we have done we have loaded the environment file environment variables to the env file. Okay. Next what we will do is we have initialized the openAI client. Okay. We have not invoked that but we have initialized that's it. Okay. Next what we have done is we have created the chat history. Chat history is very important. Chat history we have created. Okay. Next what we have done is we have done the previous message displaying and we are accepting the user input. And now show user message in the chat. So till now it's it's clear right or you guys have any questions for this. Uh so but yeah I mean as of now I'm just going through this but yeah so till now we are clear with this terms whatever the show user message in the chat and other things right. So till now we have done till here. Okay. So let me save this. uh next what I will do is next the basic thing what we wanted to understand guys is till here whatever the things what I what I'm going to share now right so we have done a basic structure now streamly structure we have done show user message till user message in the chat we have done okay so next section is very important guys because next section whatever we are trying to tell is the generating the a response right so you want to generate any any AI right it should generate AI response means how you will call okay so there will be three steps here one is that you need to have the chat message okay and AI should think that okay a should think whether what response will come okay and another thing is that you can use multiple model there are any number of models here okay you I am just doing in open AI there are any number of models in a AI space where we can use these things guys okay but What I'm trying to explain now is that I am using openAI model because I feel that that has good uh accurate you know uh what I can say response right charge you guys know in any day every day you guys will use the charge right so that's where we'll do so next what we can proceed is we will proceed with generating the response generating the response using AI this is very important step okay so for that what What I will do with the ST chat message assistant. So this is like a you know uh so what I can tell is uh assistant some for example if any anything which should happen right for example you should have some chat message things and also with st.spinner spinner thinking for example you want to tell that okay for example user is waiting okay you should think uh you should tell like okay it's thinking right so that's where we will just do that okay so now I will write try block okay so what I can do is guys so this is like a u now I will this is like a try block one second okay so now what I will do I will send the chat to see send the chat. See this is very important. Send the chat history to GPT. This is very important guys. So we need to send the chat history to GPT. GPT model. Okay. So this is a try block. Okay. So now response. So see already you know right we have initialized here client if you see here right. So here we have already initialized the client. Okay. So now what I need to do I need to fetch the response from the client. Okay. So for that I am using client.hat chat.comp completions.create. Okay. So model you guys can use anything guys. Uh so what I will do is I will use as of now I will use GPT 40 4 mini. Okay. Because I feel that mini is having the less turnaround time. Okay. That's why I will use mini. Okay. And also uh messages. Right. messages I will what I will do messages I'll put it in one array messages equal to okay so this one is in array I will do and I will store all the state messages whatever I have content messages I will store it in here okay so this is the try block what I'm trying to add uh messages okay so one second Okay, just try to add here. Yeah, this is very important. So, this is a try block. So, this is like I will explain you guys why what I'm doing now. Give me a minute. Uh, okay. Okay. So what I'm trying to do is I will explain you guys. So what see the content can be like a you know uh for example right I'm calling this uh GP4 mini and I'm including all the messages to the full chat so far whatever it's done. So it's like a history kind of thing what I'm trying to do here. One second I'm facing one error here. One second guys. Try block. Okay. The try block I need to close. One second. One second, guys. This okay. Uh oh. Let it be there. I mean, that's fine. uh later we can debug that. Uh so that is generating the a response. Okay. So that is one thing. Okay. Next thing is that generating text from the response. Okay. Now a message we have. Okay. A message. A message we have. So that one we need to fetch the content. Right. I will just ah do the a message equal to response choices.0. Okay. I will explain this zero. Right? Zero means the current message guys. Okay. Respond choices zero. Message.content content means it's a current message whatever we are trying to fetch from the AI message. Okay. So that will be the next thing. Okay. Next what I can do is uh next I can display that AI message. So for that I need to display in the stream. Right. I will just just display in the stream. Okay. So this is the first thing what I wanted to uh do is that when you save this right once after you save this whatever the things are there. So you want to save that AI message to the chat history also because uh if you want to save that to the chat history right for example I will tell hi my how are you okay for example I I need to save that a message into the chat history so that for that we are using the session state session state so that is very important guys so for that what I will do is st dot session state okay so ro assistant content equal to a message this a message I'm going to call to the session message session state that is very important. Okay. Next uh uh so yeah I mean almost we are done guys almost we are done and I think uh almost we have the code updated code of this uh maybe we will try to see what is the error message which will come here. Okay. So let me one second. Let me check one. Okay. So almost we are done. Uh one some error message is there. We'll see that uh how to debug that. But yeah I mean apart from that I think you guys are clear right? So this is like a initial go. So I will explain like how to run and all. Uh so that is the another thing what I'm trying to share. Uh so till here everybody's clear. Uh okay I think if if if everybody is clear then I think that's fine. Uh only thing is I'll just show the demo things for you guys how to do and all. So but don't worry I'll push all this code to the g uh g repository. Okay. Uh so we can start with the process. I don't know like some indentation problem is there. I know uh sorry guys this is the first time I'm going live but uh if anything is there please uh make a note of these things but uh but to be honest this is the things whatever I want to do uh so this one is the main uh things whatever I wanted to show but yeah I will just run this command we'll see how it works okay guys uh you terminal okay so hope my screen is visible visible and uh we can start with you know streamlate only because we have streamlate now currently streamllet run chatbot py okay some errors are there okay let us check what are the errors are there uh what is this user distribute without warrant is limited okay it's launching guys okay some error okay it's telling syntax error Um okay I will show that screen as well for you. Uh currently you guys will not able to see my error error prompt. I will show you guys. Uh so it's killing except expected line 70 in second guys. Yeah that same thing whatever we got this one right. It's it's that one. Okay. Okay. Maybe that expectation was missing here. That except condition was missing after try. So that's why that error message is coming. Guys, one second. Let me debug that. Uh, try try try try. Okay. Message content. Okay. Sorry. Okay. I think we are clear. Uh, I think no error as of now. you terminal. Okay. Okay. Now we'll start again. Uh so for running the command so we will use streamllet run chatbot. py. Okay. So don't worry about that. Uh so that's fine. So guys, I'll show my this one uh the updated one. Let it load. Okay, I will show my another screen. Uh so it's launched guys. I'll show that. So able to see chatbot screen guys able to see chatbot screen anybody? Okay fine. Uh so this is a chatbot uh ask me anything kind of thing. Uh so whatever I have done so let me show that in a proper way. One second guys. One second. second. Yeah. So can close this and uh can start from here. Uh so yeah guys, so this is the chatbot what I am trying to see uh what I can fetch. Uh so any anything from the chats what do you want to try uh the chats uh messages or something uh please type so that I you know I can just uh explore so I'll just type hi here hi okay and chat job chat what will thing and it is giving me hello how I can assist you today okay uh anything you guys want to try um like For example, okay, I can type tell me a joke. Tell me a joke. Okay. So, what it has given some why did the scrap scarecrow win an award? Because he was outstanding in his field. Okay. Write a Python code for Fibonacci series. I just I'm just giving some random thoughts. Uh if you guys have anything in your mind uh you guys can just tell me so I I can in I mean I can just implement this. See guys it has given the Python code in the Fibonacci series. Okay. So anybody anybody has any thoughts? Anybody has any uh things which you guys can try uh uh tell um so I can try like you know uh Python code for tic tactoe tic tac toe everybody knows right it's still thinking. Okay. Uh yeah. So I mean it has given guys. Okay. Uh so anybody has any uh you know cheat kind cheat chats so that you know it will not give the response. Anybody has you guys can give me no problem. Uh okay. So I mean I can just enter uh tell me uh ancient history uh tell me about tell me about Jalen Walab incident I'll just type okay I also don't I mean I don't know spelling also even but yeah but I think it's it's good right it's pretty good it's performing good also and it's exactly giving the massacre happened in Jalan Walab and it is giving the background and the incident and aftermath and impact problems also. Okay. Uh so anybody in if you guys want anything uh so you guys can just uh tell me otherwise I think that should be fine. So what I will do is I will just store this in the bit bucket or something and you guys can start with you know playing around it you know if you if you have any um if you have any things uh to be opened you can just um you know chat with me that's not a problem uh either YouTube or I'll share my LinkedIn also so you guys can just um show me I mean you guys can just if you have any doubts or something based on this chatbot you guys can uh just contact And um anybody has any thoughts or any questions uh I can still be there otherwise we can ask about Canada Rajaso history. Okay. Ask about Canada and when it started good one uh Canada ah since it is Canada good that's a good s history and when it when it is started [snorts] okay let us see today Canada it's a good occasion Oh nice. Canada Rajasawa is also known as formation day in celebrated. Oh, it was started in 1956. uh AJ background and history is like a pre-independence before India gained independence in 1947 the region and it is giving after independence also and it is formation of Karnataka unified one and celebration of Canada Rajutsa is a significant Connecticut uh within Karnataka and across the globe parades cultural events awards flag hoisting overall will be day of full pride for Canada reflecting the culture identity and the history significance of the unification of Canada speaking regions into a single state. Nice. I mean, yeah, I mean it is giving the brief. It kind we can just still play around it. But yeah, I mean this is a this is a you know I mean this is a good start. That's good. Okay. And also here you can clear the chat also guys. Here you can clear the chat also so that the particular chat will go and later you guys can see the other things also that's also there. Okay. Uh so apart from that what I can tell is and uh again guys this chatbot will not give the uh another hack in this chatbot is that this chatbot will not give the current things which is happening. Okay. So I will type what is the current weather in Bangalore. Okay. So this will not give the live update guys because this API is not suffable. For that we need to create a aentic AI environment. See if you see this right it will give I don't have the realtime capabilities to fetch the current weather data because for this we need to have a separate APIs which is integrated to this uh chatbot. Okay, which I will explain in the upcoming uh training sess live sessions. I will explain you guys how to fetch all these things uh using other APIs, right? External APIs, we can do it. But as of now this chatbot is a skeleton where we have built whatever you want to ask in a you know either in a history point of time or for example in a different way it will give you but not the current things guys current weather you know or current um incident which is going to happen which is already happened in like current incident live incident right so this will not give the chatbot is not enabled for that okay but yeah still uh we can try that also right how to get the current weather and all these things. I will explain you guys in my upcoming sessions how to do that also. Okay, that's fine. But still this is like a personal AI chatbot for you. Okay. So like you guys can just uh tell like you know uh for example right um so my my name is Chaitan. Okay. I I will just show chat history things right how it will work. Uh my name is Chaitan and uh my hobbies are playing cricket. Okay, TT. Okay, so I'll just feed this information to the AI. Okay, so now I'll just ask what are my what are my hobbies? Uh sorry not what are my abish one second. Uh so I will just tell uh what is my name? Okay so see guys it will automatically give your name is Chan because the chat history has been stored already. Okay. So if I click on this clear chat then I ask what is my name? For example I will clear this chat. Okay. Clear chat is done. Okay. So now I will ask what is my name for example right so so it don't know it don't know it don't have the access to the personal data okay so now I will f my name is chithan okay and I that's fine now if you give what is my name okay so it will give your name is chetan okay you understand this this is very important in when when you have the chatboard things also right this is very important and this is very easy to understand uh all this uh kind of things which will be there okay so what I will do is I will just uh do this all the things to the repo GitHub repo and I will share you guys and if you guys have any any any thoughts or any information or whatever you want to you know understand in this coding terms right you guys can do it uh and you guys can contact me as well. I will share my LinkedIn profile or I will share my uh chatting whatever the you know updates will be there. You can just uh speak with me and um so that is there and and this is the start guys and I am going to I'm going to start with this series and uh we will be going to design multiple AI tools right and it's very helpful for you guys also. Uh so only thing is what we can do is that we can start with some upgrading things also like this is like a skeleton what I was trying trying to build. Next what we can do is that we can add message for example and I'll show you guys how to deploy this in the live environment. For example this is whatever I have done in is my local. Okay. So whatever I have done is in my local. So what I want to do is like we can start showcasing these things in a upcoming things also. So that is also very important guys. So when we start with the uh different things right so we can start with uh how to deploy okay uh there is a different types of deployment hugging face is there streamly cloud is there we have different types of uh you know uh things are there so that also we can start and we can uh deal with these things. So those things we can start and uh we can u give the knowledge for everybody you know my uh goal is to just give the knowledge for everybody uh in the AI space so that it will help you guys in a longer term and uh see yeah I mean only thing is u I want to make it simple I want to make it uh easy to understand for you guys so that it will help you guys to you know upskill and uh you know um like it will help everybody to understand and you guys can build your own AI chatbot. You guys can build your own AI tools. You know my agenda is that uh if you guys want anything uh generic kind of things just let me know what if you if you have any plan to build any AI tools and not able to you know um build those things due to some blockers let me know so that we can together we can do it that's not a problem. So those kind of things what I'm trying to uh see here and um so if this session was helpful uh please give a like and share it to more people so that they will also get knowledge from this uh whatever we have built and uh so yeah I mean those kind of things are very important to share the knowledge for everybody. Okay. Uh yeah, if no questions are there, I think uh we can wind up the call, wind up the streams and uh maybe this will be again uh who have who are missed the stream. So it will be like uh a live video uh I will do it based on this uh so that it will helpful for more people also. But yeah, I mean thanks for uh joining the session guys and it was really helpful uh and uh so uh yeah I am ending the stream now. If anything is there just uh let me know uh in the comment section or in the this one so that we can address it. Okay, thanks all for joining. Have a nice day. Bye.
Original Description
Build a ChatGPT-style AI chatbot in Python in just 1 hour!
In this beginner-friendly course, you'll learn step-by-step how to create an AI chatbot using:
✅ Python
✅ Streamlit for UI
✅ OpenAI API (ChatGPT)
✅ Chat memory & conversation handling
By the end of this video, you will have your own working chatbot — just like ChatGPT — running locally on your system!
🚀 What You'll Learn
How ChatGPT-style AI chatbots work
Setting up OpenAI API in Python
Building a chatbot backend
Creating a chat UI using Streamlit
Adding chat history & memory
Deploying your chatbot
Perfect for beginners, students, and Python developers stepping into AI.
📦 Resources & Code
GitHub Source Code: https://github.com/chethannj/AIChatBot
OpenAI API Docs: https://platform.openai.com/docs
Streamlit Docs: https://docs.streamlit.io
Comment below which one you want next! 👇
🙋♂️ Community Challenge
If you complete this project — share your result!
👉 Link your GitHub repo or screenshot in the comments — I’ll check it 💬
👍 Support & Subscribe
If you found this helpful:
✅ Like
✅ Comment
✅ Subscribe
✅ Turn on 🔔
I upload Python + AI + ChatGPT projects every week.
#python #chatgpt #openai #streamlit #aiproject #pythonproject #programming #learnpython
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
More on: AI Pair Programming
View skill →Related Reads
📰
📰
📰
📰
Complete Guide: Transferring Firestore Data Between Databases (Including Subcollections)
Dev.to · K-kibet
How I Built a CLI That Generates 12 Project Templates in 30 Seconds
Dev.to · ke jia
Debouncing vs Throttling Explained: Why Modern Web Applications Can’t Live Without Them
Medium · Programming
The Complete Roadmap to Become a Backend Developer in 2025
Dev.to · qing
🎓
Tutor Explanation
DeepCamp AI