(response)
| 79736 | return promptFeedback.blockReasonMessage ? `Gemini response was blocked due to ${promptFeedback.blockReason}: ${promptFeedback.blockReasonMessage}` : `Gemini response was blocked due to ${promptFeedback.blockReason}`; |
| 79737 | } |
| 79738 | const firstCandidate = response.candidates?.[0]; |
| 79739 | if (firstCandidate?.finishReason) { |
| 79740 | return firstCandidate.finishMessage ? `Gemini response was blocked due to ${firstCandidate.finishReason}: ${firstCandidate.finishMessage}` : `Gemini response was blocked due to ${firstCandidate.finishReason}`; |
| 79741 | } |
| 79742 | return "Gemini response did not contain usable text"; |
| 79743 | }; |
| 79744 | var extractGeminiText = (response) => { |
| 79745 | const firstCandidate = response.candidates?.[0]; |
| 79746 | if (firstCandidate?.finishReason && GEMINI_BLOCKING_FINISH_REASONS.has(firstCandidate.finishReason)) { |
| 79747 | throw new Error(formatGeminiBlockMessage(response)); |
| 79748 | } |
| 79749 | const text = firstCandidate?.content?.parts?.flatMap( |
| 79750 | (part) => "text" in part && typeof part.text === "string" ? [part.text] : [] |
| 79751 | ).join(""); |
| 79752 | if (typeof text === "string" && text.length > 0) { |
| 79753 | return text; |
| 79754 | } |
| 79755 | if (response.promptFeedback?.blockReason) { |
| 79756 | throw new Error(formatGeminiBlockMessage(response)); |
no test coverage detected
searching dependent graphs…