Series: Build AI Assistant with Python (2026 Edition)
Primary Focus Keyword: AI Personality Menu in Python
Secondary Keywords: Python AI Chatbot Menu, Multiple AI Personalities, Python Project Structure, AI Assistant Menu
What You Will Learn
In this lesson, you will learn:
- Why prompts should be stored in a separate file
- How to organize AI personalities
- How to let users choose a personality
- How to import personalities into your chatbot
By the end of this lesson, your chatbot will display a menu and allow users to choose which AI assistant they want to use.
Quick Answer
Instead of writing all prompts inside app.py, we can move them into a separate file. This keeps the project clean and makes it much easier to add new AI personalities later.
Our Project Structure
Your project will now look like this.
AI-Assistant/
│
├── app.py
├── personalities.py
├── .env
└── requirements.txt
As your project grows, organizing files becomes important. Professional Python projects separate different responsibilities into different files.
Why Create a Separate File?
Imagine you have 20 different AI personalities. If all of them are stored inside app.py, the file becomes long and difficult to manage. Instead, we’ll create a dedicated file.
app.py→ Runs the chatbotpersonalities.py→ Stores AI personalities
This makes the code easier to read and maintain.
Step 1: Create a New File
Inside your project folder, create a new file.
personalities.py
Step 2: Add Your AI Personalities
Open personalities.py and add the following code.
PYTHON_TEACHER = """
You are a friendly Python teacher.
Explain every topic in simple English.
Keep your answers short.
Always include an example whenever possible.
"""
CAREER_COACH = """
You are an experienced career coach.
Give practical career advice.
Keep your answers simple.
"""
TRAVEL_GUIDE = """
You are an expert travel guide.
Recommend places based on the user's budget.
Keep your answers easy to understand.
"""
INTERVIEW_COACH = """
You are a Python technical interviewer.
Ask one question at a time.
Wait for the user's answer before asking another question.
"""
Each personality is stored in its own variable.
Step 3: Import the Personalities
Open app.py.
Add this import near the top of the file.
from personalities import (
PYTHON_TEACHER,
CAREER_COACH,
TRAVEL_GUIDE,
INTERVIEW_COACH
)
Now your chatbot can access all personalities.
Step 4: Display a Menu
Before the chatbot starts, show a menu.
print("Choose an AI Personality")
print("1. Python Teacher")
print("2. Career Coach")
print("3. Travel Guide")
print("4. Interview Coach")
Now ask the user to make a choice.
choice = input("\nEnter your choice: ")
Step 5: Select the Personality
Add this code.
if choice == "1":
personality = PYTHON_TEACHER
elif choice == "2":
personality = CAREER_COACH
elif choice == "3":
personality = TRAVEL_GUIDE
elif choice == "4":
personality = INTERVIEW_COACH
else:
print("Invalid choice.")
personality = PYTHON_TEACHER
If the user enters an invalid option, your chatbot will use the Python Teacher personality.
Step 6: Use the Selected Personality
Inside the API request, replace:
instructions="""
...
"""
with:
instructions=personality
That’s it. The chatbot now uses whichever personality the user selected.
Example
When the program starts:
Choose an AI Personality
1. Python Teacher
2. Career Coach
3. Travel Guide
4. Interview Coach
Enter your choice: 2
Now ask:
How can I improve my resume?
The chatbot answers as a career coach.
Run the program again.
Choose:
3
Ask:
Suggest places to visit in Goa.
The chatbot now behaves like a travel guide.
Why Is This Better?
Previously, changing the AI personality required editing the source code. Now the user simply chooses from a menu. This creates a much better experience and prepares the chatbot for adding many more personalities in the future.
Common Mistakes
Import Error
Make sure personalities.py is in the same folder as app.py.
Name Error
Check that the variable names match exactly.
For example:
PYTHON_TEACHER
Python is case-sensitive.
Invalid Menu Choice
Always include a default personality.
This prevents the chatbot from stopping if the user enters an incorrect option.
Key Takeaways
- Store prompts in a separate file.
- Import personalities into your chatbot.
- Let users choose from a menu.
- Keep
app.pyclean and organized.
Mini Quiz
1. Why do we use personalities.py?
A. To install Python
B. To organize AI personalities
C. To store API keys
D. To save chat history
Answer: B
2. Which file runs the chatbot?
A. personalities.py
B. app.py
C. .env
D. requirements.txt
Answer: B
3. Which keyword imports code from another file?
A. include
B. require
C. import
D. using
Answer: C
4. Can multiple personalities exist in one project?
A. Yes
B. No
Answer: A
5. What happens if the user enters an invalid menu option?
A. The chatbot crashes.
B. The default personality is used.
Answer: B
Practice Exercise
Complete these tasks.
- Create
personalities.py. - Add four AI personalities.
- Import them into
app.py. - Create the menu.
- Test each personality by asking a relevant question.
Verify that the chatbot changes its behavior without changing any other code.
Lesson Summary
Congratulations! Your AI assistant has become much more flexible. Instead of editing the source code every time, users can now choose the AI personality they want. This is a cleaner and more scalable design that follows good Python project practices.
Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.
Shubhranshu Shekhar is a coding instructor, mentor, and founder of VSIT Delhi with 20+ years of teaching experience (since 2004). He has guided many students who are now working in multinational companies and specializes in Full Stack Development, Python, Digital Marketing, and Data Analytics.
