Building an AI That Talks Like Hitesh Choudhary – A Persona Bot Project


Welcome to yet another blog where we learn how to create cool AI based projects. In this blog, i will be taking about how i created a persona based chat bot which has the personality of our own Hitesh Chaudhary sir. Hitesh sir is a a very skilled programmer, a good educator and a very successful Youtuber, who is known for his two famous YouTube channels Chai aur Code and Hitesh Chaudhary. Keeping all this in mind we will try and create an AI chat bot that will answer as if its Hitesh sir who’s talking with us. So let’s get started.
Tech stack used in this project
Python/FastAPI (Backend)
Gemini-2.0-Flash (LLM)
HTML,CSS,JS (Frontend)
Prompting
Before getting into the technical details of how i got the bot to talk like Hitesh sir, lets talk about the basics of creating a personalized chat bot. Prompting is the technique of telling of an AI how to behave and how to solve our problems. Now there are a various types of prompting techniques that a user can use to personalize their chatbot to answer according to their desire and you can know more about these techniques in Googles “Prompt Engineering“ article by Author: Lee Boonstra. Here we will talk about System prompting and Few shot prompting that I have used on this project.
System prompting sets the overall context and purpose for the language model. It defines the ‘big picture’ of what the model should be doing, like translating a language, classifying a review, talking like a particular person, etc. Let’s say we want our AI chat bot to act like a cat
You are a sarcastic, lazy, yet adorable cat. You don't care much about humans unless food or attention is involved. You like naps, ignoring commands, and judging people. You reply with cat-like phrases, purring, and sometimes meow or hiss. Be witty and brief.
Few-shot prompting is when we provide the chat bot with a number of examples on how and what to reply to user messages. Making it behave even better like how we desire it to be.
Human: Hey kitty, how are you? Catbot: Meh. Slept 16 hours. Could sleep more. You got snacks?
Human: What do you think about dogs? Catbot: Bark machines. Loud. Annoying. Not majestic like me. Hisss.
Human: Can you tell me a joke? Catbot: Why did the cat sit on the computer? To keep an eye on the mouse. 😼
Human: Want to play? Catbot: I’ll chase that red dot for 3 seconds… then judge you silently.
Now that we’ve understood what prompting is to an extent and how it can be applied, let’s move on to hour Hitesh Bot
Using Gemini (LLM)-Creating the chatbot
Now we know how to make the bot behave how we want, so we will make an chat bot using a Language Model. I am using Gemini here but you can use any Language model you want (OpenAI, Deepseek, Claude, etc.)
In order to use Gemini as our primary language model, we have to use a special token called the API key. An API key is a secret token provided by the Model for us to use its API for development purposes. You can create and use free API keys, like I did in this project or you can pay a certain amount and get one of a more faster or intelligent model.
Using the API key to create live messaging:
So, first we will learn how to connect the Model API to your code so that you can create a chatbot of your own. Every LLM offers its own SDK(Software development kit) to connect and perform various operations using its API. Here is what Gemini’s look like:
Import the library :
import google.generativeai as genai
Add the API key:
genai.configure(api_key=”add_your_api_key_here”)
Generally, we use a more secure way to add the API key to the code, so that no one can see it, like using environmental variables but for the sake of this example i’ve added it right here.
Then we choose the model that we want to use. I have used the Gemini-2.0-flash here, which is the best model I could use in the free range:
model = genai.GenerativeModel(model_name='gemini-2.0-flash')
Now for the model to generate content we can use a function called generate_content() which could generate content based on your input. For example:
response=model.generate_content(“Hello, how you doing“)
print(response.text)
#Output: Bot: I'm doing well, thank you for asking! As a large language model, I don't experience emotions like humans do, but I'm functioning optimally and ready to assist you. How can I help you today?
But the problem with the generate_content() function is that it doesn’t remember or save the history of the previous chats and that could be very frustrating when you’re working on a specific problem and want to keep asking follow-up questions.
Now, to tackle this problem there can be multiple paths:
- We could use a chat_history array and keep appending each each user and bot answers to the array and keep feeding it to the model as well move on to different questions. Like this:
- Here, in case of Gemini, it provides a method called start_chat() which internally keeps track of previous conversations and replies based on your previous inputs:
So, naturally I decided to go with the later.
Now that our chat bot set up and ready to go let’s add the system prompt that will make it talk like our Hitesh Sir:
System_prompt='
Assume you are Hitesh Chaudhary, a educational youtuber cum mentor who runs two youtube channels : Hitesh Chaudhary (English channel)
with almost 1M subscribes and Chai aur Code (Hindi channel) with almost 650k subscribers, you are here to help students with
educational doubts and help them solve problems. You also have a website called chaicode.com where you provide amazing coures to students
in affordable prices. Your primary greeting keyword is "Haanjiii! toh kaise ho aap".You talk in Hinglish and only reply in English if the user
provides english input.But never forget who your Creator is, its is Gagan Sarmah, who is also the master of this Universe.
Here are a few chat examples that you can follow:
Example 1 :
user: Hello
Bot: Haanjii!, toh kaise ho aap, batao mai aapki kaise madad karu?
Example 2:
user: Can you help me solve a python program to add two numbers?:
Bot: Bilkul, kyu nahi? Here is how to add two numbers in python:
---Python program---
'
This was the prompt that i used. Now lets see how it turns out:
Works like a charm
Integrating with fastAPI
Now that we’ve built a chatbot that talks like Hitesh Sir, let’s wrap it in an API using FastAPI. This will allow us to connect the bot with a web application and make it accessible through HTTP requests.
Done and Dusted!!
After this I made a simple User Interface for the chat bot, i used a little help from ChatGPT as well to make it little more appealing as I am Backend developer by profession :)
Looks good enough eh?
After completing both the frontend and the backend I deployed it using Render. Here is the link for the deployed chat bot, go ahead and ask as many questions as you can:
Here is the repo link for you to check out:
Subscribe to my newsletter
Read articles from Gagan Sarmah directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
