This repository contains a simple Python-based boilerplate code for using OpenAI's GPT-3.5-turbo and GPT-4 model to create a chatbot. This chatbot utilizes the OpenAI API and Tiktoken library to manage tokens and costs.
Before you can use this boilerplate, you'll need to set up a few things:
- Sign up for an OpenAI account and obtain an API key.
- Install the required Python libraries by running
pip install openai tiktoken python-dotenv
.
-
Clone this repository:
git clone https://github.com/lablab-ai/openai-chat-endpoint-boilerplate.git cd openai-chat-endpoint-boilerplate
-
Create a
.env
file in the root directory of the project and add your OpenAI API key:OPENAI_API_KEY=your_openai_api_key
-
Run the chatbot script:
python openai-chat-endpoint-boilerplate.py
-
Start chatting with the bot by running the openai-chat-endpoint-boilerplate.py file
On lablab discord, we discuss this repo and many other topics related to artificial intelligence! Checkout upcoming Artificial Intelligence Hackathons Event