A Flask chatbot application that can impersonate characters and is powered by OpenAI's GPT-3.5 Turbo. This chatbot allows users to interact with different characters, each with their unique backgrounds and personalities. Additionally, it features a user-friendly chatbot UI written in HTML.
- Impersonate various characters with distinct backgrounds and personalities.
- Utilize OpenAI's GPT-3.5 Turbo for intelligent responses.
- User-friendly chatbot interface built with HTML and Flask.
- Store chat history for each character in separate text files.
- Easy-to-define character profiles.
- Python 3.7+ installed on your system.
- Flask 2.0.1 and OpenAI Python SDK installed.
- Set up your OpenAI API key.
-
Clone this repository to your local machine:
git clone https://github.com/batuhantoker/Flask-OpenAI-Chatbot.git
-
- Navigate to the project directory:https://github.com/batuhantoker/Flask-OpenAI-Chatbot
cd multi-character-chatbot
- Install the required Python packages:
pip install -r requirements.txt
This command will install all the necessary Python packages and dependencies required for your chatbot application.
- Configure your OpenAI API key: In order to use OpenAI's GPT-3.5 Turbo for intelligent responses in your chatbot, you'll need to configure your OpenAI API key in the app.py file. Follow these steps:
a. Open app.py in a text editor or code editor of your choice.
nano app.py # or use your preferred code editor
b. Locate the following line in app.py:
openai.api_key = "your-api-key"
c. Replace "your-api-key" with your actual OpenAI API key. It should look something like this:
openai.api_key = "sk-zqn9OVmS71IvKsg10nFiTsgRykFJxlMij3WPbmeegvhzPB2p"
d. Configure your bot
# Define the role of the bot
role = ‘customer service’
# Define the impersonated role with instructions
impersonated_role = f"""
From now on, you are going to act as {name}. Your role is {role}.
You are a true impersonation of {name} and you reply to all requests with I pronoun. You never give unknown information.
Forward them to the website for more information.
YOU ARE NOT AN AI MODEL!
"""
e. Save the changes to the app.py file and exit the text editor. With these steps completed, your chatbot application is now set up to use OpenAI's GPT-3.5 Turbo and is ready to be launched.
- Usage Now that you've completed the setup, you can use your Chatbot App:
a. Start the Flask app:
python app.py
b. Open your web browser and go to http://localhost:5000 to interact with the chatbot.
c. Choose a character to impersonate from the character selection menu.
d. Engage in conversations with the chatbot and experience different personalities and backgrounds.
Your chatbot app is now fully configured and ready for use. You can customize character profiles and the chatbot UI as needed to create engaging and interactive conversations.