Skip to content

Commit 5b7787e

Browse files
committed
Add usage function
1 parent 525bdba commit 5b7787e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

chatgpt.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,32 @@ COMMAND_GENERATION_PROMPT="Return a one-line bash command with the functionality
1515

1616
CHATGPT_CYAN_LABEL="\n\033[36mchatgpt \033[0m"
1717

18+
usage() {
19+
cat << EOF
20+
A simple, lightweight shell script to use OpenAI's chatGPT and DALL-E from the terminal without installing python or node.js.
21+
22+
Commands:
23+
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.
24+
history - To view your chat history, type history
25+
models - To get a list of the models available at OpenAI API, type models
26+
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
27+
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. command: show me all files in this directory that have more than 150 lines of code If a command modifies your file system or dowloads external files the script will show a warning before executing.
28+
29+
Options:
30+
-i, --init-prompt - Provide initial chat prompt to use in context
31+
--init-prompt-from-file - Provide initial prompt from file
32+
-p, --prompt - Provide prompt instead of starting chat
33+
--prompt-from-file - Provide prompt from file
34+
-t, --temperature - Temperature
35+
--max-tokens - Max number of tokens
36+
-m, --model - Model
37+
-s, --size - Image size. (The sizes that are accepted by the OpenAI API are 256x256, 512x512, 1024x1024)
38+
-c, --chat-context - Make chatgpt aware of todays date and what data it was trained on
39+
40+
41+
EOF
42+
}
43+
1844
# error handling function
1945
# $1 should be the response body
2046
handle_error() {
@@ -203,6 +229,10 @@ while [[ "$#" -gt 0 ]]; do
203229
CONTEXT=true
204230
shift
205231
;;
232+
-h | --help)
233+
usage
234+
exit 0
235+
;;
206236
*)
207237
echo "Unknown parameter: $1"
208238
exit 1

0 commit comments

Comments
 (0)