Create Multiple AI Personalities in Python (Lesson 18)

What You Will Learn

In this lesson, you will learn:

  • What an AI personality is
  • Why AI personalities are useful
  • How to create multiple AI personalities in Python
  • How to switch between different AI assistants

By the end of this lesson, your chatbot will be able to behave like different experts without changing the main program.


Quick Answer

An AI personality is the role you give to an AI model. For example, the same chatbot can become:

  • A Python Teacher
  • A Career Coach
  • A Travel Guide
  • A Technical Interviewer
  • A Digital Marketing Expert

You don’t need a new AI model for each role. You only need to change the system prompt.


Why Create Multiple AI Personalities?

Suppose you built an AI chatbot for your website. Different users may need different kinds of help.

  • One visitor wants to learn Python.
  • Another visitor wants interview tips.
  • Someone else wants travel advice.

Instead of creating a new chatbot every time, you can create different AI personalities. This makes your chatbot more flexible and useful.


Our Current Chatbot

Right now, your chatbot always behaves like a Python teacher. This happens because your code contains this instruction.

instructions="""
You are a friendly Python teacher.

Explain every topic in simple English.

Keep your answers short.

Always include an example whenever possible.
"""

Let’s improve this.


Step 1: Create a Personality Variable

Above the while loop, add a new variable.

personality = """
You are a friendly Python teacher.

Explain every topic in simple English.

Keep your answers short.

Always include an example whenever possible.
"""

Now your chatbot’s personality is stored in one place.


Step 2: Use the Personality Variable

Find this code.

instructions="""
You are a friendly Python teacher.
...
"""

Replace it with:

instructions=personality

Your API request becomes easier to read.

response = client.responses.create(
    model="gpt-5",
    instructions=personality,
    input=user_message,
    previous_response_id=previous_response_id,
    stream=True
)


Step 3: Create a New Personality

Now change the value of the personality variable. Example:

personality = """
You are an experienced Career Coach.

Give practical career advice.

Keep your answers short and easy to understand.
"""

Run your chatbot again.

Now ask:

How can I improve my resume?

The chatbot now answers like a career coach. You didn’t change any other part of the code.


Step 4: Try Another Personality

Replace the personality again.

personality = """
You are an expert travel guide.

Suggest places based on the user's budget.

Keep your answers simple.
"""

Ask:

Suggest a 3-day trip to Jaipur.

The chatbot now behaves like a travel expert.


Another Example

You can also create a technical interviewer.

personality = """
You are a Python technical interviewer.

Ask one interview question at a time.

Wait for the user's answer before asking the next question.

If the answer is incorrect, explain the correct answer in simple English.
"""

This turns the same chatbot into an interview practice tool.


Why Is This Better?

Earlier, your chatbot had only one personality. Now you can reuse the same application for different purposes. Only the instructions change. The rest of your Python code stays the same. This is one of the biggest advantages of using AI models.


Complete Example

personality = """
You are a friendly Python teacher.

Explain every topic in simple English.

Keep your answers short.

Always include an example whenever possible.
"""

response = client.responses.create(
    model="gpt-5",
    instructions=personality,
    input=user_message,
    previous_response_id=previous_response_id,
    stream=True
)


Common Mistakes

Personality Doesn’t Change

Check that you updated the personality variable. If the old instructions are still there, the chatbot will continue behaving the same way.


Instructions Are Too Long

Keep your instructions clear and simple. A short system prompt is usually easier to understand and maintain.


Conflicting Instructions

Avoid writing opposite instructions. For example:

Answer briefly.

Explain in detail.

These instructions conflict with each other and may produce inconsistent results.


Key Takeaways

  • An AI personality tells the chatbot how to behave.
  • You can create many personalities using different system prompts.
  • The main Python code does not change.
  • Clear instructions usually produce better responses.

Mini Quiz

1. What defines an AI personality?

A. Python version

B. System prompt

C. API key

D. Model name

Answer: B


2. Can one chatbot have different personalities?

A. Yes

B. No

Answer: A


3. Which part of the code changes when creating a new personality?

A. API key

B. Model

C. System prompt

D. Python version

Answer: C


4. Which of these can be an AI personality?

A. Python Teacher

B. Career Coach

C. Travel Guide

D. All of the above

Answer: D


5. Should system prompts be simple and clear?

A. Yes

B. No

Answer: A


Practice Exercise

Create these four AI personalities and test each one.

Python Teacher

Ask:

Explain Python functions.

Career Coach

Ask:

How can I prepare for a software developer interview?

Travel Guide

Ask:

Suggest places to visit in Kerala.

Digital Marketing Expert

Ask:

How can I increase website traffic?

Notice how the chatbot changes its answers even though the Python code remains the same.


Lesson Summary

Excellent! Your chatbot can now take on different roles by changing only the system prompt. This makes your application much more flexible and allows you to build many types of AI assistants without rewriting your code. In the next lesson, you’ll make this even better by allowing users to choose an AI personality from a menu when the chatbot starts.


Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.

Scroll to Top