Skip to content

Commit d0446e2

Browse files
authored
Merge pull request #79 from 0xacx/add-help-command
Add help command
2 parents e777711 + ff85604 commit d0446e2

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

chatgpt.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
23
GLOBIGNORE="*"
34

45
CHAT_INIT_PROMPT="You are ChatGPT, a Large Language Model trained by OpenAI. You will be answering questions from users. You answer as concisely as possible for each response (e.g. don’t be verbose). If you are generating a list, do not have too many items. Keep the number of items short. Before each user prompt you will be given the chat history in Q&A form. Output your answer directly, with no labels in front. Do not start your answers with A or Anwser. You were trained on data up until 2021. Today's date is $(date +%d/%m/%Y)"
@@ -11,6 +12,43 @@ CHATGPT_CYAN_LABEL="\n\033[36mchatgpt \033[0m"
1112

1213
PROCESSING_LABEL="\033[90mprocessing... \033[0m"
1314

15+
if [[ -z "$OPENAI_KEY" ]]; then
16+
echo "You need to set your OPENAI_KEY to use this script"
17+
echo "You can set it temporarily by running this on your terminal: export OPENAI_KEY=YOUR_KEY_HERE"
18+
exit 1
19+
fi
20+
21+
usage() {
22+
cat <<EOF
23+
A simple, lightweight shell script to use OpenAI's Language Models and DALL-E from the terminal without installing Python or Node.js. Open Source and written in 100% Shell (Bash)
24+
25+
https://github.com/0xacx/chatGPT-shell-cli/
26+
27+
By default the script uses the "gpt-3.5-turbo" model. It will upgrade to "gpt-4" when the API is accessible to anyone.
28+
29+
Commands:
30+
image: - To generate images, start a prompt with image: If you are using iTerm, you can view the image directly in the terminal. Otherwise the script will ask to open the image in your browser.
31+
history - To view your chat history
32+
models - To get a list of the models available at OpenAI API
33+
model: - To view all the information on a specific model, start a prompt with model: and the model id as it appears in the list of models. For example: "model:text-babbage:001" will get you all the fields for text-babbage:001 model
34+
command: - To get a command with the specified functionality and run it, just type "command:" and explain what you want to achieve. The script will always ask you if you want to execute the command. i.e.
35+
"command: show me all files in this directory that have more than 150 lines of code"
36+
*If a command modifies your file system or dowloads external files the script will show a warning before executing.
37+
38+
Options:
39+
-i, --init-prompt - Provide initial chat prompt to use in context
40+
--init-prompt-from-file - Provide initial prompt from file
41+
-p, --prompt - Provide prompt instead of starting chat
42+
--prompt-from-file - Provide prompt from file
43+
-t, --temperature - Temperature
44+
--max-tokens - Max number of tokens
45+
-m, --model - Model
46+
-s, --size - Image size. (The sizes that are accepted by the OpenAI API are 256x256, 512x512, 1024x1024)
47+
-c, --chat-context - For models that do not support chat context by default (all models except gpt-3.5-turbo and gpt-4), you can enable chat context, for the model to remember your previous questions and its previous answers. It also makes models aware of todays date and what data it was trained on.
48+
49+
EOF
50+
}
51+
1452
# error handling function
1553
# $1 should be the response body
1654
handle_error() {
@@ -199,6 +237,10 @@ while [[ "$#" -gt 0 ]]; do
199237
CONTEXT=true
200238
shift
201239
;;
240+
-h | --help)
241+
usage
242+
exit 0
243+
;;
202244
*)
203245
echo "Unknown parameter: $1"
204246
exit 1

0 commit comments

Comments
 (0)