This is a simple Python application that creates a chatbot powered by the GPT-3.5 model using the Streamlit framework for the user interface. The chatbot can engage in conversations and answer questions based on the user's input.
Before you can run this chatbot, make sure you have the following prerequisites installed:
- Python
- Streamlit
- OpenAI Python SDK
- TOML library
You can install the required libraries using pip
:
pip install streamlit openai toml
-
Clone the repository or create a new project directory for this chatbot.
-
Inside your project directory, create a folder named
streamlit
. This folder will contain thesecrets.toml
file where you'll store your OpenAI API key. -
Obtain an OpenAI API key and place it in the
secrets.toml
file as follows:# secrets.toml OPENAI_API_KEY = "YOUR_OPENAI_API_KEY_HERE"
-
Create a Python script (e.g.,
app.py
) and paste the provided code into this script. -
Run the chatbot application using the following command:
streamlit run app.py
-
Upon running the application, a Streamlit interface will open in your web browser.
-
You will see a chat interface with a message input box labeled "What is up?"
-
Start a conversation by typing a message in the input box and pressing Enter.
-
The chatbot will respond to your message, and the conversation will continue. You can ask questions or have a general chat with the bot.
-
The conversation history will be displayed in the chat interface, with user and assistant messages shown.
-
The chatbot is powered by the GPT-3.5 model, and it can provide responses based on the context of the conversation.
-
To stop the chatbot, simply close the Streamlit interface or the terminal where it's running.
-
You can customize the chatbot's behavior by modifying the GPT-3.5 model settings or adding additional logic to handle specific user inputs.
-
You can also add more conversation messages or prompts in the code to make the chatbot respond to various queries and topics.
Enjoy using your Chat Bot powered by GPT-3.5! Feel free to enhance and customize it further to suit your specific needs and requirements.