@cognigy/rest-api-client
Version:
Cognigy REST-Client
16 lines • 1 kB
JavaScript
import { TOP_K_MIN_VALUE, TOP_K_MAX_VALUE } from "../../constants/constants";
export 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 < TOP_K_MIN_VALUE || topK > TOP_K_MAX_VALUE) {
throw new Error(`Unable to perform knowledge search. topK value of "${topK}" is invalid. Must be between or equal to ${TOP_K_MIN_VALUE} and ${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.");
}
}
//# sourceMappingURL=configValidator.helper.js.map