diff options
Diffstat (limited to 'bin/gpt')
-rwxr-xr-x | bin/gpt/gpt | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/gpt/gpt b/bin/gpt/gpt index 0383dd0..a3bfa48 100755 --- a/bin/gpt/gpt +++ b/bin/gpt/gpt | |||
@@ -5,6 +5,7 @@ | |||
5 | # https://help.openai.com/en/articles/6654000-best-practices-for-prompt-engineering-with-openai-api | 5 | # https://help.openai.com/en/articles/6654000-best-practices-for-prompt-engineering-with-openai-api |
6 | # - Cowork with https://github.com/openai/chatgpt-retrieval-plugin | 6 | # - Cowork with https://github.com/openai/chatgpt-retrieval-plugin |
7 | # - History for prompt | 7 | # - History for prompt |
8 | # - Mac/BSD compatible | ||
8 | 9 | ||
9 | # Necessary commands | 10 | # Necessary commands |
10 | stacks=( curl jq sed ) | 11 | stacks=( curl jq sed ) |
@@ -29,6 +30,7 @@ _print_helper_message() { | |||
29 | cat <<EOF | 30 | cat <<EOF |
30 | Usage: gpt [-h] [-m MODEL] [-m4] [-b BEHAVIOR] [-t temperature] | 31 | Usage: gpt [-h] [-m MODEL] [-m4] [-b BEHAVIOR] [-t temperature] |
31 | [-M MAX_TOKENS] [-s] [MESSAGE] | 32 | [-M MAX_TOKENS] [-s] [MESSAGE] |
33 | gpt <SUBCOMMAND> | ||
32 | 34 | ||
33 | Env: | 35 | Env: |
34 | OPENAI_API_KEY Generate API key from https://platform.openai.com/account/api-keys | 36 | OPENAI_API_KEY Generate API key from https://platform.openai.com/account/api-keys |
@@ -206,7 +208,7 @@ _process_completion() { | |||
206 | 208 | ||
207 | # Check OPENAI API KEY in env | 209 | # Check OPENAI API KEY in env |
208 | # Exit with 6 (configuration issue) if it is not set | 210 | # Exit with 6 (configuration issue) if it is not set |
209 | [ -z "$OPENAI_API_KEY" ] && which token &>/dev/null && OPENAI_API_KEY=$(token openai) | 211 | [ -z "$OPENAI_API_KEY" ] && OPENAI_API_KEY=$(cat $XDG_CONFIG_HOME/openai/key) |
210 | [ -z "$OPENAI_API_KEY" ] && { echo API KEY not specified; exit 6; } | 212 | [ -z "$OPENAI_API_KEY" ] && { echo API KEY not specified; exit 6; } |
211 | 213 | ||
212 | # Parse arguments | 214 | # Parse arguments |
@@ -285,7 +287,8 @@ stream=${stream:-false} | |||
285 | INDEX= | 287 | INDEX= |
286 | 288 | ||
287 | # Prepare for chat session | 289 | # Prepare for chat session |
288 | cache=$(mktemp -t gpt.XXXXXX) && touch "$cache" | 290 | CACHE_DIR=${CACHE_DIR:-/tmp} |
291 | cache=$(mktemp -t gpt.XXXXXX -p ${CACHE_DIR}) && touch "$cache" | ||
289 | #trap "rm $cache" EXIT | 292 | #trap "rm $cache" EXIT |
290 | session=() | 293 | session=() |
291 | 294 | ||