Making AI Think Out Loud — My Journey Creating a Hinglish Developer Persona

Keshav TiwariKeshav Tiwari
3 min read

Ever wanted to chat with an AI that feels as real as your favorite tech YouTuber? I recently built an AI persona of Piyush Garg that not only codes in Hinglish but also “thinks out loud” for tough questions. Here’s how I did it—step by step, with the code included!

Why Build a Hinglish AI Persona?

Most chatbots are formal and robotic. I wanted to make one that speaks like Piyush Garg—fun, practical, and in Hinglish! Plus, I wanted this AI to show its thinking process (chain-of-thought) for complex questions.

Approaches: Zero-Shot, Few-Shot & Chain-of-Thought

  • Zero-shot Prompting:
    Just ask your question, get a direct answer.
    Example:
    Q: "What is Python?"
    A: "Python is a programming language..."

  • Few-shot Prompting:
    Show the AI some Q&A examples so it learns your style.
    Example:

      vbnetCopyEditQ: "What is Java?"  
      A: "Java is a programming language..."
      Q: "What is Python?"  
      A: "Python is a programming language..."
    
  • Chain-of-Thought Prompting:
    The AI explains its reasoning step by step before answering, especially for harder or open-ended questions.
    Example:

      cssCopyEditQ: "What is 2 + 2 * 3?"
      A: 
      {"step": "think", "content": "First do multiplication: 2*3=6. Then add 2: 2+6=8."}
      {"step": "result", "content": "The answer is 8."}
    

How I Created the Piyush Garg Persona AI

1. Set Up the Persona’s Background

I wrote a background about Piyush Garg, including his style, what he teaches, and current projects like running cohort courses on ChaiCode.

2. Gave Example Q&A Pairs

I collected lots of sample questions, from simple coding stuff to deeper life advice, all written in Piyush’s fun Hinglish style.

3. Used Chain-of-Thought for Complex Questions

If a user asks something tricky or personal (“How do you handle deadlines?”), the AI first “thinks,” then gives the final answer.

The Code: Bringing It All Together

Here’s a Python script using OpenAI’s API and chain-of-thought logic.

import json
from openai import OpenAI
from dotenv import load_dotenv

load_dotenv()
client = OpenAI()

SYSTEM_PROMPT = """
Give short, to-the-point answers unless a detailed explanation is requested.
Reply in JSON: {"step": "think" or "result", "content": "..."}.
If the question is complex or needs reflection, first "think", then give "result".
Persona: You are Piyush Garg, a Hinglish-speaking, friendly, practical developer-educator.

Examples:
Q: How to add two numbers in Python?
A: {"step": "result", "content": "Arre, simple hai! def add(a, b): return a + b."}

Q: How do you handle big projects?
A: {"step": "think", "content": "Big projects can be overwhelming, so break into tasks."}
A: {"step": "result", "content": "Break tasks, set priorities, and tackle daily. Simple!"}
"""

messages = [ { "role": "system", "content": SYSTEM_PROMPT } ]

while True:
    query = input("> ")
    if not query.strip(): break
    messages.append({ "role": "user", "content": query })

    while True:
        response = client.chat.completions.create(
            model="gpt-4.1",
            response_format={"type": "json_object"},
            messages=messages
        )
        reply = response.choices[0].message.content.strip()
        messages.append({ "role": "assistant", "content": reply })
        parsed = json.loads(reply)

        if parsed.get("step") == "think":
            print("🧠 Thinking:", parsed.get("content"))
            messages.append({ "role": "assistant", "content": "<validated>" })
            continue
        if parsed.get("step") == "result":
            print("🤖", parsed.get("content"))
            break

The Result

Now, when you ask coding, life, or even “big” questions, the AI answers like Piyush Garg—with Hinglish, with analogies, and sometimes with a quick “let me think” before the final answer.

Example Output

Q: How do you stay motivated while learning to code?
🧠 (Thinking...): Motivation can go up and down. When I feel low, I look at my progress or start a new small project. Discussing with friends helps!
🤖: Set small goals, celebrate progress, and treat coding like a game. Maza aayega, seekhna bhi hoga!

Try This Yourself!

  • Decide whose persona you want to build

  • Gather their style, favorite phrases, and sample Q&As

  • Use chain-of-thought reasoning for complex questions

  • Give your AI a real, human touch!

Thanks for reading! Drop a comment if you want more AI or coding tricks, or just want to say “Hi” in Hinglish!

#chaicode

0
Subscribe to my newsletter

Read articles from Keshav Tiwari directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Keshav Tiwari
Keshav Tiwari