From 9efdd307ab876a569365a5e67d32ff14fc346a94 Mon Sep 17 00:00:00 2001 From: anaxios Date: Wed, 7 Aug 2024 03:23:49 -0700 Subject: [PATCH] Title: Improve reset functionality Content: Add error handling for resetting conversation. --- aicommit | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/aicommit b/aicommit index d0150fb..43c5a75 100755 --- a/aicommit +++ b/aicommit @@ -4,7 +4,7 @@ set -o pipefail ARGS=("${@-}") -pushd "$(pwd)" "$@" >/dev/null +pushd "$(pwd)" >/dev/null TMP_FILE="/tmp/aicommit" @@ -35,9 +35,11 @@ message=$( ".message = $(jq -R -s '@json' <<<"${message_cat}")" ) +# trunk-ignore(shellcheck/SC2091) +# trunk-ignore(shellcheck/SC2310) if $(hasFlag -r --reset); then - curl -s -X POST https://infer.x64.world/reset-conversation "$@" >/dev/null - if ! curl -s -X POST https://infer.x64.world/reset-conversation "$@" >/dev/null; then + echo "resetting AI history." + if ! curl -s -X POST https://infer.x64.world/reset-conversation >/dev/null; then echo "Failed to reset conversation." exit 1 fi @@ -48,6 +50,7 @@ curl -s "https://infer.x64.world/chat" \ -H "Content-Type: application/json" \ -d "${message}" | jq -r '.content | gsub("\""; "")' >"${TMP_FILE}" +# trunk-ignore(shellcheck/SC2181) if [[ 0 -ne $? ]]; then echo "Failed to get response." exit 1 @@ -55,4 +58,4 @@ fi git commit -e -m "$(cat "${TMP_FILE}")" && rm "${TMP_FILE}" -popd "$@" >/dev/null +popd >/dev/null