diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-11-06 09:29:30 +0100 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-11-06 09:29:30 +0100 |
commit | 61d5bb429488794ac178a47fa73c38322aa14c04 (patch) | |
tree | 6cd7d3510f999701b5e2f7fe10b0f790cd868243 /bin/common/ask | |
parent | af9608a3a98f0ab4217da80b8d478810505801bc (diff) | |
parent | 694813e05187b5ccf144425c4bad6f5ab4f92234 (diff) |
Merge branch 'main' of db: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" |