Title: Update GROQ API request to match official documentation

Content: Updated curl command and removed unnecessary code for setting up spinner.
This commit is contained in:
ilguappo 2024-08-07 04:21:13 -07:00
parent 624861e320
commit ab5738d14e
2 changed files with 4 additions and 21 deletions

View File

@ -5,7 +5,6 @@ set -e
ARGS=("${@-}")
TMP_FILE="/tmp/aicommit"
system=$(
cat - <<EOF
@ -18,24 +17,11 @@ EOF
pushd "$(pwd)" >/dev/null || exit 1
spin() {
echo "${@}"
while true; do
spinner=('-' '\' '|' '/')
for i in "${spinner[@]}"; do
echo -ne "\r${i}"
sleep .05
done
done
echo ""
}
if [[ -z ${GROQ_API_KEY} ]]; then
echo "API key not set."
exit 1
fi
if ! diff=$(git diff --cached); then
echo "Failed to get diff."
exit 1
@ -51,8 +37,7 @@ message=$(
.stream = false |
.stop = null"
)
spin "AI is thinking..." &
SPINNER="$!"
curl -s "https://api.groq.com/openai/v1/chat/completions" \
-X POST \
-H "Content-Type: application/json" \
@ -61,10 +46,8 @@ curl -s "https://api.groq.com/openai/v1/chat/completions" \
if [[ 0 -ne $? ]]; then
echo "Failed to get response."
kill "${SPINNER}"
exit 1
fi
kill "${SPINNER}"
git commit -e -m "$(cat ${TMP_FILE})" && rm ${TMP_FILE}