Compare commits
10 Commits
1767b2c737
...
455ae71cd3
Author | SHA1 | Date | |
---|---|---|---|
455ae71cd3 | |||
6fa213550d | |||
e0ee195fca | |||
7de04c06c9 | |||
ab5738d14e | |||
624861e320 | |||
cf655b7202 | |||
41dc5665b4 | |||
74909d05f4 | |||
c72a7835da |
32
aicommit
32
aicommit
@ -1,10 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
set -e
|
||||||
|
|
||||||
ARGS=("${@-}")
|
ARGS=("${@-}")
|
||||||
|
|
||||||
TMP_FILE="/tmp/aicommit"
|
TMP_FILE="/tmp/aicommit"
|
||||||
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."
|
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
|
pushd "$(pwd)" >/dev/null
|
||||||
|
|
||||||
@ -21,18 +29,6 @@ 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
|
||||||
@ -48,18 +44,12 @@ 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" \
|
||||||
@ -67,11 +57,9 @@ 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,31 +1,28 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
ARGS=("${@-}")
|
ARGS=("${@-}")
|
||||||
TMP_FILE="/tmp/aicommit"
|
TMP_FILE="/tmp/aicommit"
|
||||||
|
|
||||||
pushd "$(pwd)" >/dev/null || exit 1
|
system=$(
|
||||||
|
cat - <<EOF
|
||||||
|
|
||||||
spin() {
|
You are an expert programmer that values clear, unambiguous communication and are specialized in generating concise and informative git commit messages.
|
||||||
echo "${@}"
|
Only reply with the commit message and nothing else.
|
||||||
while true; do
|
Give detail for every change in the diff.
|
||||||
spinner=('-' '\' '|' '/')
|
|
||||||
for i in "${spinner[@]}"; do
|
EOF
|
||||||
echo -ne "\r${i}"
|
)
|
||||||
sleep .05
|
|
||||||
done
|
pushd "$(pwd)" >/dev/null || exit 1
|
||||||
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
|
||||||
@ -33,7 +30,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 |
|
||||||
@ -41,8 +38,8 @@ message=$(
|
|||||||
.stream = false |
|
.stream = false |
|
||||||
.stop = null"
|
.stop = null"
|
||||||
)
|
)
|
||||||
spin "AI is thinking..." &
|
|
||||||
SPINNER="$!"
|
# trunk-ignore(shellcheck/SC2312)
|
||||||
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" \
|
||||||
@ -51,10 +48,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