MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / formatBlockErrorMessage

Function formatBlockErrorMessage

out/cli.cjs:79047–79068  ·  view source on GitHub ↗
(response)

Source from the content-addressed store, hash-verified

79045var badFinishReasons = [
79046 FinishReason.RECITATION,
79047 FinishReason.SAFETY,
79048 FinishReason.LANGUAGE
79049];
79050function hadBadFinishReason(candidate) {
79051 return !!candidate.finishReason && badFinishReasons.includes(candidate.finishReason);
79052}
79053function 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 }

Callers 3

addHelpersFunction · 0.85
sendMessageMethod · 0.85
sendMessageStreamMethod · 0.85

Calls 1

hadBadFinishReasonFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…