This repository contains code for building a terminal-based chatbot using OpenAI's recently released ChatGPT API Released on 01/03/2023. The code is written in Python and uses the OpenAI Python library
Before you begin, you'll need to sign up for an OpenAI API key. You can sign up here and get your API key here.
Once you have your API key, you can install the openai library using pip:
pip install openai
You will need to replace the API Key in the code in order to run the chatbot
- You can do this by replacing the value of the variable
openai.api_key
with your API key, in the filechat.py
line 3
To start the chatbot, run the following command:
python chat.py
You can enter your prompts and the chatbot will generate responses. It will continue to respond until you enter the message exit
to exit the program. You can also enter clear
to clear the chat history and start a new conversation.
Happy chatting 🎉
- OpenAI Blog: Introducing ChatGPT and Whisper APIs
- OpenAI Documentation: ChatGPT API
- OpenAI Python Library
Name: Abdur Rahman
Institution: Indian Institute of Technology Delhi
Find me on: