diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-11-19 16:30:21 +0100 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-11-19 16:30:21 +0100 |
commit | ac82416ba14d4cfc2f47ab1d607501bfd899781f (patch) | |
tree | ac0ecd986284f5ae73b413143739281b9f8577bd /bin/common/ask | |
parent | ff3a8bb2d62f5a7e1759eb3d9e0834f4396e833d (diff) | |
parent | 822f8dbf4db697c7a2bfbd675374bfaa7080ce82 (diff) |
Merge branch 'main' of /var/git/dotfiles
Diffstat (limited to 'bin/common/ask')
-rwxr-xr-x | bin/common/ask | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/bin/common/ask b/bin/common/ask index 9fb04ce..95530f5 100755 --- a/bin/common/ask +++ b/bin/common/ask @@ -1,36 +1,4 @@ #!/bin/sh - -# requirements -which pass jq > /dev/null || - exit 1 - -# input -test -z "${inp:=$@}" && - inp="$(cat /dev/stdin)" - -# \n\t -> ' ' && "->' -prompt="$(echo "$inp" | tr "\n\t\"" " '")" -test -z "$prompt" && exit 1 - -API_KEY="$(pass tokens/openai-api)" -model="text-davinci-003" -tokens="1024" -temperature=0 - -data=$(echo \ -'{ - "prompt": "'"$prompt"'", - "model": "'"$model"'", - "max_tokens": '$tokens', - "temperature": '$temperature' -}') - -output=$(curl -s -X POST \ - -H 'Content-Type: application/json' \ - -H "Authorization: Bearer $API_KEY" \ - -d "$data" \ - https://api.openai.com/v1/completions \ - | jq -r '.choices[0].text') - -# remove newline -echo "${output:1}" +which tgpt >/dev/null || exit 1 +[ "${inp:=$@}" ] || inp="$(cat /dev/stdin)" +tgpt "$inp" |