Skip to content

Commit

Permalink
Merge pull request #55 from heiderich/url_in_error_message
Browse files Browse the repository at this point in the history
show URL in error message
  • Loading branch information
thomas-endres-tng authored Jan 4, 2025
2 parents c405b13 + 3daa7d6 commit 99e01ec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions please.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ explain_command() {
}

perform_openai_request() {
IFS=$'\n' read -r -d '' -a result < <(curl "${openai_invocation_url}/chat/completions" \
completions_url="${openai_invocation_url}/chat/completions"
IFS=$'\n' read -r -d '' -a result < <(curl "${completions_url}" \
-s -w "\n%{http_code}" \
-H "Content-Type: application/json" \
-H "Accept-Encoding: identity" \
Expand All @@ -236,8 +237,8 @@ perform_openai_request() {
response="${response_array[*]}"

if [ "${httpStatus}" -ne 200 ]; then
echo "Error: Received HTTP status ${httpStatus}"
echo "${response}" | jq .error.message --raw-output
echo "Error: Received HTTP status ${httpStatus} while trying to access ${completions_url}"
echo "${response}"
exit 1
else
message=$(echo "${response}" | jq '.choices[0].message.content' --raw-output)
Expand Down

0 comments on commit 99e01ec

Please sign in to comment.