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:
parent
624861e320
commit
ab5738d14e
2
aicommit
2
aicommit
@ -5,7 +5,7 @@ ARGS=("${@-}")
|
|||||||
|
|
||||||
TMP_FILE="/tmp/aicommit"
|
TMP_FILE="/tmp/aicommit"
|
||||||
system=$(
|
system=$(
|
||||||
cat - <<EOF
|
cat - <<EOF
|
||||||
|
|
||||||
You are an expert programmer that values clear, unambiguous communication and are specialized in generating concise and informative git commit messages.
|
You are an expert programmer that values clear, unambiguous communication and are specialized in generating concise and informative git commit messages.
|
||||||
Only reply with the commit message and nothing else.
|
Only reply with the commit message and nothing else.
|
||||||
|
@ -5,9 +5,8 @@ set -e
|
|||||||
ARGS=("${@-}")
|
ARGS=("${@-}")
|
||||||
TMP_FILE="/tmp/aicommit"
|
TMP_FILE="/tmp/aicommit"
|
||||||
|
|
||||||
|
|
||||||
system=$(
|
system=$(
|
||||||
cat - <<EOF
|
cat - <<EOF
|
||||||
|
|
||||||
You are an expert programmer that values clear, unambiguous communication and are specialized in generating concise and informative git commit messages.
|
You are an expert programmer that values clear, unambiguous communication and are specialized in generating concise and informative git commit messages.
|
||||||
Only reply with the commit message and nothing else.
|
Only reply with the commit message and nothing else.
|
||||||
@ -18,24 +17,11 @@ EOF
|
|||||||
|
|
||||||
pushd "$(pwd)" >/dev/null || exit 1
|
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
|
if [[ -z ${GROQ_API_KEY} ]]; then
|
||||||
echo "API key not set."
|
echo "API key not set."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if ! diff=$(git diff --cached); then
|
if ! diff=$(git diff --cached); then
|
||||||
echo "Failed to get diff."
|
echo "Failed to get diff."
|
||||||
exit 1
|
exit 1
|
||||||
@ -51,8 +37,7 @@ message=$(
|
|||||||
.stream = false |
|
.stream = false |
|
||||||
.stop = null"
|
.stop = null"
|
||||||
)
|
)
|
||||||
spin "AI is thinking..." &
|
|
||||||
SPINNER="$!"
|
|
||||||
curl -s "https://api.groq.com/openai/v1/chat/completions" \
|
curl -s "https://api.groq.com/openai/v1/chat/completions" \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
@ -61,10 +46,8 @@ curl -s "https://api.groq.com/openai/v1/chat/completions" \
|
|||||||
|
|
||||||
if [[ 0 -ne $? ]]; then
|
if [[ 0 -ne $? ]]; then
|
||||||
echo "Failed to get response."
|
echo "Failed to get response."
|
||||||
kill "${SPINNER}"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
kill "${SPINNER}"
|
|
||||||
|
|
||||||
git commit -e -m "$(cat ${TMP_FILE})" && rm ${TMP_FILE}
|
git commit -e -m "$(cat ${TMP_FILE})" && rm ${TMP_FILE}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user