Skip to content

luizcampos331/openai-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenAI CLI Chat

Index

About | Technologies | Objective | Requirements | Download | How to Use | Author | License

🔖 About

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.

💻 Technologies Used

  • Python 3.8+
  • OpenAI API
  • python-dotenv
  • unittest (for testing)

🎯 Objective

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.

⚙️ Requirements

  • 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).

📦 How to Download the Project

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 .

🔧 How to Use

  1. Duplicate the file .env.example, rename to .env and define your "OPENAI_API_KEY":
OPENAI_API_KEY=your-api-key-here
  1. Run the application:
start-chat
  1. Type your messages in the terminal to interact with the API. To exit, type exit.

Running Tests

To execute unit tests:

run-tests

👤 Author

Luiz Eduardo Campos da Silva LinkedIn: @luiz-campos GitHub: @luizcampos331

📝 License

Copyright © 2020 Luiz Campos
This project is licensed under the MIT license.

About

An example project demonstrating the integration and usage of OpenAI’s API with Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages