This Python script is a command-line interface (CLI) for interacting with OpenAI's GPT-3.5 Turbo model. It allows you to have conversations with the model, generate commands, and more.
Before using this script, make sure you have the following:
- Python 3.x
- An OpenAI API key (set as an environment variable
OPENAI_KEY
)
-
Clone this repository:
git clone https://github.com/yourusername/chatgpt-cli.git cd chatgpt-cli
-
Set your OpenAI API key as an environment variable:
export OPENAI_KEY=YOUR_API_KEY_HERE
You can use the script for basic conversations with the GPT-3.5 Turbo model. For example:
python cligpt.py
You can also use it to generate shell commands. Provide a prompt starting with "command:" like this:
python cligpt.py "command: Create a new file in the current directory."
To generate images from text prompts, use the "image:" prefix:
python cligpt.py "image: Draw a landscape with a river and mountains."
history
: View chat history.models
: List available models.model: MODEL_ID
: Get details for a specific model.exit
orq
: Quit the script.
-
Be cautious when executing commands generated by the script, especially if they contain potentially dangerous commands (e.g.,
rm
,wget
). Always understand the commands before running them. -
The script supports multi-line prompts. Press Enter then Ctrl-D to send multi-line prompts.
This project is licensed under the MIT License - see the LICENSE file for details.