A CLI utility for interacting with OpenAI GPT.
Project description
Command GPT
A simple command-line utility to interact with OpenAI's API and retrieve shell suggestions. By default, predefined system and user messages are used to facilitate the interaction. However, flags are available to allow customization of these messages per request.
Prerequisites
- Python 3
- OpenAI API Key
Install
pip install commandgpt
Usage
On the first run, Command GPT will create a configuration file named .openai_config
in your home directory and prompt you for details. This file will store the OpenAI API key, model version, user and system messages to facilitate future interactions without the need to repeatedly input those details.
└─$ gpt -h
usage: gpt [-h] [-s SYSTEM] [-u USER] [-d] [-c] [-v] [query]
Interact with OpenAI ChatGPT.
positional arguments:
query your question or query
options:
-h, --help show this help message and exit
-s SYSTEM, --system SYSTEM
system message for AI
-u USER, --user USER prefix for user message
-d, --debug enable debug mode
-c, --config reconfigure settings
-v, --version show the version number and exit
Example System and User messages
System:
You are a super star linux system admin.
User:
Provide very brief answers without any explanation. Write one-liner commands as answers.
Example usage
$ gpt "Your query here"
However, if you wish to customize the system or user messages:
$ gpt "Your query here" --system "Your custom system message" --user "Your custom user prefix"
$ gpt "How do I check disk space?"
df -h
$ gpt "How can I see all running processes?"
ps aux
$ gpt "How do I find my machine's IP address?"
ip a
Output Safety Warning
The output from Command GPT is not escaped or quoted by default. This means that special characters or command structures in the output can have direct consequences if executed in a shell or scripting environment.
Using the raw output in scripts or as part of piped commands can be hazardous. I strongly advise against directly integrating the output of Command GPT into another command, script, or pipeline without meticulously reviewing and understanding its implications.
Before utilizing any output, please ensure you're fully aware of its content and potential side effects.
A Word of Caution!
While GPT aims to provide accurate and efficient command suggestions, it's essential to understand the commands and not take them at face value. As with any AI system, the output it produces may not always reflect the most accurate or optimal solution for a given task.
Illustrative Example: Counting Lines in Text Files
Imagine you want to count all the lines in .txt files within a directory, recursively. You might get two suggestions:
find /path/to/directory -type f -name "*.txt" -exec wc -l {} + | awk '{sum += $1} END {print sum}'
find /path/to/directory -name "*.txt" -exec cat {} + | wc -l
At first glance, both might seem to do the job. However, upon closer inspection, the first command might return a count that's double the actual number of lines. Why? Because wc -l
produces an output line for each file and a cumulative count when used with multiple files. The awk
part then sums all these numbers, leading to an inflated total.
The lesson here? Always review and understand the commands you get. Even if a command looks technically correct, it may not deliver the expected result in every context.
Command GPT is a tool, and like any tool, its effectiveness depends on the skill and awareness of the user.
TODO
- Think of a better way to store API key (keyring module?).
- Add more openai models including images.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file commandgpt-0.1.1.tar.gz
.
File metadata
- Download URL: commandgpt-0.1.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93912d48a2e3f2b8f344c39b9b05b3a0b79f3382c62a0098f22cb18f8d566d7f |
|
MD5 | b9958428c5da4265e340f4971be398c3 |
|
BLAKE2b-256 | c1d4650abe7739866d0aedb4c50f24affdfcac8ea0ca8fa7afd9f071f350b3a3 |
File details
Details for the file commandgpt-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: commandgpt-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83148931fcaa102cb2fbead6a0b9f3849261412407b79abce9bb65e2a31557eb |
|
MD5 | f46acb8815116ae7c91461a8c971baa3 |
|
BLAKE2b-256 | 71c53c5e1694d10e0fd07770ad56beddb138a0957f6532cb71d129f7035635bb |