About | Technologies | Objective | Requirements | Download | How to Use | Author | License
OpenAI CLI Chat is a Python-based command-line interface (CLI) application designed to interact with the OpenAI API.
This project serves as an example of how to integrate OpenAI’s services into Python applications while following best practices like object-oriented programming and modular project organization.
- Python 3.8+
- OpenAI API
- python-dotenv
- unittest (for testing)
The main objectives of this project are:
- Demonstrate how to call the OpenAI API to generate responses based on user prompts.
- Build a simple yet functional command-line interface.
- Showcase how to structure a Python project with clean architecture and object-oriented programming.
- Python 3.8 or higher: Download from python.org.
- OpenAI API Key: Get your API key from OpenAI.
- A code editor (we recommend Visual Studio Code).
Open your terminal, navigate to your desired folder, and run the commands below:
# Clone the repository
$ git clone https://github.com/luizcampos331/openai-python.git
# Navigate to the project directory
$ cd openai-python
# Create a virtual environment and activate it
$ python -m venv .venv
$ source .venv/bin/activate # On Linux/MacOS
# or
$ source .venv\Scripts\activate # On Windows
# Install the project as a package
$ pip install -e .
- Duplicate the file .env.example, rename to .env and define your "OPENAI_API_KEY":
OPENAI_API_KEY=your-api-key-here
- Run the application:
start-chat
- Type your messages in the terminal to interact with the API. To exit, type exit.
To execute unit tests:
run-tests
Luiz Eduardo Campos da Silva LinkedIn: @luiz-campos GitHub: @luizcampos331
Copyright © 2020 Luiz Campos
This project is licensed under the MIT license.