(response)
| 79045 | var badFinishReasons = [ |
| 79046 | FinishReason.RECITATION, |
| 79047 | FinishReason.SAFETY, |
| 79048 | FinishReason.LANGUAGE |
| 79049 | ]; |
| 79050 | function hadBadFinishReason(candidate) { |
| 79051 | return !!candidate.finishReason && badFinishReasons.includes(candidate.finishReason); |
| 79052 | } |
| 79053 | function formatBlockErrorMessage(response) { |
| 79054 | var _a5, _b2, _c2; |
| 79055 | let message = ""; |
| 79056 | if ((!response.candidates || response.candidates.length === 0) && response.promptFeedback) { |
| 79057 | message += "Response was blocked"; |
| 79058 | if ((_a5 = response.promptFeedback) === null || _a5 === void 0 ? void 0 : _a5.blockReason) { |
| 79059 | message += ` due to ${response.promptFeedback.blockReason}`; |
| 79060 | } |
| 79061 | if ((_b2 = response.promptFeedback) === null || _b2 === void 0 ? void 0 : _b2.blockReasonMessage) { |
| 79062 | message += `: ${response.promptFeedback.blockReasonMessage}`; |
| 79063 | } |
| 79064 | } else if ((_c2 = response.candidates) === null || _c2 === void 0 ? void 0 : _c2[0]) { |
| 79065 | const firstCandidate = response.candidates[0]; |
| 79066 | if (hadBadFinishReason(firstCandidate)) { |
| 79067 | message += `Candidate was blocked due to ${firstCandidate.finishReason}`; |
| 79068 | if (firstCandidate.finishMessage) { |
| 79069 | message += `: ${firstCandidate.finishMessage}`; |
| 79070 | } |
| 79071 | } |
no test coverage detected
searching dependent graphs…