diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-11-03 18:07:08 +0100 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-11-03 18:07:08 +0100 |
commit | d6cda512a3d6450b88fcd99b5d95addc768bc05c (patch) | |
tree | cdbb72d0abd79c6026406abd4f419b2d03cf1662 /bin | |
parent | c508a980ae4a6bffc5e968e2570118ae265fe46b (diff) |
made ask use tgpt
Diffstat (limited to 'bin')
-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" |