@cognigy/rest-api-client
Version:
Cognigy REST-Client
20 lines • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateKnowledgeSearchConfig = void 0;
const constants_1 = require("../../constants/constants");
function validateKnowledgeSearchConfig({ knowledgeStoreId, topK = 5, searchStoreLocation, searchStoreLocationContextKey, searchStoreLocationInputKey, }) {
if (!knowledgeStoreId) {
throw new Error("Unable to perform knowledge search. No knowledge store was provided.");
}
if (topK < constants_1.TOP_K_MIN_VALUE || topK > constants_1.TOP_K_MAX_VALUE) {
throw new Error(`Unable to perform knowledge search. topK value of "${topK}" is invalid. Must be between or equal to ${constants_1.TOP_K_MIN_VALUE} and ${constants_1.TOP_K_MAX_VALUE}.`);
}
if (searchStoreLocation === "context" && !searchStoreLocationContextKey) {
throw new Error("Unable to perform knowledge search. Context Key is missing.");
}
if (searchStoreLocation === "input" && !searchStoreLocationInputKey) {
throw new Error("Unable to perform knowledge search. Input Key is missing.");
}
}
exports.validateKnowledgeSearchConfig = validateKnowledgeSearchConfig;
//# sourceMappingURL=configValidator.helper.js.map