@cognigy/rest-api-client 0.13.2 → 0.15.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 (284) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/build/RestAPIClient.js +4 -0
  3. package/build/apigroups/AdministrationAPIGroup_2_1.js +13 -0
  4. package/build/apigroups/ResourcesAPIGroup_2_0.js +83 -11
  5. package/build/apigroups/index.js +3 -1
  6. package/build/connector/AxiosAdapter.js +1 -1
  7. package/build/shared/api/eightByEight/eightByEightInterfaces.js +3 -0
  8. package/build/shared/charts/descriptors/agentAssist/index.js +10 -0
  9. package/build/shared/charts/descriptors/agentAssist/setAdaptiveCardTile.js +74 -0
  10. package/build/shared/charts/descriptors/agentAssist/setHtmlTile.js +98 -0
  11. package/build/shared/charts/descriptors/agentAssist/setIframeTile.js +86 -0
  12. package/build/shared/charts/descriptors/analytics/activateProfile.js +1 -1
  13. package/build/shared/charts/descriptors/analytics/blindMode.js +5 -5
  14. package/build/shared/charts/descriptors/analytics/completeGoal.js +2 -2
  15. package/build/shared/charts/descriptors/analytics/deactivateProfile.js +2 -2
  16. package/build/shared/charts/descriptors/analytics/deleteProfile.js +1 -1
  17. package/build/shared/charts/descriptors/analytics/mergeProfile.js +2 -2
  18. package/build/shared/charts/descriptors/analytics/overwriteAnalytics.js +34 -27
  19. package/build/shared/charts/descriptors/analytics/requestRating.js +5 -5
  20. package/build/shared/charts/descriptors/analytics/setRating.js +4 -4
  21. package/build/shared/charts/descriptors/analytics/updateProfile.js +3 -3
  22. package/build/shared/charts/descriptors/apps/getAppSessionPin.js +7 -14
  23. package/build/shared/charts/descriptors/apps/initAppSession.js +99 -87
  24. package/build/shared/charts/descriptors/apps/setAdaptiveCardAppState.js +101 -19
  25. package/build/shared/charts/descriptors/apps/setAppState.js +7 -7
  26. package/build/shared/charts/descriptors/apps/setHtmlAppState.js +154 -42
  27. package/build/shared/charts/descriptors/apps/utils/buildAppUrl.js +2 -6
  28. package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/anthropicProviderConnection.js +11 -0
  29. package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/azureOpenAIProviderConnection.js +17 -0
  30. package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/azureOpenAIProviderConnectionV2.js +11 -0
  31. package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/googleVertexAIProviderConnection.js +16 -0
  32. package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/index.js +31 -0
  33. package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/openAIProviderConnection.js +11 -0
  34. package/build/shared/charts/descriptors/connectionNodes/internalStorageProviders/amazonStorageProviderConnection.js +1 -1
  35. package/build/shared/charts/descriptors/connectionNodes/internalStorageProviders/azureBlobStorageProviderConnection.js +1 -1
  36. package/build/shared/charts/descriptors/connectionNodes/internalStorageProviders/googleCloudStorageProviderConnection.js +1 -1
  37. package/build/shared/charts/descriptors/connectionNodes/mongoDB/aggregate.js +13 -13
  38. package/build/shared/charts/descriptors/connectionNodes/mongoDB/find.js +18 -18
  39. package/build/shared/charts/descriptors/connectionNodes/mongoDB/findOne.js +17 -17
  40. package/build/shared/charts/descriptors/connectionNodes/mongoDB/insert.js +13 -13
  41. package/build/shared/charts/descriptors/connectionNodes/mongoDB/mongoDBConnection.js +1 -1
  42. package/build/shared/charts/descriptors/connectionNodes/mongoDB/remove.js +13 -13
  43. package/build/shared/charts/descriptors/connectionNodes/mongoDB/updateMany.js +15 -15
  44. package/build/shared/charts/descriptors/connectionNodes/mongoDB/updateOne.js +15 -15
  45. package/build/shared/charts/descriptors/connectionNodes/smtp/emailNotification.js +28 -28
  46. package/build/shared/charts/descriptors/connectionNodes/smtp/index.js +3 -1
  47. package/build/shared/charts/descriptors/connectionNodes/smtp/oAuth2Connection.js +18 -0
  48. package/build/shared/charts/descriptors/connectionNodes/smtp/sendEmail.js +102 -70
  49. package/build/shared/charts/descriptors/connectionNodes/smtp/serviceConnection.js +1 -1
  50. package/build/shared/charts/descriptors/connectionNodes/smtp/smtpConnection.js +1 -1
  51. package/build/shared/charts/descriptors/connectionNodes/speechProviders/awsSpeechProviderConnection.js +14 -0
  52. package/build/shared/charts/descriptors/connectionNodes/speechProviders/googleSpeechProviderConnection.js +16 -0
  53. package/build/shared/charts/descriptors/connectionNodes/speechProviders/index.js +23 -0
  54. package/build/shared/charts/descriptors/connectionNodes/speechProviders/microsoftSpeechProviderConnection.js +12 -0
  55. package/build/shared/charts/descriptors/connectionNodes/sql/runQuery.js +11 -11
  56. package/build/shared/charts/descriptors/connectionNodes/sql/runStoredProcedure.js +13 -13
  57. package/build/shared/charts/descriptors/connectionNodes/sql/runTransaction.js +11 -11
  58. package/build/shared/charts/descriptors/connectionNodes/sql/sqlConnection.js +1 -1
  59. package/build/shared/charts/descriptors/data/addToContext.js +7 -7
  60. package/build/shared/charts/descriptors/data/code.js +3 -3
  61. package/build/shared/charts/descriptors/data/copyDataToContext.js +1 -1
  62. package/build/shared/charts/descriptors/data/copySlotsToContext.js +9 -9
  63. package/build/shared/charts/descriptors/data/log.js +7 -7
  64. package/build/shared/charts/descriptors/data/removeFromContext.js +7 -7
  65. package/build/shared/charts/descriptors/data/resetContext.js +2 -2
  66. package/build/shared/charts/descriptors/index.js +35 -8
  67. package/build/shared/charts/descriptors/knowledgeSearch/index.js +6 -0
  68. package/build/shared/charts/descriptors/knowledgeSearch/knowledgeSearch.js +149 -0
  69. package/build/shared/charts/descriptors/liveAgent/assistInfo.js +25 -25
  70. package/build/shared/charts/descriptors/logic/disableSlotFillers.js +4 -4
  71. package/build/shared/charts/descriptors/logic/enableSlotFillers.js +3 -3
  72. package/build/shared/charts/descriptors/logic/executeFlow.js +9 -9
  73. package/build/shared/charts/descriptors/logic/goTo.js +17 -17
  74. package/build/shared/charts/descriptors/logic/if/if.js +3 -3
  75. package/build/shared/charts/descriptors/logic/interval/interval.js +3 -3
  76. package/build/shared/charts/descriptors/logic/once/once.js +1 -1
  77. package/build/shared/charts/descriptors/logic/resetState.js +1 -1
  78. package/build/shared/charts/descriptors/logic/setState.js +4 -4
  79. package/build/shared/charts/descriptors/logic/setTranslation.js +15 -15
  80. package/build/shared/charts/descriptors/logic/sleep.js +2 -2
  81. package/build/shared/charts/descriptors/logic/stop.js +1 -1
  82. package/build/shared/charts/descriptors/logic/switch/case.js +1 -1
  83. package/build/shared/charts/descriptors/logic/switch/default.js +1 -1
  84. package/build/shared/charts/descriptors/logic/switch/switch.js +28 -19
  85. package/build/shared/charts/descriptors/logic/switchLocale.js +5 -5
  86. package/build/shared/charts/descriptors/logic/think.js +11 -11
  87. package/build/shared/charts/descriptors/logic/thinkV2.js +11 -11
  88. package/build/shared/charts/descriptors/logic/wait.js +1 -1
  89. package/build/shared/charts/descriptors/message/checkChannelChange/checkChannelChange.js +4 -4
  90. package/build/shared/charts/descriptors/message/datePicker.js +1 -1
  91. package/build/shared/charts/descriptors/message/question/optionalQuestion.js +87 -39
  92. package/build/shared/charts/descriptors/message/question/question.js +751 -204
  93. package/build/shared/charts/descriptors/message/question/utils/cleanTextUtils.js +191 -0
  94. package/build/shared/charts/descriptors/message/question/utils/datepickerUtils.js +40 -40
  95. package/build/shared/charts/descriptors/message/question/utils/evaluateQuestionAnswer.js +37 -27
  96. package/build/shared/charts/descriptors/message/say.js +70 -6
  97. package/build/shared/charts/descriptors/message/sendImage.js +1 -1
  98. package/build/shared/charts/descriptors/message/sendText.js +2 -2
  99. package/build/shared/charts/descriptors/microsoft/getToken.js +1 -1
  100. package/build/shared/charts/descriptors/microsoft/invalidateToken.js +1 -1
  101. package/build/shared/charts/descriptors/microsoft/tokenStatus/index.js +1 -1
  102. package/build/shared/charts/descriptors/nlu/addLexiconKeyphrase.js +5 -5
  103. package/build/shared/charts/descriptors/nlu/cleanText.js +103 -0
  104. package/build/shared/charts/descriptors/nlu/executeCognigyNLU.js +15 -15
  105. package/build/shared/charts/descriptors/nlu/extractAnswer.js +11 -11
  106. package/build/shared/charts/descriptors/nlu/fuzzySearch.js +33 -33
  107. package/build/shared/charts/descriptors/nlu/generativeSlotFiller/generativeSlotFiller.js +270 -0
  108. package/build/shared/charts/descriptors/nlu/generativeSlotFiller/generativeSlotFillerFallback.js +27 -0
  109. package/build/shared/charts/descriptors/nlu/generativeSlotFiller/generativeSlotFillerSuccess.js +27 -0
  110. package/build/shared/charts/descriptors/nlu/generativeSlotFiller/prompt.js +76 -0
  111. package/build/shared/charts/descriptors/nlu/index.js +9 -1
  112. package/build/shared/charts/descriptors/nlu/matchPattern.js +16 -16
  113. package/build/shared/charts/descriptors/nlu/regexSlotFiller.js +5 -5
  114. package/build/shared/charts/descriptors/placeholder.js +3 -3
  115. package/build/shared/charts/descriptors/service/GPTConversation.js +678 -0
  116. package/build/shared/charts/descriptors/service/GPTPrompt.js +258 -0
  117. package/build/shared/charts/descriptors/service/checkAgentAvailability.js +34 -33
  118. package/build/shared/charts/descriptors/service/closeHandover.js +34 -0
  119. package/build/shared/charts/descriptors/service/conversationSummary.js +148 -0
  120. package/build/shared/charts/descriptors/service/handover.js +18 -17
  121. package/build/shared/charts/descriptors/service/handoverInactivityTimer.js +37 -0
  122. package/build/shared/charts/descriptors/service/handoverV2.js +170 -41
  123. package/build/shared/charts/descriptors/service/httpRequest.js +52 -52
  124. package/build/shared/charts/descriptors/service/index.js +11 -1
  125. package/build/shared/charts/descriptors/service/triggerFunction/triggerFunction.js +3 -3
  126. package/build/shared/charts/descriptors/voice/index.js +5 -1
  127. package/build/shared/charts/descriptors/voice/mappers/base.mapper.js +83 -0
  128. package/build/shared/charts/descriptors/voice/mappers/hangup.mapper.js +6 -9
  129. package/build/shared/charts/descriptors/voice/mappers/muteSpeechInput.mapper.js +52 -0
  130. package/build/shared/charts/descriptors/voice/mappers/play.mapper.js +19 -19
  131. package/build/shared/charts/descriptors/voice/mappers/record.mapper.js +96 -0
  132. package/build/shared/charts/descriptors/voice/mappers/sendMetadata.mapper.js +53 -0
  133. package/build/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +157 -62
  134. package/build/shared/charts/descriptors/voice/mappers/transfer.mapper.js +126 -35
  135. package/build/shared/charts/descriptors/voice/nodes/bargeIn.js +14 -20
  136. package/build/shared/charts/descriptors/voice/nodes/continuousAsr.js +7 -7
  137. package/build/shared/charts/descriptors/voice/nodes/dtmf.js +10 -18
  138. package/build/shared/charts/descriptors/voice/nodes/hangup.js +2 -2
  139. package/build/shared/charts/descriptors/voice/nodes/muteSpeechInput.js +52 -0
  140. package/build/shared/charts/descriptors/voice/nodes/noUserInput.js +15 -14
  141. package/build/shared/charts/descriptors/voice/nodes/play.js +20 -14
  142. package/build/shared/charts/descriptors/voice/nodes/sendMetadata.js +51 -0
  143. package/build/shared/charts/descriptors/voice/nodes/sessionSpeechParameters.js +163 -17
  144. package/build/shared/charts/descriptors/voice/nodes/transfer.js +12 -12
  145. package/build/shared/charts/descriptors/voice/utils/helper.js +11 -1
  146. package/build/shared/charts/descriptors/voicegateway/nodes/agentAssist.js +12 -12
  147. package/build/shared/charts/descriptors/voicegateway/nodes/callRecording.js +64 -62
  148. package/build/shared/charts/descriptors/voicegateway/nodes/handover.js +14 -14
  149. package/build/shared/charts/descriptors/voicegateway/nodes/hangup.js +2 -2
  150. package/build/shared/charts/descriptors/voicegateway/nodes/playURL.js +18 -15
  151. package/build/shared/charts/descriptors/voicegateway/nodes/sendMessage.js +41 -41
  152. package/build/shared/charts/descriptors/voicegateway/nodes/sendMetaData.js +15 -19
  153. package/build/shared/charts/descriptors/voicegateway/nodes/setSessionParams.js +3 -3
  154. package/build/shared/charts/descriptors/voicegateway/utils/paramUtils.js +117 -97
  155. package/build/shared/charts/descriptors/voicegateway2/index.js +5 -1
  156. package/build/shared/charts/descriptors/voicegateway2/nodes/dtmf.js +5 -5
  157. package/build/shared/charts/descriptors/voicegateway2/nodes/hangup.js +3 -4
  158. package/build/shared/charts/descriptors/voicegateway2/nodes/muteSpeechInput.js +49 -0
  159. package/build/shared/charts/descriptors/voicegateway2/nodes/play.js +40 -19
  160. package/build/shared/charts/descriptors/voicegateway2/nodes/record.js +108 -0
  161. package/build/shared/charts/descriptors/voicegateway2/nodes/refer.js +12 -13
  162. package/build/shared/charts/descriptors/voicegateway2/nodes/sendMetadata.js +14 -29
  163. package/build/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +383 -82
  164. package/build/shared/charts/descriptors/voicegateway2/nodes/transfer.js +214 -18
  165. package/build/shared/charts/descriptors/voicegateway2/utils/helper.js +21 -14
  166. package/build/shared/charts/descriptors/voicegateway2/utils/strip-nulls.js +8 -1
  167. package/build/shared/charts/helpers/generativeAI/getRephraseWithAIFields.js +100 -0
  168. package/build/shared/charts/helpers/generativeAI/rephraseSentenceWithAi.js +44 -0
  169. package/build/shared/constants.js +15 -1
  170. package/build/shared/errors/ErrorCode.js +1 -0
  171. package/build/shared/errors/TooManyRequestsError.js +59 -0
  172. package/build/shared/errors/baseError.js +6 -2
  173. package/build/shared/errors/codes.js +2 -1
  174. package/build/shared/errors/index.js +3 -1
  175. package/build/shared/helper/BaseContext.js +56 -3
  176. package/build/shared/helper/nlu/dicts/dicts.js +691 -0
  177. package/build/shared/helper/nlu/textCleaner.js +391 -0
  178. package/build/shared/interfaces/IApiKey.js +2 -7
  179. package/build/shared/interfaces/IOrganisation.js +2 -7
  180. package/build/shared/interfaces/IProfileSchema.js +1 -7
  181. package/build/shared/interfaces/agentAssist/ISendTileUpdateParams.js +3 -0
  182. package/build/shared/interfaces/agentAssist/ISendTileUpdateReferenceParams.js +3 -0
  183. package/build/shared/interfaces/agentAssist/index.js +3 -0
  184. package/build/shared/interfaces/amqpInterface.js +7 -1
  185. package/build/shared/interfaces/analytics/IAnalyticsDataGoals.js +3 -0
  186. package/build/shared/interfaces/endpointInterface.js +1 -0
  187. package/build/shared/interfaces/filemanager/IRuntimeFile.js +30 -0
  188. package/build/shared/interfaces/filemanager/index.js +1 -0
  189. package/build/shared/interfaces/generativeAI/IGenerativeAIModels.js +72 -0
  190. package/build/shared/interfaces/generativeAI/IGenerativeAIPrompts.js +3 -0
  191. package/build/shared/interfaces/generativeAI/IRunGenerativeAIPromptOptions.js +3 -0
  192. package/build/shared/interfaces/handover.js +52 -4
  193. package/build/shared/interfaces/knowledgesearch/search.js +3 -0
  194. package/build/shared/interfaces/messageAPI/ai.js +2 -1
  195. package/build/shared/interfaces/messageAPI/endpoints.js +93 -2
  196. package/build/shared/interfaces/messageAPI/handover.js +10 -1
  197. package/build/shared/interfaces/resources/IAgentAssistConfig.js +26 -20
  198. package/build/shared/interfaces/resources/IAuditEvent.js +8 -1
  199. package/build/shared/interfaces/resources/IChart.js +1 -10
  200. package/build/shared/interfaces/resources/IConnection.js +7 -1
  201. package/build/shared/interfaces/resources/IConnectionSchema.js +2 -1
  202. package/build/shared/interfaces/resources/IEndpoint.js +2 -14
  203. package/build/shared/interfaces/resources/IExtension.js +2 -1
  204. package/build/shared/interfaces/resources/IFlow.js +17 -11
  205. package/build/shared/interfaces/resources/IFunction.js +1 -7
  206. package/build/shared/interfaces/resources/IGenerateNodeOutput.js +3 -0
  207. package/build/shared/interfaces/resources/ILargeLanguageModel.js +54 -0
  208. package/build/shared/interfaces/resources/ILexicon.js +16 -8
  209. package/build/shared/interfaces/resources/INodeDescriptorSet.js +32 -29
  210. package/build/shared/interfaces/resources/IPackage.js +1 -7
  211. package/build/shared/interfaces/resources/IPlaybookRun.js +2 -1
  212. package/build/shared/interfaces/resources/IProject.js +1 -7
  213. package/build/shared/interfaces/resources/ISnapshot.js +2 -14
  214. package/build/shared/interfaces/resources/TNLUConnectorType.js +2 -1
  215. package/build/shared/interfaces/resources/TResourceType.js +16 -5
  216. package/build/shared/interfaces/resources/chart/IChartExecutable.js +1 -7
  217. package/build/shared/interfaces/resources/intent/IIntent.js +5 -2
  218. package/build/shared/interfaces/resources/intent/IIntentRelation.js +3 -1
  219. package/build/shared/interfaces/resources/knowledgeStore/IKnowledgeChunk.js +32 -0
  220. package/build/shared/interfaces/resources/knowledgeStore/IKnowledgeSource.js +31 -0
  221. package/build/shared/interfaces/resources/knowledgeStore/IKnowledgeStore.js +26 -0
  222. package/build/shared/interfaces/resources/settings/IAgentSettings.js +8 -46
  223. package/build/shared/interfaces/resources/settings/IAudioPreviewSettings.js +36 -0
  224. package/build/shared/interfaces/resources/settings/IGenerativeAISettings.js +69 -0
  225. package/build/shared/interfaces/resources/settings/IGenerativeAIUseCase.js +3 -0
  226. package/build/shared/interfaces/resources/settings/ISharedSettings.js +2 -2
  227. package/build/shared/interfaces/resources/settings/index.js +6 -1
  228. package/build/shared/interfaces/restAPI/administration/user/v2.1/IApiKeyIndexItem_2_1.js +3 -0
  229. package/build/shared/interfaces/restAPI/administration/user/v2.1/IApiKey_2_1.js +3 -0
  230. package/build/shared/interfaces/restAPI/administration/user/v2.1/ICreateApiKeyRest_2_1.js +3 -0
  231. package/build/shared/interfaces/restAPI/administration/user/v2.1/IIndexApiKeysMeRest_2_1.js +3 -0
  232. package/build/shared/interfaces/restAPI/administration/user/v2.1/index.js +3 -0
  233. package/build/shared/interfaces/restAPI/insights/reports/IGenerateReportRest_2_0.js +0 -2
  234. package/build/shared/interfaces/restAPI/resources/agentAssist/v2.0/IReadAgentAssistSessionDataRest_2_0.js +3 -0
  235. package/build/shared/interfaces/restAPI/resources/chart/v2.0/IGenerateNodeOutputRest_2_0.js +3 -0
  236. package/build/shared/interfaces/restAPI/resources/flow/v2.0/sentence/IGenerateSentencesRest_2_0.js +3 -0
  237. package/build/shared/interfaces/restAPI/resources/knowledgeSearchIndex/v2.0/ICreateKnowledgeSearchIndexRest_2_0.js +3 -0
  238. package/build/shared/interfaces/restAPI/resources/knowledgeSearchIndex/v2.0/IDeleteKnowledgeSearchIndexRest_2_0.js +3 -0
  239. package/build/shared/interfaces/restAPI/resources/knowledgeSearchIndex/v2.0/index.js +3 -0
  240. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/ICreateKnowledgeStoreRest_2_0.js +3 -0
  241. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IDeleteKnowledgeStoreRest_2_0.js +3 -0
  242. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IIndexKnowledgeStoresRest_2_0.js +3 -0
  243. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IIngestKnowledgeStoreRest_2_0.js +3 -0
  244. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IKnowledgeStore_2_0.js +3 -0
  245. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IReadKnowledgeStoreRest_2_0.js +3 -0
  246. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IUpdateKnowledgeStoreRest_2_0.js +3 -0
  247. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/index.js +3 -0
  248. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/ICreateKnowledgeSourceRest_2_0.js +3 -0
  249. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/IDeleteKnowledgeSourceRest_2_0.js +3 -0
  250. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/IIndexKnowledgeSourcesRest_2_0.js +3 -0
  251. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/IKnowledgeSource_2_0.js +3 -0
  252. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/IReadKnowledgeSourceRest_2_0.js +3 -0
  253. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/IUpdateKnowledgeSourceRest_2_0.js +3 -0
  254. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/IUploadKnowledgeSourceFileRest_2_0.js +4 -0
  255. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/chunk/ICreateKnowledgeChunkRest_2_0.js +3 -0
  256. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/chunk/IDeleteKnowledgeChunkRest_2_0.js +3 -0
  257. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/chunk/IIndexKnowledgeChunksRest_2_0.js +3 -0
  258. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/chunk/IKnowledgeChunk_2_0.js +3 -0
  259. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/chunk/IReadKnowledgeChunkRest_2_0.js +3 -0
  260. package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/chunk/IUpdateKnowledgeChunkRest_2_0.js +3 -0
  261. package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/ICloneLargeLanguageModelRest_2_0.js +4 -0
  262. package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/ICreateLargeLanguageModelRest_2_0.js +3 -0
  263. package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/IDeleteLargeLanguageModelRest_2_0.js +3 -0
  264. package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/IIndexLargeLanguageModelsRest_2_0.js +3 -0
  265. package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/ILargeLanguageModelIndexItem_2_0.js +3 -0
  266. package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/ILargeLanguageModel_2_0.js +3 -0
  267. package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/IReadLargeLanguageModelRest_2_0.js +3 -0
  268. package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/ITestLargeLanguageModelRest_2_0.js +3 -0
  269. package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/IUpdateLargeLanguageModelRest_2_0.js +3 -0
  270. package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/index.js +3 -0
  271. package/build/shared/interfaces/restAPI/resources/nluconnector/v2.0/TNLUConnectorType_2_0.js +3 -1
  272. package/build/shared/interfaces/restAPI/resources/project/v2.0/settings/ISetupCognigyGenerativeAIRest_2_0.js +4 -0
  273. package/build/shared/interfaces/security/IACL.js +1 -7
  274. package/build/shared/interfaces/security/IIdentityProvider.js +1 -7
  275. package/build/shared/interfaces/security/IPermission.js +6 -2
  276. package/build/shared/interfaces/security/IRole.js +3 -1
  277. package/build/shared/interfaces/security/index.js +1 -2
  278. package/build/shared/interfaces/taskmanager/ITask.js +1 -0
  279. package/build/shared/interfaces/trainer/ITrainerRecord.js +1 -1
  280. package/build/shared/interfaces/user.js +1 -9
  281. package/package.json +1 -1
  282. package/types/index.d.ts +5297 -3423
  283. package/build/shared/charts/descriptors/voice/utils/constants.js +0 -8
  284. package/build/shared/charts/descriptors/voicegateway2/utils/constants.js +0 -7
@@ -9,7 +9,7 @@ const getFuzzySearchMaxObjectSizeInBytes = () => {
9
9
  exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
10
10
  type: "fuzzySearch",
11
11
  defaultLabel: "Fuzzy Search",
12
- summary: "Performs a fuzzy search on a given collection of source data",
12
+ summary: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__SUMMARY",
13
13
  preview: {
14
14
  key: "searchPattern",
15
15
  type: "text"
@@ -18,8 +18,8 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
18
18
  fields: [
19
19
  {
20
20
  key: "searchPattern",
21
- label: "Search Pattern",
22
- description: "The pattern to search for",
21
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__SEARCH_PATTERN__LABEL",
22
+ description: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__SEARCH_PATTERN__DESCRIPTION",
23
23
  type: "cognigyText",
24
24
  params: {
25
25
  required: true
@@ -27,8 +27,8 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
27
27
  },
28
28
  {
29
29
  key: "items",
30
- label: "Source Data",
31
- description: "An array of type string or object to search through..",
30
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__ITEMS__LABEL",
31
+ description: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__ITEMS__DESCRIPTION",
32
32
  type: "json",
33
33
  params: {
34
34
  required: true
@@ -42,31 +42,31 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
42
42
  },
43
43
  {
44
44
  key: "isCaseSensitive",
45
- label: "Is Case Sensitive",
45
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__IN_CASE_SENSITIVE__LABEL",
46
46
  defaultValue: false,
47
47
  type: "toggle",
48
- description: "Indicates whether comparisons should be case sensitive"
48
+ description: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__IN_CASE_SENSITIVE__DESCRIPTION"
49
49
  },
50
50
  {
51
51
  key: "includeScore",
52
- label: "Include Score",
52
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__INCLUDE_STORE__LABEL",
53
53
  defaultValue: true,
54
54
  type: "toggle",
55
- description: "Whether the score should be included in the result set. A score of 1 indicates a perfect match, while a score of 0 indicates a complete mismatch"
55
+ description: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__INCLUDE_STORE__DESCRIPTION"
56
56
  },
57
57
  {
58
58
  key: "includeMatches",
59
- label: "Include Matches",
59
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__INCLUDE_MATCHES__LABEL",
60
60
  defaultValue: false,
61
61
  type: "toggle",
62
- description: "Whether the matches should be included in the result set. When true, each record in the result set will include the indices of the matched characters."
62
+ description: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__INCLUDE_MATCHES__DESCRIPTION"
63
63
  },
64
64
  {
65
65
  key: "minMatchCharLength",
66
- label: "Minimum Characters",
66
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__MIN_MATCH_CHAR_LENGTH__LABEL",
67
67
  defaultValue: 1,
68
68
  type: "number",
69
- description: "Only the matches whose length exceeds this value will be returned.",
69
+ description: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__MIN_MATCH_CHAR_LENGTH__DESCRIPTION",
70
70
  params: {
71
71
  min: 1,
72
72
  max: 100
@@ -74,24 +74,24 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
74
74
  },
75
75
  {
76
76
  key: "shouldSort",
77
- label: "Should Sort",
77
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__SHOULD_SORT__LABEL",
78
78
  defaultValue: true,
79
79
  type: "toggle",
80
- description: "Whether to sort the result list, by score."
80
+ description: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__SHOULD_SORT__DESCRIPTION"
81
81
  },
82
82
  {
83
83
  key: "findAllMatches",
84
- label: "Find All Matches",
84
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__FIND_ALL_MATCHES__LABEL",
85
85
  defaultValue: true,
86
86
  type: "toggle",
87
- description: "When activated, the matching function will continue to the end of a search pattern even if a perfect match has already been located in the string."
87
+ description: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__FIND_ALL_MATCHES__DESCRIPTION"
88
88
  },
89
89
  {
90
90
  key: "location",
91
- label: "Location",
91
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__LOCATION__LABEL",
92
92
  defaultValue: 0,
93
93
  type: "number",
94
- description: "Determines approximately where in the text is the pattern expected to be found.",
94
+ description: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__LOCATION__DESCRIPTION",
95
95
  params: {
96
96
  min: 0,
97
97
  max: 100
@@ -99,10 +99,10 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
99
99
  },
100
100
  {
101
101
  key: "threshold",
102
- label: "Threshold",
102
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__THRESHOLD__LABEL",
103
103
  defaultValue: 0.1,
104
104
  type: "slider",
105
- description: "At what point does the match algorithm give up. A threshold of 1.0 requires a perfect match (of both letters and location), a threshold of 0.0 would match anything.",
105
+ description: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__THRESHOLD__DESCRIPTION",
106
106
  params: {
107
107
  min: 0,
108
108
  max: 1,
@@ -111,10 +111,10 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
111
111
  },
112
112
  {
113
113
  key: "distance",
114
- label: "Distance",
114
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__DISTANCE__LABEL",
115
115
  defaultValue: 100,
116
116
  type: "number",
117
- description: "Determines how close the match must be to the fuzzy location (specified by location).",
117
+ description: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__DISTANCE__DESCRIPTION",
118
118
  params: {
119
119
  min: 0,
120
120
  max: 1000
@@ -122,23 +122,23 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
122
122
  },
123
123
  {
124
124
  key: "ignoreLocation",
125
- label: "Ignore Location",
125
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__IGNORE_LOCATION__LABEL",
126
126
  defaultValue: true,
127
127
  type: "toggle",
128
- description: "When activated, search will ignore location and distance, so it won't matter where in the string the pattern appears."
128
+ description: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__IGNORE_LOCATION__DESCRIPTION"
129
129
  },
130
130
  {
131
131
  key: "storeLocation",
132
132
  type: "select",
133
- label: "Where to store the result",
133
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__STORE_LOCATION__LABEL",
134
134
  params: {
135
135
  options: [
136
136
  {
137
- label: "Input",
137
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__STORE_LOCATION__OPTIONS__INPUT__LABEL",
138
138
  value: "input"
139
139
  },
140
140
  {
141
- label: "Context",
141
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__STORE_LOCATION__OPTIONS__CONTEXT__LABEL",
142
142
  value: "context"
143
143
  }
144
144
  ],
@@ -149,7 +149,7 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
149
149
  {
150
150
  key: "inputKey",
151
151
  type: "cognigyText",
152
- label: "Input Key to store Result",
152
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__INPUT_KEY__LABEL",
153
153
  defaultValue: "search",
154
154
  condition: {
155
155
  key: "storeLocation",
@@ -159,7 +159,7 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
159
159
  {
160
160
  key: "contextKey",
161
161
  type: "cognigyText",
162
- label: "Context Key to store Result",
162
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__FIELDS__CONTEXT_KEY__LABEL",
163
163
  defaultValue: "search",
164
164
  condition: {
165
165
  key: "storeLocation",
@@ -170,7 +170,7 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
170
170
  sections: [
171
171
  {
172
172
  key: "storageOption",
173
- label: "Storage Option",
173
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__SECTIONS__STORAGE_OPTION__LABEL",
174
174
  defaultCollapsed: true,
175
175
  fields: [
176
176
  "storeLocation",
@@ -180,7 +180,7 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
180
180
  },
181
181
  {
182
182
  key: "basicOptions",
183
- label: "Basic Options",
183
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__SECTIONS__BASIC_OPTIONS__LABEL",
184
184
  defaultCollapsed: true,
185
185
  fields: [
186
186
  "isCaseSensitive",
@@ -193,7 +193,7 @@ exports.FUZZY_SEARCH = (0, createNodeDescriptor_1.createNodeDescriptor)({
193
193
  },
194
194
  {
195
195
  key: "fuzzyOptions",
196
- label: "Fuzzy Matching Options",
196
+ label: "UI__NODE_EDITOR__NLU__FUZZY_SEARCH__SECTIONS__FUZZY_OPTIONS__LABEL",
197
197
  defaultCollapsed: true,
198
198
  fields: [
199
199
  "location",
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterConversationEntries = exports.GENERATIVE_SLOT_FILLER = void 0;
4
+ /* Custom modules */
5
+ const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
6
+ const prompt_1 = require("./prompt");
7
+ const logger_1 = require("../../../../helper/logger");
8
+ const message_1 = require("../../message");
9
+ exports.GENERATIVE_SLOT_FILLER = (0, createNodeDescriptor_1.createNodeDescriptor)({
10
+ type: "generativeSlotFiller",
11
+ defaultLabel: "Generative Slot Filler",
12
+ summary: "UI__NODE_EDITOR__NLU__GENERATIVE_SLOT_FILLER__SUMMARY__DEFAULT",
13
+ dependencies: {
14
+ children: ["generativeSlotFillerFallback", "generativeSlotFillerSuccess"],
15
+ },
16
+ fields: [
17
+ {
18
+ key: "slotsConfig",
19
+ type: "json",
20
+ label: "UI__NODE_EDITOR__NLU__GENERATIVE_SLOT_FILLER__FIELDS__SLOT_CONFIG__DEFAULT_LABEL",
21
+ },
22
+ {
23
+ key: "amountOfLastUserInputs",
24
+ type: "slider",
25
+ label: "UI__NODE_EDITOR__NLU__GENERATIVE_SLOT_FILLER__FIELDS__AMOUNT_OF_LAST_USERS_INPUTS__LABEL",
26
+ params: {
27
+ min: 1,
28
+ max: 10,
29
+ step: 1,
30
+ },
31
+ defaultValue: 5
32
+ },
33
+ {
34
+ key: "maxQuestions",
35
+ label: "UI__NODE_EDITOR__NLU__GENERATIVE_MAX_QUESTIONS__DEFAULT_LABEL",
36
+ type: "slider",
37
+ defaultValue: 5,
38
+ params: {
39
+ min: 0,
40
+ max: 10,
41
+ step: 1
42
+ },
43
+ },
44
+ {
45
+ key: "temperature",
46
+ label: "UI__NODE_EDITOR__NLU__GENERATIVE_TEMPERATURE__DEFAULT_LABEL",
47
+ type: "slider",
48
+ description: "UI__NODE_EDITOR__NLU__GENERATIVE_SLIDER__DEFAULT_LABEL",
49
+ defaultValue: 1,
50
+ params: {
51
+ min: 0,
52
+ max: 1,
53
+ step: 0.1
54
+ },
55
+ },
56
+ {
57
+ key: "timeout",
58
+ label: "UI__NODE_EDITOR__NLU__GENERATIVE_TIMEOUT__DEFAULT_LABEL",
59
+ defaultValue: 6000,
60
+ type: "number",
61
+ description: "UI__NODE_EDITOR__NLU__GENERATIVE_TIMEOUT__DESCRIPTION",
62
+ },
63
+ {
64
+ key: "storeLocation",
65
+ type: "select",
66
+ label: "UI__NODE_EDITOR__NLU__GENERATIVE_STORE_LOCATION__DEFAULT_LABEL",
67
+ defaultValue: "context",
68
+ params: {
69
+ options: [
70
+ {
71
+ label: "UI__NODE_EDITOR__NLU__GENERATIVE_STORE_LOCATION__OPTIONS__INPUT__LABEL",
72
+ value: "input"
73
+ },
74
+ {
75
+ label: "UI__NODE_EDITOR__NLU__GENERATIVE_STORE_LOCATION__OPTIONS__CONTEXT__LABEL",
76
+ value: "context"
77
+ }
78
+ ],
79
+ required: true
80
+ },
81
+ },
82
+ {
83
+ key: "inputKey",
84
+ type: "cognigyText",
85
+ label: "UI__NODE_EDITOR__NLU__GENERATIVE_INPUT_KEY__DEFAULT_LABEL",
86
+ defaultValue: "generativeSlotFiller",
87
+ condition: {
88
+ key: "storeLocation",
89
+ value: "input",
90
+ }
91
+ },
92
+ {
93
+ key: "contextKey",
94
+ type: "cognigyText",
95
+ label: "UI__NODE_EDITOR__NLU__GENERATIVE_CONTEXT_KEY__DEFAULT_LABEL",
96
+ defaultValue: "generativeSlotFiller",
97
+ condition: {
98
+ key: "storeLocation",
99
+ value: "context",
100
+ }
101
+ },
102
+ ],
103
+ sections: [
104
+ {
105
+ key: "advanced",
106
+ label: "UI__NODE_EDITOR__NLU__GENERATIVE_SLOT_FILLER__SECTIONS__ADVANCED__DEFAULT_LABEL",
107
+ defaultCollapsed: true,
108
+ fields: [
109
+ "temperature",
110
+ "timeout",
111
+ ]
112
+ },
113
+ {
114
+ key: "storage",
115
+ label: "UI__NODE_EDITOR__NLU__GENERATIVE_SLOT_FILLER__SECTIONS__STORAGE__DEFAULT_LABEL",
116
+ defaultCollapsed: true,
117
+ fields: [
118
+ "storeLocation",
119
+ "inputKey",
120
+ "contextKey",
121
+ ]
122
+ }
123
+ ],
124
+ form: [
125
+ { type: "field", key: "slotsConfig" },
126
+ { type: "field", key: "amountOfLastUserInputs" },
127
+ { type: "field", key: "maxQuestions" },
128
+ { type: "section", key: "advanced" },
129
+ { type: "section", key: "storage" },
130
+ ],
131
+ appearance: {},
132
+ tags: ["nlu"],
133
+ function: async ({ cognigy, config, childConfigs, nodeId, organisationId }) => {
134
+ var _a;
135
+ const { api, lastConversationEntries } = cognigy;
136
+ const { slotsConfig, amountOfLastUserInputs, maxQuestions, temperature, storeLocation, contextKey, inputKey, timeout, } = config;
137
+ const fallBackChild = childConfigs.find(child => child.type === "generativeSlotFillerFallback");
138
+ if ((slotsConfig === null || slotsConfig === void 0 ? void 0 : slotsConfig.length) < 1 || (lastConversationEntries === null || lastConversationEntries === void 0 ? void 0 : lastConversationEntries.length) < 1) {
139
+ api.setNextNode(fallBackChild.id);
140
+ return;
141
+ }
142
+ try {
143
+ // the filled slots that were found in the previous execution
144
+ const filledSlots = storeLocation === "context" ? cognigy.context[contextKey] : cognigy.input[inputKey];
145
+ const slots = [...slotsConfig];
146
+ if (filledSlots) {
147
+ for (const filledSlot of Object.keys(filledSlots)) {
148
+ const slot = slots.find(slot => slot.tag === filledSlot);
149
+ slot.value = filledSlots[filledSlot];
150
+ // remove the validation, so that the slot is not validated again
151
+ delete slot.validation;
152
+ }
153
+ }
154
+ const questionCountKey = `generativeSlotFiller_${nodeId}_questionCount`;
155
+ const questionCount = api.getSystemContext(questionCountKey) || 0;
156
+ // for questions, we only use the last user input
157
+ const extractionEntries = questionCount > 0 ? (0, exports.filterConversationEntries)(lastConversationEntries, 1) : (0, exports.filterConversationEntries)(lastConversationEntries, amountOfLastUserInputs);
158
+ const extractEntitiesprompt = (0, prompt_1.createExtractionPrompt)(slots, extractionEntries);
159
+ const data = {
160
+ prompt: extractEntitiesprompt,
161
+ temperature,
162
+ timeoutInMs: timeout,
163
+ useCase: "slotExtraction",
164
+ };
165
+ // TODO: Create a new useCase for this feature and use it here instead
166
+ const response = await api.runGenerativeAIPrompt(data, "gptConversation");
167
+ const parsed = JSON.parse(response);
168
+ const slotsWithLexiconValidations = [];
169
+ slots.forEach(slot => {
170
+ if (parsed[slot.tag]) {
171
+ if (slot.validation && slot.validation.type === "slot") {
172
+ slotsWithLexiconValidations.push(slot);
173
+ }
174
+ slot.value = parsed[slot.tag];
175
+ }
176
+ });
177
+ for (const slot of slotsWithLexiconValidations) {
178
+ const nlu = await api.executeCognigyNLU(parsed[slot.tag], null, "TODO", {
179
+ parseIntents: false,
180
+ });
181
+ if ((_a = nlu === null || nlu === void 0 ? void 0 : nlu.slots) === null || _a === void 0 ? void 0 : _a[slot.validation.value]) {
182
+ slot.invalid = false;
183
+ }
184
+ else {
185
+ slot.invalid = true;
186
+ }
187
+ }
188
+ ;
189
+ let complete = true;
190
+ let allValid = true;
191
+ const missingSlots = [];
192
+ const invalidSlots = [];
193
+ const foundSlots = [];
194
+ for (const slot of slots) {
195
+ if (!slot.optional && !slot.value) {
196
+ missingSlots.push(slot);
197
+ }
198
+ else if (slot.invalid) {
199
+ invalidSlots.push(slot);
200
+ }
201
+ else if (slot.value && !slot.invalid) {
202
+ foundSlots.push(slot);
203
+ }
204
+ }
205
+ const slotResult = {};
206
+ foundSlots.forEach(slot => {
207
+ slotResult[slot.tag] = slot.value;
208
+ });
209
+ if (storeLocation === "context") {
210
+ cognigy.context[contextKey] = slotResult;
211
+ }
212
+ else {
213
+ cognigy.input[contextKey] = slotResult;
214
+ }
215
+ if (missingSlots.length > 0) {
216
+ complete = false;
217
+ }
218
+ if (invalidSlots.length > 0) {
219
+ allValid = false;
220
+ }
221
+ if (complete && allValid) {
222
+ const childNode = childConfigs.find(child => child.type === "generativeSlotFillerSuccess");
223
+ api.setNextNode(childNode.id);
224
+ return;
225
+ }
226
+ if (questionCount >= maxQuestions && !(complete && allValid)) {
227
+ const childNode = childConfigs.find(child => child.type === "generativeSlotFillerFallback");
228
+ api.setNextNode(childNode.id);
229
+ return;
230
+ }
231
+ if (questionCount < maxQuestions && !(complete && allValid)) {
232
+ api.setSystemContext(questionCountKey, questionCount + 1);
233
+ const prompt = allValid ? (0, prompt_1.createQuestionPrompt)(foundSlots, missingSlots, extractionEntries) : (0, prompt_1.createInvalidAnswerPrompt)(invalidSlots, extractionEntries);
234
+ const data = {
235
+ prompt,
236
+ temperature,
237
+ timeoutInMs: timeout,
238
+ useCase: "slotExtractionQuestion",
239
+ };
240
+ // TODO: Create a new useCase for this feature and use it here instead
241
+ const question = await api.runGenerativeAIPrompt(data, "gptConversation");
242
+ await message_1.SAY.function({ cognigy, childConfigs: [], nodeId, organisationId, config: { say: { type: "text", text: [question] } } });
243
+ api.stopExecution();
244
+ api.setNextNode(nodeId);
245
+ return;
246
+ }
247
+ }
248
+ catch (error) {
249
+ api.setNextNode(fallBackChild.id);
250
+ logger_1.default.log("error", { traceId: cognigy.input.traceId }, `Error in generativeSlotFiller: ${error.message}`);
251
+ }
252
+ }
253
+ });
254
+ const filterConversationEntries = (lastConversationEntries, amountOfLastUserInputs) => {
255
+ let addedUserInputsCount = 0;
256
+ let lastEntries = [];
257
+ // lastUserInputs is ordered newest -> oldest
258
+ for (const entry of lastConversationEntries) {
259
+ if (entry.source === "user" && addedUserInputsCount >= amountOfLastUserInputs) {
260
+ break;
261
+ }
262
+ lastEntries.push(entry);
263
+ if (entry.source === "user") {
264
+ addedUserInputsCount++;
265
+ }
266
+ }
267
+ return lastEntries;
268
+ };
269
+ exports.filterConversationEntries = filterConversationEntries;
270
+ //# sourceMappingURL=generativeSlotFiller.js.map
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GENERATIVE_SLOT_FILLER_FALLBACK = void 0;
4
+ /* Custom modules */
5
+ const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
6
+ exports.GENERATIVE_SLOT_FILLER_FALLBACK = (0, createNodeDescriptor_1.createNodeDescriptor)({
7
+ type: "generativeSlotFillerFallback",
8
+ parentType: "generativeSlotFillerFallback",
9
+ defaultLabel: "Fallback",
10
+ appearance: {
11
+ color: '#B3A7EA',
12
+ textColor: 'white',
13
+ contrastTextColor: 'black',
14
+ variant: 'mini'
15
+ },
16
+ constraints: {
17
+ editable: false,
18
+ deletable: false,
19
+ collapsable: true,
20
+ childFlowCreatable: true,
21
+ creatable: false,
22
+ movable: false,
23
+ placement: {},
24
+ },
25
+ tags: ["nlu"],
26
+ });
27
+ //# sourceMappingURL=generativeSlotFillerFallback.js.map
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GENERATIVE_SLOT_FILLER_SUCCESS = void 0;
4
+ /* Custom modules */
5
+ const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
6
+ exports.GENERATIVE_SLOT_FILLER_SUCCESS = (0, createNodeDescriptor_1.createNodeDescriptor)({
7
+ type: "generativeSlotFillerSuccess",
8
+ parentType: "generativeSlotFillerSuccess",
9
+ defaultLabel: "Success",
10
+ appearance: {
11
+ color: '#B3A7EA',
12
+ textColor: 'white',
13
+ contrastTextColor: 'black',
14
+ variant: 'mini'
15
+ },
16
+ constraints: {
17
+ editable: false,
18
+ deletable: false,
19
+ collapsable: true,
20
+ childFlowCreatable: true,
21
+ creatable: false,
22
+ movable: false,
23
+ placement: {},
24
+ },
25
+ tags: ["nlu"],
26
+ });
27
+ //# sourceMappingURL=generativeSlotFillerSuccess.js.map
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLastUserInputString = exports.createLastConverationString = exports.createInvalidAnswerPrompt = exports.createQuestionPrompt = exports.createExtractionPrompt = void 0;
4
+ const createExtractionPrompt = (slots, lastConversationEntries) => {
5
+ const userInput = lastConversationEntries.filter(entry => entry.source === "user").map(entry => "- " + entry.text).join("\n");
6
+ const conversation = (0, exports.createLastConverationString)(lastConversationEntries);
7
+ let slotDescriptions = "";
8
+ let foundSlotDescriptions = "";
9
+ for (const slot of slots) {
10
+ if (!slot.value || slot.invalid) {
11
+ slotDescriptions += `- KEY: ${slot.tag}, DESCRIPTION: ${slot.optional ? "(if explicitly mentioned) " : ""}${slot.description}\n`;
12
+ }
13
+ else {
14
+ foundSlotDescriptions += `- KEY: ${slot.tag}, DESCRIPTION: ${slot.description}, FOUND: ${slot.value}\n`;
15
+ }
16
+ }
17
+ const prompt = `A USER has interacted with a BOT, this is the conversation so far:
18
+ ${conversation}
19
+ ${foundSlotDescriptions.length > 0 ? `\nSo far, the BOT has found the following entities:\n${foundSlotDescriptions}` : ""}
20
+ Try to fill the following entities from the USER input, each entity has to match the given description field. If the value does not strictly match this description, leave the value empty:
21
+ ${slotDescriptions}
22
+ Return the extracted entities as a valid JSON object, where the keys are the entity tags and the values are the extracted values.`;
23
+ return prompt;
24
+ };
25
+ exports.createExtractionPrompt = createExtractionPrompt;
26
+ const createQuestionPrompt = (foundSlots, missingSlots, lastConversationEntries) => {
27
+ const conversation = (0, exports.createLastConverationString)(lastConversationEntries);
28
+ const missingSlotDescriptions = missingSlots.map(slot => `- KEY: ${slot.tag}, DESCRIPTION: ${slot.description}`).join("\n");
29
+ const foundSlotDescriptions = foundSlots.map(slot => `- KEY: ${slot.tag}, DESCRIPTION: ${slot.description}, FOUND: ${slot.value}`).join("\n");
30
+ const prompt = `A user has interacted with a bot, this is the conversation so far:
31
+ ${conversation}
32
+
33
+ ${foundSlots.length > 0 ? `So far, the BOT has found the following entities:\n${foundSlotDescriptions}` : ""}
34
+
35
+ The BOT wants to find the following entities:
36
+ ${missingSlotDescriptions}
37
+
38
+ The BOT asks the user to for this information, based on the conversation so far. The BOT outputs should not be repetitive.
39
+ BOT: `;
40
+ return prompt;
41
+ };
42
+ exports.createQuestionPrompt = createQuestionPrompt;
43
+ const createInvalidAnswerPrompt = (invalidSlots, lastConversationEntries) => {
44
+ const userInput = (0, exports.createLastConverationString)(lastConversationEntries);
45
+ const invalidSlotDescription = `- KEY: ${invalidSlots[0].tag}, DESCRIPTION: ${invalidSlots[0].description}, USER INPUT: ${invalidSlots[0].value}, INVALID BECAUSE: ${invalidSlots[0].validation.invalidReason}\n`;
46
+ const prompt = `A user has interacted with a bot, this is the conversation so far:
47
+ ${userInput}
48
+
49
+ The USER has provided the following entities, but the USER INPUT was INVALID BECAUSE:
50
+ ${invalidSlotDescription}
51
+ The BOT explains the answer why he can't use the answer and asks the USER again for this information, based on the conversation so far. The BOT does not give explicit alternatives.:
52
+ BOT: `;
53
+ invalidSlots[0].invalid = false;
54
+ invalidSlots[0].value = "";
55
+ return prompt;
56
+ };
57
+ exports.createInvalidAnswerPrompt = createInvalidAnswerPrompt;
58
+ /* returns recentConversation as a multiline string:
59
+ - BOT: Hello
60
+ - USER: Hi
61
+ */
62
+ const createLastConverationString = (lastConversationEntries) => {
63
+ const conversation = lastConversationEntries === null || lastConversationEntries === void 0 ? void 0 : lastConversationEntries.map(entry => "- " + (entry.source === "user" ? "USER: " : "BOT: ") + entry.text).reverse().join("\n");
64
+ return conversation || "";
65
+ };
66
+ exports.createLastConverationString = createLastConverationString;
67
+ /* returns recentUserInput as a multiline string:
68
+ - Hi
69
+ - I want to order...
70
+ */
71
+ const createLastUserInputString = (lastConversationEntries) => {
72
+ const userInput = lastConversationEntries.filter(entry => entry.source === "user").map(entry => "- " + entry.text).reverse().join("\n");
73
+ return userInput || "";
74
+ };
75
+ exports.createLastUserInputString = createLastUserInputString;
76
+ //# sourceMappingURL=prompt.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FUZZY_SEARCH = exports.MATCH_PATTERN = exports.REGEX_SLOT_FILLER = exports.EXTRACT_ANSWER = exports.EXECUTE_COGNIGY_NLU = exports.ADD_LEXICON_KEYPHRASE = void 0;
3
+ exports.CLEAN_TEXT = exports.GENERATIVE_SLOT_FILLER_FALLBACK = exports.GENERATIVE_SLOT_FILLER_SUCCESS = exports.GENERATIVE_SLOT_FILLER = exports.FUZZY_SEARCH = exports.MATCH_PATTERN = exports.REGEX_SLOT_FILLER = exports.EXTRACT_ANSWER = exports.EXECUTE_COGNIGY_NLU = exports.ADD_LEXICON_KEYPHRASE = void 0;
4
4
  var addLexiconKeyphrase_1 = require("./addLexiconKeyphrase");
5
5
  Object.defineProperty(exports, "ADD_LEXICON_KEYPHRASE", { enumerable: true, get: function () { return addLexiconKeyphrase_1.ADD_LEXICON_KEYPHRASE; } });
6
6
  var executeCognigyNLU_1 = require("./executeCognigyNLU");
@@ -13,4 +13,12 @@ var matchPattern_1 = require("./matchPattern");
13
13
  Object.defineProperty(exports, "MATCH_PATTERN", { enumerable: true, get: function () { return matchPattern_1.MATCH_PATTERN; } });
14
14
  var fuzzySearch_1 = require("./fuzzySearch");
15
15
  Object.defineProperty(exports, "FUZZY_SEARCH", { enumerable: true, get: function () { return fuzzySearch_1.FUZZY_SEARCH; } });
16
+ var generativeSlotFiller_1 = require("./generativeSlotFiller/generativeSlotFiller");
17
+ Object.defineProperty(exports, "GENERATIVE_SLOT_FILLER", { enumerable: true, get: function () { return generativeSlotFiller_1.GENERATIVE_SLOT_FILLER; } });
18
+ var generativeSlotFillerSuccess_1 = require("./generativeSlotFiller/generativeSlotFillerSuccess");
19
+ Object.defineProperty(exports, "GENERATIVE_SLOT_FILLER_SUCCESS", { enumerable: true, get: function () { return generativeSlotFillerSuccess_1.GENERATIVE_SLOT_FILLER_SUCCESS; } });
20
+ var generativeSlotFillerFallback_1 = require("./generativeSlotFiller/generativeSlotFillerFallback");
21
+ Object.defineProperty(exports, "GENERATIVE_SLOT_FILLER_FALLBACK", { enumerable: true, get: function () { return generativeSlotFillerFallback_1.GENERATIVE_SLOT_FILLER_FALLBACK; } });
22
+ var cleanText_1 = require("./cleanText");
23
+ Object.defineProperty(exports, "CLEAN_TEXT", { enumerable: true, get: function () { return cleanText_1.CLEAN_TEXT; } });
16
24
  //# sourceMappingURL=index.js.map