|
26 | 26 | echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT" |
27 | 27 |
|
28 | 28 | 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 |
31 | 30 | echo "healthy=true" >> "$GITHUB_OUTPUT" |
32 | 31 | else |
33 | 32 | echo "healthy=false" >> "$GITHUB_OUTPUT" |
|
51 | 50 | echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT" |
52 | 51 |
|
53 | 52 | 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 |
56 | 54 | echo "healthy=true" >> "$GITHUB_OUTPUT" |
57 | 55 | else |
58 | 56 | echo "healthy=false" >> "$GITHUB_OUTPUT" |
|
76 | 74 | echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT" |
77 | 75 |
|
78 | 76 | 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 |
81 | 78 | echo "healthy=true" >> "$GITHUB_OUTPUT" |
82 | 79 | else |
83 | 80 | echo "healthy=false" >> "$GITHUB_OUTPUT" |
|
101 | 98 | echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT" |
102 | 99 |
|
103 | 100 | 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 |
106 | 102 | echo "healthy=true" >> "$GITHUB_OUTPUT" |
107 | 103 | else |
108 | 104 | echo "healthy=false" >> "$GITHUB_OUTPUT" |
|
0 commit comments