UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

102 lines 3.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.COPY_SLOTS_TO_CONTEXT = void 0; /* Custom modules */ const createNodeDescriptor_1 = require("../../createNodeDescriptor"); /** * Node name: 'copySlotsToContext' * * Purpose: * Moves slots to context * @param key the context you want to set * @param tag the slot tag you want to copy * @param mode what mode to execute. Array adds the value to an array * @param useNeg if true, positive elements will be added, negative elements will be deleted */ exports.COPY_SLOTS_TO_CONTEXT = (0, createNodeDescriptor_1.createNodeDescriptor)({ type: "copySlotsToContext", defaultLabel: "Copy Slots To Context", summary: "UI__NODE_EDITOR__COPY_SLOTS_TO_CONTEXT__SUMMARY", appearance: { showIcon: false }, fields: [ { key: "key", type: "cognigyText", label: "UI__NODE_EDITOR__COPY_SLOTS_TO_CONTEXT__FIELDS__KEY__LABEL", params: { required: true } }, { key: "tag", type: "cognigyText", label: "UI__NODE_EDITOR__COPY_SLOTS_TO_CONTEXT__FIELDS__TAG__LABEL", params: { required: true } }, { key: "useNeg", type: "toggle", label: "UI__NODE_EDITOR__COPY_SLOTS_TO_CONTEXT__FIELDS__USE_NEG__LABEL", }, { key: "mode", type: "select", label: "UI__NODE_EDITOR__COPY_SLOTS_TO_CONTEXT__FIELDS__MODE__LABEL", description: "UI__NODE_EDITOR__COPY_SLOTS_TO_CONTEXT__FIELDS__MODE__DESCRIPTION", defaultValue: "simple", params: { required: true, options: [ { label: "UI__NODE_EDITOR__COPY_SLOTS_TO_CONTEXT__FIELDS__MODE__OPTIONS__SIMPLE__LABEL", value: "simple", }, { label: "UI__NODE_EDITOR__COPY_SLOTS_TO_CONTEXT__FIELDS__MODE__OPTIONS__ARRAY__LABEL", value: "array", } ] } } ], sections: [ { key: "advanced", label: "UI__NODE_EDITOR__COPY_SLOTS_TO_CONTEXT__SECTIONS__ADVANCED__LABEL", defaultCollapsed: true, fields: [ "useNeg", "mode" ] } ], form: [ { type: "field", key: "key" }, { type: "field", key: "tag" }, { type: "section", key: "advanced" } ], tags: ["ai", "data", "nlu"], function: async ({ cognigy, config }) => { const { key, tag, useNeg, mode } = config; const { input, api } = cognigy; if (!input.slots || !input.slots[tag]) { return; } let debug = ""; for (const keyphrase of input.slots[tag]) { if (keyphrase.neg && useNeg) { api.removeFromContext(key, keyphrase.lower, mode); } else { api.addToContext(key, keyphrase.lower, mode); debug += `UI__DEBUG_MODE__COPY_SLOTS_TO_CONTEXT__MESSAGE_1 ${keyphrase.lower} UI__DEBUG_MODE__COPY_SLOTS_TO_CONTEXT__MESSAGE_2 context.${key}<br>`; } } debug && api.logDebugMessage(`${debug}`); } }); //# sourceMappingURL=copySlotsToContext.js.map