This repository has been archived on 2024-10-27 . You can view files and clone it, but cannot push or open issues or pull requests.
2023-10-27 19:19:22 -06:00
#!/bin/bash
DO_STREAM = false
SLEEP_TIME = 2
while getopts p:t:s flag; do
case " ${ flag } " in
s) DO_STREAM = true ; ;
p) PROXY_CHOICE = ${ OPTARG } ; ;
t) SLEEP_TIME = ${ OPTARG } ; ;
*) ; ;
esac
done
SOURCE = ${ BASH_SOURCE [0] }
while [ -L " $SOURCE " ] ; do # resolve $SOURCE until the file is no longer a symlink
DIR = $( cd -P " $( dirname " $SOURCE " ) " >/dev/null 2>& 1 && pwd )
SOURCE = $( readlink " $SOURCE " )
[ [ $SOURCE != /* ] ] && SOURCE = $DIR /$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR = $( cd -P " $( dirname " $SOURCE " ) " >/dev/null 2>& 1 && pwd )
source " $DIR /config.sh "
if [ ! -z " $PROXY_CHOICE " ] ; then
our_proxy_server = " ${ PROXY_SERVERS [ $PROXY_CHOICE ] } "
echo " Using $our_proxy_server "
else
our_proxy_server = ""
fi
while true; do
echo "--> START <--"
DATA = $(
cat <<EOF
{
"model" : "gpt-4" ,
"messages" : [ { "role" : "user" , "content" : "Write a 300 word story about an apple tree." } ] ,
"max_tokens" : 100,
"stream" : $DO_STREAM
}
EOF
)
2024-07-07 15:05:35 -06:00
curl " $HOST /api/openai/v1/chat/completions " -m 100 -x " $our_proxy_server " \
2023-10-27 19:19:22 -06:00
-H "Content-Type: application/json" \
-H " Authorization: Bearer $AUTH_KEY " \
-d " $DATA "
echo -e "--> DONE <--\n"
sleep $SLEEP_TIME
done