MCPcopy Create free account
hub / github.com/di-sukharev/opencommit / isValidResponse

Function isValidResponse

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

Source from the content-addressed store, hash-verified

79425 for (const key of VALID_PART_FIELDS) {
79426 if (!validParts.includes(key) && countFields[key] > 0) {
79427 throw new GoogleGenerativeAIError(`Content with role '${role}' can't contain '${key}' part`);
79428 }
79429 }
79430 prevContent = true;
79431 }
79432}
79433function isValidResponse(response) {
79434 var _a5;
79435 if (response.candidates === void 0 || response.candidates.length === 0) {
79436 return false;
79437 }
79438 const content = (_a5 = response.candidates[0]) === null || _a5 === void 0 ? void 0 : _a5.content;
79439 if (content === void 0) {
79440 return false;
79441 }
79442 if (content.parts === void 0 || content.parts.length === 0) {
79443 return false;
79444 }
79445 for (const part of content.parts) {
79446 if (part === void 0 || Object.keys(part).length === 0) {
79447 return false;
79448 }
79449 if (part.text !== void 0 && part.text === "") {
79450 return false;
79451 }

Callers 2

sendMessageMethod · 0.85
sendMessageStreamMethod · 0.85

Calls 1

keysMethod · 0.45

Tested by

no test coverage detected