0xacx / chatGPT-shell-cli

Simple shell script to use OpenAI's ChatGPT and DALL-E from the terminal. No Python or JS required.
https://gptshell.cc
MIT License
1.05k stars 151 forks source link

recognize rate-limit and wait #114

Open TiloGit opened 1 year ago

TiloGit commented 1 year ago

would be great if the tool could understand when a rate limit is hit and wait for the suggested seconds (seems to be always 20s) and try again. maybe allow max retires in the cmd line.

Cheers

our request to Open AI API failed: 
Rate limit reached for default-gpt-3.5-turbo in organization org-OtZ--removed--  on requests per min. 
Limit: 3 / min. Please try again in 20s. Contact us through our help center at help.openai.com if you continue to have issues. 
Please add a payment method to your account to increase your rate limit. 
Visit https://platform.openai.com/account/billing to add a payment method.
TiloGit commented 1 year ago

here my poor man rate limit loop, might help someone for now.

###simple loop with rate limit helper 3 per min
for file in *.txt
do     
echo "$(date +"%F_%s")  now Work on ___ ${file}"
filebase=$(basename "$file" .txt)
i=$(($i+1))
echo "write letter ${filebase}" | chatgpt > "chatGPT-output/${file}"
##sleep to avoid rate limit
if test $i -gt 2 ; then echo "Wait to avoid rate limit: $i" && sleep 65 && i=$null; else echo "We are good :: $i" ; fi
done