Title: Improve reset functionality
Content: Add error handling for resetting conversation.
This commit is contained in:
parent
3149d1e73b
commit
9efdd307ab
11
aicommit
11
aicommit
@ -4,7 +4,7 @@ set -o pipefail
|
|||||||
|
|
||||||
ARGS=("${@-}")
|
ARGS=("${@-}")
|
||||||
|
|
||||||
pushd "$(pwd)" "$@" >/dev/null
|
pushd "$(pwd)" >/dev/null
|
||||||
|
|
||||||
TMP_FILE="/tmp/aicommit"
|
TMP_FILE="/tmp/aicommit"
|
||||||
|
|
||||||
@ -35,9 +35,11 @@ message=$(
|
|||||||
".message = $(jq -R -s '@json' <<<"${message_cat}")"
|
".message = $(jq -R -s '@json' <<<"${message_cat}")"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# trunk-ignore(shellcheck/SC2091)
|
||||||
|
# trunk-ignore(shellcheck/SC2310)
|
||||||
if $(hasFlag -r --reset); then
|
if $(hasFlag -r --reset); then
|
||||||
curl -s -X POST https://infer.x64.world/reset-conversation "$@" >/dev/null
|
echo "resetting AI history."
|
||||||
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."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -48,6 +50,7 @@ curl -s "https://infer.x64.world/chat" \
|
|||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "${message}" | jq -r '.content | gsub("\""; "")' >"${TMP_FILE}"
|
-d "${message}" | jq -r '.content | gsub("\""; "")' >"${TMP_FILE}"
|
||||||
|
|
||||||
|
# trunk-ignore(shellcheck/SC2181)
|
||||||
if [[ 0 -ne $? ]]; then
|
if [[ 0 -ne $? ]]; then
|
||||||
echo "Failed to get response."
|
echo "Failed to get response."
|
||||||
exit 1
|
exit 1
|
||||||
@ -55,4 +58,4 @@ fi
|
|||||||
|
|
||||||
git commit -e -m "$(cat "${TMP_FILE}")" && rm "${TMP_FILE}"
|
git commit -e -m "$(cat "${TMP_FILE}")" && rm "${TMP_FILE}"
|
||||||
|
|
||||||
popd "$@" >/dev/null
|
popd >/dev/null
|
||||||
|
Loading…
Reference in New Issue
Block a user