Skip to content

Shlomit-B/gpt-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPT CLI

A simple, elegant command-line interface for chatting with OpenAI's GPT models.

Perfect for developers who want quick access to GPT without leaving the terminal.

Features

  • One-off questions for quick answers
  • Interactive chat mode with conversation history
  • Beautiful colored output with Rich
  • Fast and lightweight

Built With

  • Typer – CLI framework
  • Rich – Terminal formatting and spinners
  • python-dotenv – Environment variable management

Prerequisites

Setup

  1. Clone the repository:
 git clone https://github.com/yourusername/gpt-cli.git
 cd gpt-cli
  1. Create a .env file in the project root:
 OPENAI_API_KEY=your_openai_api_key_here
  1. Install dependencies:
 poetry install

Usage

Ask a one-off question

poetry run python main.py question "Explain what is REST API"

Start an interactive chat

poetry run python main.py chat

Type your messages and press Enter. Type exit to quit.

Examples

One-off question:

$ python main.py question "What is Docker?"
Docker is a platform that allows developers to package applications 
into containers—lightweight, portable units that include everything 
needed to run the software...

Interactive chat:

$ python main.py chat
You can message ChatGPT now. When you finish, type "exit".
What's the capital of France?
The capital of France is Paris.
What's it famous for?
Paris is famous for the Eiffel Tower, the Louvre Museum, its art, 
culture, fashion, and cuisine. It's known as "The City of Light"...
exit

Troubleshooting

"Module not found" error:
Make sure you're running commands with poetry run or activate the Poetry shell first:

poetry shell
python main.py question "Your question"

API key error:
Verify your .env file is in the project root and contains a valid OpenAI API key.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages