Compare commits
No commits in common. "455ae71cd35a5fa0d66f6400f4b5e1185c1e3ad4" and "1767b2c7371c519e1cd894ab4a6813451722acb5" have entirely different histories.
455ae71cd3
...
1767b2c737
32
aicommit
32
aicommit
@ -1,18 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -eu
|
||||||
|
|
||||||
ARGS=("${@-}")
|
ARGS=("${@-}")
|
||||||
|
|
||||||
TMP_FILE="/tmp/aicommit"
|
TMP_FILE="/tmp/aicommit"
|
||||||
system=$(
|
system="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."
|
||||||
cat - <<EOF
|
|
||||||
|
|
||||||
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.
|
|
||||||
Give detail for every change in the diff.
|
|
||||||
|
|
||||||
EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
pushd "$(pwd)" >/dev/null
|
pushd "$(pwd)" >/dev/null
|
||||||
|
|
||||||
@ -29,6 +21,18 @@ hasFlag() {
|
|||||||
echo 'false'
|
echo 'false'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spin() {
|
||||||
|
echo "${@}"
|
||||||
|
while true; do
|
||||||
|
spinner=('-' '\' '|' '/')
|
||||||
|
for i in "${spinner[@]}"; do
|
||||||
|
echo -ne "\r${i}"
|
||||||
|
sleep .05
|
||||||
|
done
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
@ -44,12 +48,18 @@ message=$(
|
|||||||
# trunk-ignore(shellcheck/SC2091)
|
# trunk-ignore(shellcheck/SC2091)
|
||||||
# trunk-ignore(shellcheck/SC2310)
|
# trunk-ignore(shellcheck/SC2310)
|
||||||
if $(hasFlag -r --reset); then
|
if $(hasFlag -r --reset); then
|
||||||
|
spin "resetting AI history." &
|
||||||
|
SPINNER="$!"
|
||||||
if ! curl -s -X POST https://infer.x64.world/reset-conversation >/dev/null; then
|
if ! curl -s -X POST https://infer.x64.world/reset-conversation >/dev/null; then
|
||||||
echo "Failed to reset conversation."
|
echo "Failed to reset conversation."
|
||||||
|
kill ${SPINNER}
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
kill "${SPINNER}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
spin "AI is thinking." &
|
||||||
|
SPINNER="$!"
|
||||||
curl -s "https://infer.x64.world/chat" \
|
curl -s "https://infer.x64.world/chat" \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
@ -57,9 +67,11 @@ curl -s "https://infer.x64.world/chat" \
|
|||||||
|
|
||||||
# trunk-ignore(shellcheck/SC2181)
|
# trunk-ignore(shellcheck/SC2181)
|
||||||
if [[ 0 -ne $? ]]; then
|
if [[ 0 -ne $? ]]; then
|
||||||
|
kill "${SPINNER}"
|
||||||
echo "Failed to get response."
|
echo "Failed to get response."
|
||||||
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}"
|
||||||
|
|
||||||
|
@ -1,28 +1,31 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
ARGS=("${@-}")
|
ARGS=("${@-}")
|
||||||
TMP_FILE="/tmp/aicommit"
|
TMP_FILE="/tmp/aicommit"
|
||||||
|
|
||||||
system=$(
|
|
||||||
cat - <<EOF
|
|
||||||
|
|
||||||
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.
|
|
||||||
Give detail for every change in the diff.
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
system="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."
|
||||||
|
|
||||||
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
|
||||||
@ -30,7 +33,7 @@ fi
|
|||||||
|
|
||||||
message=$(
|
message=$(
|
||||||
jq -n \
|
jq -n \
|
||||||
".messages = [{role: \"system\", content: $(jq -R -s '@json' <<<"${system}")}, {role: \"user\", content: $(jq -R -s '@json' <<<"${diff}")}] |
|
".messages = [{role: \"system\", content: $(jq -R -s '@json' <<<"$system")}, {role: \"user\", content: $(jq -R -s '@json' <<<"$diff")}] |
|
||||||
.model = \"llama-3.1-70b-versatile\" |
|
.model = \"llama-3.1-70b-versatile\" |
|
||||||
.temperature = 1 |
|
.temperature = 1 |
|
||||||
.max_tokens = 1024 |
|
.max_tokens = 1024 |
|
||||||
@ -38,8 +41,8 @@ message=$(
|
|||||||
.stream = false |
|
.stream = false |
|
||||||
.stop = null"
|
.stop = null"
|
||||||
)
|
)
|
||||||
|
spin "AI is thinking..." &
|
||||||
# trunk-ignore(shellcheck/SC2312)
|
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" \
|
||||||
@ -48,8 +51,10 @@ 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