@cognigy/rest-api-client 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/GenericTusFn.js +6 -1
  3. package/build/GenericUploadFn.js +3 -5
  4. package/build/apigroups/ResourcesAPIGroup_2_0.js +12 -1
  5. package/build/connector/AxiosAdapter.js +35 -15
  6. package/build/shared/charts/createNodeDescriptor.js +5 -5
  7. package/build/shared/charts/descriptors/agentAssist/constants/constants.js +16 -1
  8. package/build/shared/charts/descriptors/agentAssist/helpers/agentAssistTranslator.helper.js +19 -0
  9. package/build/shared/charts/descriptors/agentAssist/helpers/getFontSizeFieldOptions.js +84 -0
  10. package/build/shared/charts/descriptors/agentAssist/helpers/getLanguageName.helper.js +33 -0
  11. package/build/shared/charts/descriptors/agentAssist/helpers/knowledgeSearch/answerExtraction.helper.js +59 -0
  12. package/build/shared/charts/descriptors/agentAssist/helpers/knowledgeSearch/configValidator.helper.js +20 -0
  13. package/build/shared/charts/descriptors/agentAssist/helpers/knowledgeSearch/errorHandler.helper.js +64 -0
  14. package/build/shared/charts/descriptors/agentAssist/helpers/knowledgeSearch/followUpDetection.helper.js +72 -0
  15. package/build/shared/charts/descriptors/agentAssist/helpers/knowledgeSearch/knowledgeSearch.helper.js +58 -0
  16. package/build/shared/charts/descriptors/agentAssist/helpers/sentiment.helper.js +7 -13
  17. package/build/shared/charts/descriptors/agentAssist/htmlTemplates/identityAssistTemplate.js +17 -18
  18. package/build/shared/charts/descriptors/agentAssist/htmlTemplates/knowledgeAssistTemplate.js +330 -153
  19. package/build/shared/charts/descriptors/agentAssist/htmlTemplates/nextActionWidgetTemplate.js +212 -80
  20. package/build/shared/charts/descriptors/agentAssist/htmlTemplates/sentimentAnalysisTemplate.js +11 -6
  21. package/build/shared/charts/descriptors/agentAssist/htmlTemplates/transcriptAssistTemplate.js +15 -13
  22. package/build/shared/charts/descriptors/agentAssist/identityAssist.js +87 -14
  23. package/build/shared/charts/descriptors/agentAssist/knowledgeAssist.js +192 -327
  24. package/build/shared/charts/descriptors/agentAssist/locales/cs.locale.js +11 -0
  25. package/build/shared/charts/descriptors/agentAssist/locales/de.locale.js +11 -0
  26. package/build/shared/charts/descriptors/agentAssist/locales/en.locale.js +11 -0
  27. package/build/shared/charts/descriptors/agentAssist/locales/es.locale.js +11 -0
  28. package/build/shared/charts/descriptors/agentAssist/locales/fr.locale.js +11 -0
  29. package/build/shared/charts/descriptors/agentAssist/locales/index.js +22 -0
  30. package/build/shared/charts/descriptors/agentAssist/locales/ja.locale.js +11 -0
  31. package/build/shared/charts/descriptors/agentAssist/locales/ko.locale.js +11 -0
  32. package/build/shared/charts/descriptors/agentAssist/locales/pt.locale.js +11 -0
  33. package/build/shared/charts/descriptors/agentAssist/nextActionAssist.js +485 -10
  34. package/build/shared/charts/descriptors/agentAssist/sentimentAssist.js +31 -8
  35. package/build/shared/charts/descriptors/agentAssist/transcriptAssist.js +40 -2
  36. package/build/shared/charts/descriptors/analytics/requestRating.js +56 -2
  37. package/build/shared/charts/descriptors/index.js +1 -3
  38. package/build/shared/charts/descriptors/knowledgeSearch/searchExtractOutput.js +1 -1
  39. package/build/shared/charts/descriptors/message/question/optionalQuestion.js +1 -1
  40. package/build/shared/charts/descriptors/message/question/question.js +123 -2
  41. package/build/shared/charts/descriptors/message/question/utils/evaluateQuestionAnswer.js +44 -3
  42. package/build/shared/charts/descriptors/nlu/generativeSlotFiller/prompt.js +28 -12
  43. package/build/shared/charts/descriptors/nlu/index.js +1 -3
  44. package/build/shared/charts/descriptors/service/GPTPrompt.js +320 -22
  45. package/build/shared/charts/descriptors/service/LLMEntityExtract.js +274 -0
  46. package/build/shared/charts/descriptors/service/httpRequest.js +33 -1
  47. package/build/shared/charts/descriptors/service/index.js +3 -1
  48. package/build/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +17 -13
  49. package/build/shared/charts/descriptors/voice/mappers/transfer.mapper.js +4 -4
  50. package/build/shared/charts/descriptors/voice/nodes/play.js +8 -1
  51. package/build/shared/charts/descriptors/voice/nodes/sessionSpeechParameters.js +44 -45
  52. package/build/shared/charts/descriptors/voicegateway2/nodes/play.js +0 -1
  53. package/build/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +31 -39
  54. package/build/shared/charts/descriptors/voicegateway2/nodes/transfer.js +17 -25
  55. package/build/shared/charts/helpers/generativeAI/generativeAIPrompts.js +55 -0
  56. package/build/shared/interfaces/appsession/IAppSession.js +3 -0
  57. package/build/shared/interfaces/appsession/ISetAppState.js +3 -0
  58. package/build/shared/interfaces/appsession/index.js +3 -0
  59. package/build/shared/interfaces/fileStorage.js +6 -0
  60. package/build/shared/interfaces/generativeAI/IGenerativeAIModels.js +32 -3
  61. package/build/shared/interfaces/handover.js +2 -1
  62. package/build/shared/interfaces/messageAPI/endpoints.js +15 -2
  63. package/build/shared/interfaces/messageAPI/handover.js +5 -1
  64. package/build/shared/interfaces/nlu/nlu.js +3 -0
  65. package/build/shared/interfaces/resources/IAuditEvent.js +10 -9
  66. package/build/shared/interfaces/resources/ILargeLanguageModel.js +34 -20
  67. package/build/shared/interfaces/resources/IMilestone.js +50 -0
  68. package/build/shared/interfaces/resources/INodeDescriptorSet.js +84 -75
  69. package/build/shared/interfaces/resources/TResourceType.js +12 -5
  70. package/build/shared/interfaces/resources/settings/IGenerativeAISettings.js +4 -0
  71. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/ICloneMilestoneRest_2_0.js +3 -0
  72. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/ICreateMilestoneRest_2_0.js +3 -0
  73. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IDeleteMilestoneRest_2_0.js +3 -0
  74. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IIndexMilestonesRest_2_0.js +3 -0
  75. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IMilestoneIndexItem_2_0.js +3 -0
  76. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IMilestoneStepMetric_2_0.js +3 -0
  77. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IMilestoneStep_2_0.js +3 -0
  78. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IMilestone_2_0.js +3 -0
  79. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IReadMilestoneRest_2_0.js +3 -0
  80. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IUpdateMilestoneRest_2_0.js +3 -0
  81. package/build/shared/interfaces/restAPI/resources/milestone/v2.0/index.js +3 -0
  82. package/build/shared/interfaces/restAPI/resources/uploadResumable/v2.0/IUploadResumableRest_2_0.js +3 -1
  83. package/build/shared/interfaces/security/IPermission.js +4 -2
  84. package/build/shared/interfaces/security/index.js +1 -1
  85. package/package.json +2 -2
  86. package/types/index.d.ts +938 -285
  87. package/build/shared/charts/descriptors/nlu/extractAnswer.js +0 -115
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const translations = {
4
+ feeling: {
5
+ positive: "Pozitivní",
6
+ negative: "Negativní",
7
+ neutral: "Neutrální",
8
+ },
9
+ };
10
+ exports.default = translations;
11
+ //# sourceMappingURL=cs.locale.js.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const translations = {
4
+ feeling: {
5
+ positive: "Positiv",
6
+ negative: "Negativ",
7
+ neutral: "Neutral",
8
+ },
9
+ };
10
+ exports.default = translations;
11
+ //# sourceMappingURL=de.locale.js.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const translations = {
4
+ feeling: {
5
+ positive: "Positive",
6
+ negative: "Negative",
7
+ neutral: "Neutral",
8
+ },
9
+ };
10
+ exports.default = translations;
11
+ //# sourceMappingURL=en.locale.js.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const translations = {
4
+ feeling: {
5
+ positive: "Positivo",
6
+ negative: "Negativo",
7
+ neutral: "Neutral",
8
+ },
9
+ };
10
+ exports.default = translations;
11
+ //# sourceMappingURL=es.locale.js.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const translations = {
4
+ feeling: {
5
+ positive: "Positif",
6
+ negative: "Négatif",
7
+ neutral: "Neutre",
8
+ },
9
+ };
10
+ exports.default = translations;
11
+ //# sourceMappingURL=fr.locale.js.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.translations = void 0;
4
+ const en_locale_1 = require("./en.locale");
5
+ const de_locale_1 = require("./de.locale");
6
+ const es_locale_1 = require("./es.locale");
7
+ const pt_locale_1 = require("./pt.locale");
8
+ const fr_locale_1 = require("./fr.locale");
9
+ const cs_locale_1 = require("./cs.locale");
10
+ const ja_locale_1 = require("./ja.locale");
11
+ const ko_locale_1 = require("./ko.locale");
12
+ exports.translations = {
13
+ en: en_locale_1.default,
14
+ de: de_locale_1.default,
15
+ es: es_locale_1.default,
16
+ pt: pt_locale_1.default,
17
+ fr: fr_locale_1.default,
18
+ cs: cs_locale_1.default,
19
+ ja: ja_locale_1.default,
20
+ ko: ko_locale_1.default,
21
+ };
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const translations = {
4
+ feeling: {
5
+ positive: "ポジティブ",
6
+ negative: "ネガティブ",
7
+ neutral: "中立",
8
+ },
9
+ };
10
+ exports.default = translations;
11
+ //# sourceMappingURL=ja.locale.js.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const translations = {
4
+ feeling: {
5
+ positive: "긍정적",
6
+ negative: "부정적",
7
+ neutral: "중립적",
8
+ },
9
+ };
10
+ exports.default = translations;
11
+ //# sourceMappingURL=ko.locale.js.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const translations = {
4
+ feeling: {
5
+ positive: "Positivo",
6
+ negative: "Negativo",
7
+ neutral: "Neutro",
8
+ },
9
+ };
10
+ exports.default = translations;
11
+ //# sourceMappingURL=pt.locale.js.map
@@ -3,7 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NEXT_ACTION_ASSIST = void 0;
4
4
  /* Custom modules */
5
5
  const createNodeDescriptor_1 = require("../../createNodeDescriptor");
6
+ const constants_1 = require("./constants/constants");
6
7
  const nextActionWidgetTemplate_1 = require("./htmlTemplates/nextActionWidgetTemplate");
8
+ const constants_2 = require("./constants/constants");
9
+ const configValidator_helper_1 = require("./helpers/knowledgeSearch/configValidator.helper");
10
+ const followUpDetection_helper_1 = require("./helpers/knowledgeSearch/followUpDetection.helper");
11
+ const errorHandler_helper_1 = require("./helpers/knowledgeSearch/errorHandler.helper");
12
+ const knowledgeSearch_helper_1 = require("./helpers/knowledgeSearch/knowledgeSearch.helper");
13
+ const answerExtraction_helper_1 = require("./helpers/knowledgeSearch/answerExtraction.helper");
14
+ const getFontSizeFieldOptions_1 = require("./helpers/getFontSizeFieldOptions");
7
15
  /**
8
16
  * Node name: "nextActionAssist"
9
17
  *
@@ -35,40 +43,507 @@ exports.NEXT_ACTION_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
35
43
  type: "cognigyText",
36
44
  description: "UI__NODE_EDITOR__NEXT_ACTION_ASSIST__TEXT__DESCRIPTION",
37
45
  defaultValue: "",
46
+ condition: {
47
+ key: "type",
48
+ value: "text",
49
+ },
50
+ },
51
+ {
52
+ key: "type",
53
+ label: "UI__NODE_EDITOR__NEXT_ACTION_ASSIST__TYPE__LABEL",
54
+ type: "select",
55
+ defaultValue: "text",
56
+ params: {
57
+ options: [
58
+ {
59
+ label: "UI__NODE_EDITOR__NEXT_ACTION_ASSIST__TYPE__OPTIONS__TEXT__LABEL",
60
+ value: "text",
61
+ },
62
+ {
63
+ label: "UI__NODE_EDITOR__NEXT_ACTION_ASSIST__TYPE__OPTIONS_KNOWLEDGE_ASSIST__LABEL",
64
+ value: "knowledgeAssist",
65
+ },
66
+ ],
67
+ },
68
+ },
69
+ {
70
+ key: "knowledgeStoreId",
71
+ type: "knowledgeStoreSelect",
72
+ label: "UI__NODE_EDITOR__NEXT_ACTION_ASSIST__TYPE__KNOWLEDGE_STORE_ID__LABEL",
73
+ description: "UI__NODE_EDITOR__NEXT_ACTION_ASSIST__TYPE__KNOWLEDGE_STORE_ID__DESCRIPTION",
74
+ params: {
75
+ required: true,
76
+ },
77
+ condition: {
78
+ key: "type",
79
+ value: "knowledgeAssist",
80
+ },
81
+ },
82
+ {
83
+ key: "followUpDetection",
84
+ type: "select",
85
+ label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FOLLOW_UP_DETECTION__LABEL",
86
+ description: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FOLLOW_UP_DETECTION__DESCRIPTION",
87
+ defaultValue: "transcript",
88
+ params: {
89
+ options: [
90
+ {
91
+ label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FOLLOW_UP_DETECTION__OPTIONS__NONE__LABEL",
92
+ value: "none",
93
+ },
94
+ {
95
+ label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FOLLOW_UP_DETECTION__OPTIONS__TRANSCRIPT__LABEL",
96
+ value: "transcript",
97
+ },
98
+ ],
99
+ },
100
+ },
101
+ {
102
+ key: "followUpDetectionSteps",
103
+ type: "slider",
104
+ label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FOLLOW_UP_DETECTION_STEPS__LABEL",
105
+ description: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FOLLOW_UP_DETECTION_STEPS__DESCRIPTION",
106
+ defaultValue: 2,
107
+ params: {
108
+ min: 1,
109
+ max: 6,
110
+ step: 1,
111
+ },
112
+ condition: {
113
+ key: "followUpDetection",
114
+ value: "transcript",
115
+ },
116
+ },
117
+ {
118
+ key: "topK",
119
+ type: "slider",
120
+ label: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__TOP_K__LABEL",
121
+ description: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__TOP_K__DESCRIPTION",
122
+ defaultValue: 5,
38
123
  params: {
39
124
  required: true,
125
+ min: constants_1.TOP_K_MIN_VALUE,
126
+ max: constants_1.TOP_K_MAX_VALUE,
127
+ },
128
+ },
129
+ {
130
+ key: "searchStoreLocation",
131
+ type: "select",
132
+ label: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__STORE_LOCATION__LABEL",
133
+ params: {
134
+ options: [
135
+ {
136
+ label: "default (input.knowledgeSearch)",
137
+ value: "default",
138
+ },
139
+ {
140
+ label: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__STORE_LOCATION__INPUT__LABEL",
141
+ value: "input",
142
+ },
143
+ {
144
+ label: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__STORE_LOCATION__CONTEXT__LABEL",
145
+ value: "context",
146
+ },
147
+ ],
148
+ required: true,
149
+ },
150
+ defaultValue: "default",
151
+ },
152
+ {
153
+ key: "searchStoreLocationInputKey",
154
+ type: "cognigyText",
155
+ label: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__INPUT_KEY__LABEL",
156
+ description: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__INPUT_KEY__DESCRIPTION",
157
+ defaultValue: "knowledgeSearch",
158
+ condition: {
159
+ key: "searchStoreLocation",
160
+ value: "input",
161
+ },
162
+ },
163
+ {
164
+ key: "searchStoreLocationContextKey",
165
+ type: "cognigyText",
166
+ label: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__CONTEXT_KEY__LABEL",
167
+ description: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__CONTEXT_KEY__DESCRIPTION",
168
+ defaultValue: "knowledgeSearch",
169
+ condition: {
170
+ key: "searchStoreLocation",
171
+ value: "context",
172
+ },
173
+ },
174
+ {
175
+ key: "prompt",
176
+ label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__PROMPT__LABEL",
177
+ type: "cognigyText",
178
+ description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__PROMPT__DESCRIPTION",
179
+ params: {
180
+ required: true,
181
+ multiline: true,
182
+ rows: 5,
183
+ },
184
+ defaultValue: constants_2.DEFAULT_PROMPT,
185
+ },
186
+ {
187
+ key: "temperature",
188
+ label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TEMPERATURE__LABEL",
189
+ type: "slider",
190
+ description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TEMPERATURE__DESCRIPTION",
191
+ defaultValue: 0.7,
192
+ params: {
193
+ min: 0,
194
+ max: 1,
195
+ step: 0.1,
196
+ },
197
+ },
198
+ {
199
+ key: "maxTokens",
200
+ label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__MAX_TOKENS__LABEL",
201
+ type: "slider",
202
+ description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__MAX_TOKENS__DESCRIPTION",
203
+ defaultValue: 1000,
204
+ params: {
205
+ min: 100,
206
+ max: 4000,
207
+ step: 1,
208
+ },
209
+ },
210
+ {
211
+ key: "frequencyPenalty",
212
+ label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__FREQUENCY_PENALTY__LABEL",
213
+ type: "slider",
214
+ description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__FREQUENCY_PENALTY__DESCRIPTION",
215
+ defaultValue: 0,
216
+ params: {
217
+ min: -2,
218
+ max: 2,
219
+ step: 0.1,
220
+ },
221
+ },
222
+ {
223
+ key: "presencePenalty",
224
+ label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__PRESENCE_PENALTY__LABEL",
225
+ type: "slider",
226
+ description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__PRESENCE_PENALTY__DESCRIPTION",
227
+ defaultValue: 0,
228
+ params: {
229
+ min: -2,
230
+ max: 2,
231
+ step: 0.1,
232
+ },
233
+ },
234
+ {
235
+ key: "useStop",
236
+ label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__USE_STOP__LABEL",
237
+ type: "toggle",
238
+ description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__USE_STOP__DESCRIPTION",
239
+ defaultValue: false,
240
+ },
241
+ {
242
+ key: "stop",
243
+ label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STOP__LABEL",
244
+ type: "textArray",
245
+ description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STOP__DESCRIPTION",
246
+ condition: {
247
+ key: "useStop",
248
+ value: true,
249
+ },
250
+ },
251
+ {
252
+ key: "timeout",
253
+ label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TIMEOUT__LABEL",
254
+ defaultValue: 5000,
255
+ type: "number",
256
+ description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TIMEOUT__DESCRIPTION",
257
+ },
258
+ {
259
+ key: "outputFallback",
260
+ type: "cognigyText",
261
+ label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__OUTPUT_FALLBACK__LABEL",
262
+ description: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__OUTPUT_FALLBACK__DESCRIPTION",
263
+ defaultValue: constants_1.OUTPUT_FALLBACK_DEFAULT,
264
+ },
265
+ {
266
+ key: "errorHandling",
267
+ type: "select",
268
+ label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__HANDLE_SERVICE_ERROR__LABEL",
269
+ description: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__HANDLE_SERVICE_ERROR__DESCRIPTION",
270
+ defaultValue: "stop",
271
+ params: {
272
+ options: [
273
+ {
274
+ label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__HANDLE_SERVICE_ERROR__OPTIONS__STOP__LABEL",
275
+ value: "stop",
276
+ },
277
+ {
278
+ label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__HANDLE_SERVICE_ERROR__OPTIONS__CONTINUE__LABEL",
279
+ value: "continue",
280
+ },
281
+ {
282
+ label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__HANDLE_SERVICE_ERROR__OPTIONS__GOTO__LABEL",
283
+ value: "goto",
284
+ },
285
+ ],
286
+ },
287
+ },
288
+ {
289
+ key: "timeoutMessage",
290
+ label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__ERROR_MESSAGE__LABEL",
291
+ type: "cognigyText",
292
+ description: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__ERROR_MESSAGE__DESCRIPTION",
293
+ defaultValue: constants_1.TIMEOUT_MESSAGE_DEFAULT,
294
+ condition: {
295
+ key: "errorHandling",
296
+ value: "continue",
297
+ },
298
+ },
299
+ {
300
+ key: "errorHandlingGotoTarget",
301
+ type: "flowNode",
302
+ label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__ERROR__GOTO_NODE__LABEL",
303
+ condition: {
304
+ key: "errorHandling",
305
+ value: "goto",
306
+ },
307
+ },
308
+ {
309
+ key: "enableCopyToClipboard",
310
+ label: "UI__NODE_EDITOR__TRANSCRIPT_ASSIST__ENABLE_COPY_TO_CLIPBOARD__LABEL",
311
+ type: "toggle",
312
+ defaultValue: false,
313
+ },
314
+ {
315
+ key: "fontSize",
316
+ type: "select",
317
+ label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE",
318
+ description: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE__INFO",
319
+ defaultValue: "text-sm",
320
+ params: {
321
+ options: getFontSizeFieldOptions_1.getFontSizeFieldOptions,
322
+ },
323
+ },
324
+ {
325
+ key: "actionFontSize",
326
+ type: "select",
327
+ label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__NEXT_ASSIST__ACTION__FONT_SIZE",
328
+ description: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__NEXT_ASSIST__ACTION__FONT_SIZE__DESCRIPTION",
329
+ defaultValue: "text-sm",
330
+ params: {
331
+ options: getFontSizeFieldOptions_1.getFontSizeFieldOptions,
332
+ },
333
+ },
334
+ ],
335
+ sections: [
336
+ {
337
+ key: "searchSettings",
338
+ label: "Search Settings",
339
+ defaultCollapsed: true,
340
+ fields: [
341
+ "followUpDetection",
342
+ "followUpDetectionSteps",
343
+ "topK",
344
+ "searchStoreLocation",
345
+ "searchStoreWarning",
346
+ "searchStoreLocationInputKey",
347
+ "searchStoreLocationContextKey",
348
+ ],
349
+ condition: {
350
+ key: "type",
351
+ value: "knowledgeAssist",
352
+ },
353
+ },
354
+ {
355
+ key: "extractSettings",
356
+ label: "Extract Settings",
357
+ defaultCollapsed: true,
358
+ fields: [
359
+ "prompt",
360
+ "model",
361
+ "temperature",
362
+ "topP",
363
+ "maxTokens",
364
+ "presencePenalty",
365
+ "frequencyPenalty",
366
+ "useStop",
367
+ "stop",
368
+ "timeout",
369
+ ],
370
+ condition: {
371
+ or: [
372
+ {
373
+ key: "mode",
374
+ value: "seo",
375
+ },
376
+ {
377
+ key: "mode",
378
+ value: "se",
379
+ },
380
+ ],
381
+ },
382
+ },
383
+ {
384
+ key: "outputSettings",
385
+ label: "Output Settings",
386
+ defaultCollapsed: true,
387
+ fields: [
388
+ "outputMode",
389
+ "streamDescription",
390
+ "streamStopTokens",
391
+ "outputFallback",
392
+ ],
393
+ condition: {
394
+ key: "mode",
395
+ value: "seo",
396
+ },
397
+ },
398
+ {
399
+ key: "uiPreferences",
400
+ label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__TITLE",
401
+ defaultCollapsed: true,
402
+ fields: ["fontSize", "actionFontSize", "enableCopyToClipboard"],
403
+ },
404
+ {
405
+ key: "errorHandling",
406
+ label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__SECTIONS__ERROR_HANDLING__LABEL",
407
+ defaultCollapsed: true,
408
+ fields: ["errorHandling", "timeoutMessage", "errorHandlingGotoTarget"],
409
+ condition: {
410
+ key: "type",
411
+ value: "knowledgeAssist",
40
412
  },
41
413
  },
42
414
  ],
43
- sections: [],
44
415
  form: [
45
416
  { type: "field", key: "tileId" },
46
417
  { type: "field", key: "text" },
418
+ { type: "field", key: "type" },
419
+ { type: "field", key: "knowledgeStoreId" },
420
+ {
421
+ type: "section",
422
+ key: "searchSettings",
423
+ },
424
+ { type: "section", key: "extractSettings" },
425
+ { type: "section", key: "outputSettings" },
426
+ { type: "section", key: "errorHandling" },
427
+ { type: "section", key: "uiPreferences" },
47
428
  ].filter((element) => !!element),
48
429
  function: async (params) => {
49
- const { cognigy, config } = params;
50
- const { api } = cognigy;
51
- const text = config["text"];
52
- if (!config.text) {
53
- api.log("error", "Please provide a text in the text field");
430
+ var _a, _b, _c;
431
+ const { cognigy, config, nodeId } = params;
432
+ const { api, input } = cognigy;
433
+ if (!api || !api.log) {
434
+ throw new Error("Unable to retrieve executionApi");
435
+ }
436
+ const { searchStoreLocation = "default", searchStoreLocationContextKey = "knowledgeSearch", searchStoreLocationInputKey = "knowledgeSearch", temperature = 0.7, maxTokens = 1000, topP, presencePenalty = 0, frequencyPenalty = 0, useStop = false, stop = "", contextKey, inputKey = "knowledgeSearch", timeout = 5000, timeoutMessage = constants_1.TIMEOUT_MESSAGE_DEFAULT, outputFallback = constants_1.OUTPUT_FALLBACK_DEFAULT, outputMode, errorHandling = "stop", errorHandlingGotoTarget = "", streamStopTokens, followUpDetection = "transcript", followUpDetectionSteps = 2, type, prompt = constants_2.DEFAULT_PROMPT, } = config;
437
+ const { traceId } = input;
438
+ let nextActionText = config.text;
439
+ let lastCustomerInput = input.text;
440
+ if (!lastCustomerInput) {
441
+ api.log("info", "No input text found.");
54
442
  return;
55
443
  }
444
+ // timeout message name not changed because of legacy compatibility
445
+ const errorMessage = timeoutMessage;
56
446
  try {
447
+ if (type === "knowledgeAssist") {
448
+ (0, configValidator_helper_1.validateKnowledgeSearchConfig)({
449
+ knowledgeStoreId: config.knowledgeStoreId,
450
+ topK: config.topK,
451
+ searchStoreLocation,
452
+ searchStoreLocationContextKey,
453
+ searchStoreLocationInputKey,
454
+ });
455
+ const errorHandler = (0, errorHandler_helper_1.handleServiceError)({
456
+ api,
457
+ cognigy,
458
+ nodeId,
459
+ traceId,
460
+ searchStoreLocation,
461
+ searchStoreLocationContextKey,
462
+ searchStoreLocationInputKey,
463
+ errorHandling,
464
+ errorMessage,
465
+ errorHandlingGotoTarget,
466
+ });
467
+ // If is there is transcript to give context to the follow-up detection, use it to rewrite the input
468
+ if (followUpDetection === "transcript") {
469
+ const promptResponse = await (0, followUpDetection_helper_1.detectFollowUp)({
470
+ value: lastCustomerInput,
471
+ followUpDetectionSteps,
472
+ cognigy,
473
+ });
474
+ if (promptResponse) {
475
+ // Override the lastCustomerInput with the detected follow-up which is the rephrased version of the lastCustomerInput
476
+ lastCustomerInput = promptResponse;
477
+ }
478
+ }
479
+ const knowledgeSearchResponseData = await (0, knowledgeSearch_helper_1.performKnowledgeSearch)({
480
+ api,
481
+ config: {
482
+ language: input.language,
483
+ traceId,
484
+ topK: config.topK,
485
+ searchStoreLocation,
486
+ searchStoreLocationContextKey,
487
+ searchStoreLocationInputKey,
488
+ knowledgeStoreId: config.knowledgeStoreId,
489
+ },
490
+ query: lastCustomerInput,
491
+ input,
492
+ errorHandler,
493
+ });
494
+ const answer = await (0, answerExtraction_helper_1.extractAnswer)({
495
+ api,
496
+ config: {
497
+ contextKey,
498
+ frequencyPenalty,
499
+ inputKey,
500
+ maxTokens,
501
+ outputMode,
502
+ presencePenalty,
503
+ searchStoreLocation,
504
+ stop,
505
+ streamStopTokens,
506
+ temperature,
507
+ timeout,
508
+ topP,
509
+ useStop,
510
+ prompt,
511
+ },
512
+ knowledgeSearchResponseData,
513
+ userInput: lastCustomerInput,
514
+ input,
515
+ errorHandler,
516
+ });
517
+ nextActionText = answer || outputFallback;
518
+ }
519
+ else {
520
+ if (!nextActionText) {
521
+ (_a = api.log) === null || _a === void 0 ? void 0 : _a.call(api, "error", "Please provide a text in the text field");
522
+ return;
523
+ }
524
+ }
57
525
  const data = {
58
- html: (0, nextActionWidgetTemplate_1.default)(text),
526
+ html: (0, nextActionWidgetTemplate_1.default)({
527
+ text: nextActionText,
528
+ postMessageUrl: process.env.AGENT_ASSIST_WORKSPACE_FRONTEND_URL_WITH_PROTOCOL ||
529
+ "",
530
+ enableCopyToClipboard: config.enableCopyToClipboard,
531
+ fontSize: config.fontSize,
532
+ actionFontSize: config.actionFontSize,
533
+ }),
59
534
  };
60
535
  cognigy.api.sendTileUpdateToAgentAssistWorkspace(Object.assign(Object.assign({}, params), { tile: {
61
536
  id: config.tileId,
62
537
  type: "html",
63
- data, // the generated HTML
538
+ data,
64
539
  } }));
65
540
  }
66
541
  catch (error) {
67
542
  if (error instanceof SyntaxError) {
68
- api.log("error", "Please provide a valid JSON in the JSON Data field");
543
+ (_b = api.log) === null || _b === void 0 ? void 0 : _b.call(api, "error", "Please provide a valid JSON in the JSON Data field");
69
544
  }
70
545
  else {
71
- api.log("error", error);
546
+ (_c = api.log) === null || _c === void 0 ? void 0 : _c.call(api, "error", error);
72
547
  }
73
548
  }
74
549
  return;