(params, modelParams)
| 79323 | if (!hasUserContent && !hasFunctionContent) { |
| 79324 | throw new GoogleGenerativeAIError("No content is provided for sending chat message."); |
| 79325 | } |
| 79326 | if (hasUserContent) { |
| 79327 | return userContent; |
| 79328 | } |
| 79329 | return functionContent; |
| 79330 | } |
| 79331 | function formatCountTokensInput(params, modelParams) { |
| 79332 | var _a5; |
| 79333 | let formattedGenerateContentRequest = { |
| 79334 | model: modelParams === null || modelParams === void 0 ? void 0 : modelParams.model, |
| 79335 | generationConfig: modelParams === null || modelParams === void 0 ? void 0 : modelParams.generationConfig, |
| 79336 | safetySettings: modelParams === null || modelParams === void 0 ? void 0 : modelParams.safetySettings, |
| 79337 | tools: modelParams === null || modelParams === void 0 ? void 0 : modelParams.tools, |
| 79338 | toolConfig: modelParams === null || modelParams === void 0 ? void 0 : modelParams.toolConfig, |
| 79339 | systemInstruction: modelParams === null || modelParams === void 0 ? void 0 : modelParams.systemInstruction, |
| 79340 | cachedContent: (_a5 = modelParams === null || modelParams === void 0 ? void 0 : modelParams.cachedContent) === null || _a5 === void 0 ? void 0 : _a5.name, |
| 79341 | contents: [] |
| 79342 | }; |
| 79343 | const containsGenerateContentRequest = params.generateContentRequest != null; |
| 79344 | if (params.contents) { |
| 79345 | if (containsGenerateContentRequest) { |
| 79346 | throw new GoogleGenerativeAIRequestInputError("CountTokensRequest must have one of contents or generateContentRequest, not both."); |
| 79347 | } |
| 79348 | formattedGenerateContentRequest.contents = params.contents; |
| 79349 | } else if (containsGenerateContentRequest) { |
| 79350 | formattedGenerateContentRequest = Object.assign(Object.assign({}, formattedGenerateContentRequest), params.generateContentRequest); |
| 79351 | } else { |
| 79352 | const content = formatNewContent(params); |
| 79353 | formattedGenerateContentRequest.contents = [content]; |
no test coverage detected
searching dependent graphs…