/ChatGPT-API-Python

Building a Chatbot in Python using OpenAI's Official ChatGPT API

Primary LanguagePython

🤖 ChatGPT-API-Python: Building a Chatbot using OpenAI's ChatGPT API 🚀

ChatGPT-API-Python Website

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

Screenshot 2023-03-02 at 4 09 46 PM

Getting Started 🔧

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 file chat.py line 3

Usage 💬

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 🎉

References

Connect with me

Name: Abdur Rahman

Institution: Indian Institute of Technology Delhi

Find me on:

  • LinkedIn
  • GitHub
  • Twitter