Skip to content

Commit 3e4c290

Browse files
authored
Merge pull request #68 from TobiasLaving/main
Small usability improvements
2 parents e777711 + 586e5ac commit 3e4c290

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

chatgpt.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#!/bin/bash
2+
3+
if [[ -z "$OPENAI_KEY" ]]; then
4+
echo "OPENAI_KEY is not set, exiting"
5+
exit 1
6+
fi
7+
28
GLOBIGNORE="*"
39

410
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 +17,32 @@ CHATGPT_CYAN_LABEL="\n\033[36mchatgpt \033[0m"
1117

1218
PROCESSING_LABEL="\033[90mprocessing... \033[0m"
1319

20+
usage() {
21+
cat << EOF
22+
A simple, lightweight shell script to use OpenAI's chatGPT and DALL-E from the terminal without installing python or node.js.
23+
24+
Commands:
25+
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.
26+
history - To view your chat history, type history
27+
models - To get a list of the models available at OpenAI API, type models
28+
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
29+
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.
30+
31+
Options:
32+
-i, --init-prompt - Provide initial chat prompt to use in context
33+
--init-prompt-from-file - Provide initial prompt from file
34+
-p, --prompt - Provide prompt instead of starting chat
35+
--prompt-from-file - Provide prompt from file
36+
-t, --temperature - Temperature
37+
--max-tokens - Max number of tokens
38+
-m, --model - Model
39+
-s, --size - Image size. (The sizes that are accepted by the OpenAI API are 256x256, 512x512, 1024x1024)
40+
-c, --chat-context - Make chatgpt aware of todays date and what data it was trained on
41+
42+
43+
EOF
44+
}
45+
1446
# error handling function
1547
# $1 should be the response body
1648
handle_error() {
@@ -199,6 +231,10 @@ while [[ "$#" -gt 0 ]]; do
199231
CONTEXT=true
200232
shift
201233
;;
234+
-h | --help)
235+
usage
236+
exit 0
237+
;;
202238
*)
203239
echo "Unknown parameter: $1"
204240
exit 1

0 commit comments

Comments
 (0)