(response)
| 78953 | requestOptions.signal.addEventListener("abort", () => { |
| 78954 | controller.abort(); |
| 78955 | }); |
| 78956 | } |
| 78957 | fetchOptions.signal = controller.signal; |
| 78958 | } |
| 78959 | return fetchOptions; |
| 78960 | } |
| 78961 | function addHelpers(response) { |
| 78962 | response.text = () => { |
| 78963 | if (response.candidates && response.candidates.length > 0) { |
| 78964 | if (response.candidates.length > 1) { |
| 78965 | console.warn(`This response had ${response.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`); |
| 78966 | } |
| 78967 | if (hadBadFinishReason(response.candidates[0])) { |
| 78968 | throw new GoogleGenerativeAIResponseError(`${formatBlockErrorMessage(response)}`, response); |
| 78969 | } |
| 78970 | return getText(response); |
| 78971 | } else if (response.promptFeedback) { |
| 78972 | throw new GoogleGenerativeAIResponseError(`Text not available. ${formatBlockErrorMessage(response)}`, response); |
| 78973 | } |
| 78974 | return ""; |
| 78975 | }; |
| 78976 | response.functionCall = () => { |
| 78977 | if (response.candidates && response.candidates.length > 0) { |
| 78978 | if (response.candidates.length > 1) { |
| 78979 | console.warn(`This response had ${response.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`); |
| 78980 | } |
| 78981 | if (hadBadFinishReason(response.candidates[0])) { |
| 78982 | throw new GoogleGenerativeAIResponseError(`${formatBlockErrorMessage(response)}`, response); |
| 78983 | } |
| 78984 | console.warn(`response.functionCall() is deprecated. Use response.functionCalls() instead.`); |
| 78985 | return getFunctionCalls(response)[0]; |
| 78986 | } else if (response.promptFeedback) { |
| 78987 | throw new GoogleGenerativeAIResponseError(`Function call not available. ${formatBlockErrorMessage(response)}`, response); |
| 78988 | } |
| 78989 | return void 0; |
| 78990 | }; |
| 78991 | response.functionCalls = () => { |
| 78992 | if (response.candidates && response.candidates.length > 0) { |
| 78993 | if (response.candidates.length > 1) { |
| 78994 | console.warn(`This response had ${response.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`); |
| 78995 | } |
| 78996 | if (hadBadFinishReason(response.candidates[0])) { |
| 78997 | throw new GoogleGenerativeAIResponseError(`${formatBlockErrorMessage(response)}`, response); |
| 78998 | } |
| 78999 | return getFunctionCalls(response); |
| 79000 | } else if (response.promptFeedback) { |
| 79001 | throw new GoogleGenerativeAIResponseError(`Function call not available. ${formatBlockErrorMessage(response)}`, response); |
| 79002 | } |
| 79003 | return void 0; |
no test coverage detected
searching dependent graphs…