Skip to content

Commit bec5648

Browse files
wehosHongzhi Wen
andauthored
Accept empty health check completions (Project-N-E-K-O#1241)
Co-authored-by: Hongzhi Wen <cartabio.coder1@gmail.com>
1 parent e7a0813 commit bec5648

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

.github/workflows/health-check.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ jobs:
2626
echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT"
2727
2828
if [ "$HTTP_CODE" = "200" ]; then
29-
HAS_CHOICES=$(echo "$BODY" | jq -r '.choices[0].message.content // empty' 2>/dev/null || true)
30-
if [ -n "$HAS_CHOICES" ]; then
29+
if echo "$BODY" | jq -e '(.choices | type) == "array" and (.choices | length) > 0 and (.choices[0].message | type) == "object" and .choices[0].message.role == "assistant" and (.choices[0].message | has("content"))' >/dev/null 2>&1; then
3130
echo "healthy=true" >> "$GITHUB_OUTPUT"
3231
else
3332
echo "healthy=false" >> "$GITHUB_OUTPUT"
@@ -51,8 +50,7 @@ jobs:
5150
echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT"
5251
5352
if [ "$HTTP_CODE" = "200" ]; then
54-
HAS_CHOICES=$(echo "$BODY" | jq -r '.choices[0].message.content // empty' 2>/dev/null || true)
55-
if [ -n "$HAS_CHOICES" ]; then
53+
if echo "$BODY" | jq -e '(.choices | type) == "array" and (.choices | length) > 0 and (.choices[0].message | type) == "object" and .choices[0].message.role == "assistant" and (.choices[0].message | has("content"))' >/dev/null 2>&1; then
5654
echo "healthy=true" >> "$GITHUB_OUTPUT"
5755
else
5856
echo "healthy=false" >> "$GITHUB_OUTPUT"
@@ -76,8 +74,7 @@ jobs:
7674
echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT"
7775
7876
if [ "$HTTP_CODE" = "200" ]; then
79-
HAS_CHOICES=$(echo "$BODY" | jq -r '.choices[0].message.content // empty' 2>/dev/null || true)
80-
if [ -n "$HAS_CHOICES" ]; then
77+
if echo "$BODY" | jq -e '(.choices | type) == "array" and (.choices | length) > 0 and (.choices[0].message | type) == "object" and .choices[0].message.role == "assistant" and (.choices[0].message | has("content"))' >/dev/null 2>&1; then
8178
echo "healthy=true" >> "$GITHUB_OUTPUT"
8279
else
8380
echo "healthy=false" >> "$GITHUB_OUTPUT"
@@ -101,8 +98,7 @@ jobs:
10198
echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT"
10299
103100
if [ "$HTTP_CODE" = "200" ]; then
104-
HAS_CHOICES=$(echo "$BODY" | jq -r '.choices[0].message.content // empty' 2>/dev/null || true)
105-
if [ -n "$HAS_CHOICES" ]; then
101+
if echo "$BODY" | jq -e '(.choices | type) == "array" and (.choices | length) > 0 and (.choices[0].message | type) == "object" and .choices[0].message.role == "assistant" and (.choices[0].message | has("content"))' >/dev/null 2>&1; then
106102
echo "healthy=true" >> "$GITHUB_OUTPUT"
107103
else
108104
echo "healthy=false" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)