@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.
- package/CHANGELOG.md +5 -1
- package/build/RestAPIClient.js +4 -0
- package/build/apigroups/AdministrationAPIGroup_2_1.js +13 -0
- package/build/apigroups/ResourcesAPIGroup_2_0.js +83 -11
- package/build/apigroups/index.js +3 -1
- package/build/connector/AxiosAdapter.js +1 -1
- package/build/shared/api/eightByEight/eightByEightInterfaces.js +3 -0
- package/build/shared/charts/descriptors/agentAssist/index.js +10 -0
- package/build/shared/charts/descriptors/agentAssist/setAdaptiveCardTile.js +74 -0
- package/build/shared/charts/descriptors/agentAssist/setHtmlTile.js +98 -0
- package/build/shared/charts/descriptors/agentAssist/setIframeTile.js +86 -0
- package/build/shared/charts/descriptors/analytics/activateProfile.js +1 -1
- package/build/shared/charts/descriptors/analytics/blindMode.js +5 -5
- package/build/shared/charts/descriptors/analytics/completeGoal.js +2 -2
- package/build/shared/charts/descriptors/analytics/deactivateProfile.js +2 -2
- package/build/shared/charts/descriptors/analytics/deleteProfile.js +1 -1
- package/build/shared/charts/descriptors/analytics/mergeProfile.js +2 -2
- package/build/shared/charts/descriptors/analytics/overwriteAnalytics.js +34 -27
- package/build/shared/charts/descriptors/analytics/requestRating.js +5 -5
- package/build/shared/charts/descriptors/analytics/setRating.js +4 -4
- package/build/shared/charts/descriptors/analytics/updateProfile.js +3 -3
- package/build/shared/charts/descriptors/apps/getAppSessionPin.js +7 -14
- package/build/shared/charts/descriptors/apps/initAppSession.js +99 -87
- package/build/shared/charts/descriptors/apps/setAdaptiveCardAppState.js +101 -19
- package/build/shared/charts/descriptors/apps/setAppState.js +7 -7
- package/build/shared/charts/descriptors/apps/setHtmlAppState.js +154 -42
- package/build/shared/charts/descriptors/apps/utils/buildAppUrl.js +2 -6
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/anthropicProviderConnection.js +11 -0
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/azureOpenAIProviderConnection.js +17 -0
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/azureOpenAIProviderConnectionV2.js +11 -0
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/googleVertexAIProviderConnection.js +16 -0
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/index.js +31 -0
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/openAIProviderConnection.js +11 -0
- package/build/shared/charts/descriptors/connectionNodes/internalStorageProviders/amazonStorageProviderConnection.js +1 -1
- package/build/shared/charts/descriptors/connectionNodes/internalStorageProviders/azureBlobStorageProviderConnection.js +1 -1
- package/build/shared/charts/descriptors/connectionNodes/internalStorageProviders/googleCloudStorageProviderConnection.js +1 -1
- package/build/shared/charts/descriptors/connectionNodes/mongoDB/aggregate.js +13 -13
- package/build/shared/charts/descriptors/connectionNodes/mongoDB/find.js +18 -18
- package/build/shared/charts/descriptors/connectionNodes/mongoDB/findOne.js +17 -17
- package/build/shared/charts/descriptors/connectionNodes/mongoDB/insert.js +13 -13
- package/build/shared/charts/descriptors/connectionNodes/mongoDB/mongoDBConnection.js +1 -1
- package/build/shared/charts/descriptors/connectionNodes/mongoDB/remove.js +13 -13
- package/build/shared/charts/descriptors/connectionNodes/mongoDB/updateMany.js +15 -15
- package/build/shared/charts/descriptors/connectionNodes/mongoDB/updateOne.js +15 -15
- package/build/shared/charts/descriptors/connectionNodes/smtp/emailNotification.js +28 -28
- package/build/shared/charts/descriptors/connectionNodes/smtp/index.js +3 -1
- package/build/shared/charts/descriptors/connectionNodes/smtp/oAuth2Connection.js +18 -0
- package/build/shared/charts/descriptors/connectionNodes/smtp/sendEmail.js +102 -70
- package/build/shared/charts/descriptors/connectionNodes/smtp/serviceConnection.js +1 -1
- package/build/shared/charts/descriptors/connectionNodes/smtp/smtpConnection.js +1 -1
- package/build/shared/charts/descriptors/connectionNodes/speechProviders/awsSpeechProviderConnection.js +14 -0
- package/build/shared/charts/descriptors/connectionNodes/speechProviders/googleSpeechProviderConnection.js +16 -0
- package/build/shared/charts/descriptors/connectionNodes/speechProviders/index.js +23 -0
- package/build/shared/charts/descriptors/connectionNodes/speechProviders/microsoftSpeechProviderConnection.js +12 -0
- package/build/shared/charts/descriptors/connectionNodes/sql/runQuery.js +11 -11
- package/build/shared/charts/descriptors/connectionNodes/sql/runStoredProcedure.js +13 -13
- package/build/shared/charts/descriptors/connectionNodes/sql/runTransaction.js +11 -11
- package/build/shared/charts/descriptors/connectionNodes/sql/sqlConnection.js +1 -1
- package/build/shared/charts/descriptors/data/addToContext.js +7 -7
- package/build/shared/charts/descriptors/data/code.js +3 -3
- package/build/shared/charts/descriptors/data/copyDataToContext.js +1 -1
- package/build/shared/charts/descriptors/data/copySlotsToContext.js +9 -9
- package/build/shared/charts/descriptors/data/log.js +7 -7
- package/build/shared/charts/descriptors/data/removeFromContext.js +7 -7
- package/build/shared/charts/descriptors/data/resetContext.js +2 -2
- package/build/shared/charts/descriptors/index.js +35 -8
- package/build/shared/charts/descriptors/knowledgeSearch/index.js +6 -0
- package/build/shared/charts/descriptors/knowledgeSearch/knowledgeSearch.js +149 -0
- package/build/shared/charts/descriptors/liveAgent/assistInfo.js +25 -25
- package/build/shared/charts/descriptors/logic/disableSlotFillers.js +4 -4
- package/build/shared/charts/descriptors/logic/enableSlotFillers.js +3 -3
- package/build/shared/charts/descriptors/logic/executeFlow.js +9 -9
- package/build/shared/charts/descriptors/logic/goTo.js +17 -17
- package/build/shared/charts/descriptors/logic/if/if.js +3 -3
- package/build/shared/charts/descriptors/logic/interval/interval.js +3 -3
- package/build/shared/charts/descriptors/logic/once/once.js +1 -1
- package/build/shared/charts/descriptors/logic/resetState.js +1 -1
- package/build/shared/charts/descriptors/logic/setState.js +4 -4
- package/build/shared/charts/descriptors/logic/setTranslation.js +15 -15
- package/build/shared/charts/descriptors/logic/sleep.js +2 -2
- package/build/shared/charts/descriptors/logic/stop.js +1 -1
- package/build/shared/charts/descriptors/logic/switch/case.js +1 -1
- package/build/shared/charts/descriptors/logic/switch/default.js +1 -1
- package/build/shared/charts/descriptors/logic/switch/switch.js +28 -19
- package/build/shared/charts/descriptors/logic/switchLocale.js +5 -5
- package/build/shared/charts/descriptors/logic/think.js +11 -11
- package/build/shared/charts/descriptors/logic/thinkV2.js +11 -11
- package/build/shared/charts/descriptors/logic/wait.js +1 -1
- package/build/shared/charts/descriptors/message/checkChannelChange/checkChannelChange.js +4 -4
- package/build/shared/charts/descriptors/message/datePicker.js +1 -1
- package/build/shared/charts/descriptors/message/question/optionalQuestion.js +87 -39
- package/build/shared/charts/descriptors/message/question/question.js +751 -204
- package/build/shared/charts/descriptors/message/question/utils/cleanTextUtils.js +191 -0
- package/build/shared/charts/descriptors/message/question/utils/datepickerUtils.js +40 -40
- package/build/shared/charts/descriptors/message/question/utils/evaluateQuestionAnswer.js +37 -27
- package/build/shared/charts/descriptors/message/say.js +70 -6
- package/build/shared/charts/descriptors/message/sendImage.js +1 -1
- package/build/shared/charts/descriptors/message/sendText.js +2 -2
- package/build/shared/charts/descriptors/microsoft/getToken.js +1 -1
- package/build/shared/charts/descriptors/microsoft/invalidateToken.js +1 -1
- package/build/shared/charts/descriptors/microsoft/tokenStatus/index.js +1 -1
- package/build/shared/charts/descriptors/nlu/addLexiconKeyphrase.js +5 -5
- package/build/shared/charts/descriptors/nlu/cleanText.js +103 -0
- package/build/shared/charts/descriptors/nlu/executeCognigyNLU.js +15 -15
- package/build/shared/charts/descriptors/nlu/extractAnswer.js +11 -11
- package/build/shared/charts/descriptors/nlu/fuzzySearch.js +33 -33
- package/build/shared/charts/descriptors/nlu/generativeSlotFiller/generativeSlotFiller.js +270 -0
- package/build/shared/charts/descriptors/nlu/generativeSlotFiller/generativeSlotFillerFallback.js +27 -0
- package/build/shared/charts/descriptors/nlu/generativeSlotFiller/generativeSlotFillerSuccess.js +27 -0
- package/build/shared/charts/descriptors/nlu/generativeSlotFiller/prompt.js +76 -0
- package/build/shared/charts/descriptors/nlu/index.js +9 -1
- package/build/shared/charts/descriptors/nlu/matchPattern.js +16 -16
- package/build/shared/charts/descriptors/nlu/regexSlotFiller.js +5 -5
- package/build/shared/charts/descriptors/placeholder.js +3 -3
- package/build/shared/charts/descriptors/service/GPTConversation.js +678 -0
- package/build/shared/charts/descriptors/service/GPTPrompt.js +258 -0
- package/build/shared/charts/descriptors/service/checkAgentAvailability.js +34 -33
- package/build/shared/charts/descriptors/service/closeHandover.js +34 -0
- package/build/shared/charts/descriptors/service/conversationSummary.js +148 -0
- package/build/shared/charts/descriptors/service/handover.js +18 -17
- package/build/shared/charts/descriptors/service/handoverInactivityTimer.js +37 -0
- package/build/shared/charts/descriptors/service/handoverV2.js +170 -41
- package/build/shared/charts/descriptors/service/httpRequest.js +52 -52
- package/build/shared/charts/descriptors/service/index.js +11 -1
- package/build/shared/charts/descriptors/service/triggerFunction/triggerFunction.js +3 -3
- package/build/shared/charts/descriptors/voice/index.js +5 -1
- package/build/shared/charts/descriptors/voice/mappers/base.mapper.js +83 -0
- package/build/shared/charts/descriptors/voice/mappers/hangup.mapper.js +6 -9
- package/build/shared/charts/descriptors/voice/mappers/muteSpeechInput.mapper.js +52 -0
- package/build/shared/charts/descriptors/voice/mappers/play.mapper.js +19 -19
- package/build/shared/charts/descriptors/voice/mappers/record.mapper.js +96 -0
- package/build/shared/charts/descriptors/voice/mappers/sendMetadata.mapper.js +53 -0
- package/build/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +157 -62
- package/build/shared/charts/descriptors/voice/mappers/transfer.mapper.js +126 -35
- package/build/shared/charts/descriptors/voice/nodes/bargeIn.js +14 -20
- package/build/shared/charts/descriptors/voice/nodes/continuousAsr.js +7 -7
- package/build/shared/charts/descriptors/voice/nodes/dtmf.js +10 -18
- package/build/shared/charts/descriptors/voice/nodes/hangup.js +2 -2
- package/build/shared/charts/descriptors/voice/nodes/muteSpeechInput.js +52 -0
- package/build/shared/charts/descriptors/voice/nodes/noUserInput.js +15 -14
- package/build/shared/charts/descriptors/voice/nodes/play.js +20 -14
- package/build/shared/charts/descriptors/voice/nodes/sendMetadata.js +51 -0
- package/build/shared/charts/descriptors/voice/nodes/sessionSpeechParameters.js +163 -17
- package/build/shared/charts/descriptors/voice/nodes/transfer.js +12 -12
- package/build/shared/charts/descriptors/voice/utils/helper.js +11 -1
- package/build/shared/charts/descriptors/voicegateway/nodes/agentAssist.js +12 -12
- package/build/shared/charts/descriptors/voicegateway/nodes/callRecording.js +64 -62
- package/build/shared/charts/descriptors/voicegateway/nodes/handover.js +14 -14
- package/build/shared/charts/descriptors/voicegateway/nodes/hangup.js +2 -2
- package/build/shared/charts/descriptors/voicegateway/nodes/playURL.js +18 -15
- package/build/shared/charts/descriptors/voicegateway/nodes/sendMessage.js +41 -41
- package/build/shared/charts/descriptors/voicegateway/nodes/sendMetaData.js +15 -19
- package/build/shared/charts/descriptors/voicegateway/nodes/setSessionParams.js +3 -3
- package/build/shared/charts/descriptors/voicegateway/utils/paramUtils.js +117 -97
- package/build/shared/charts/descriptors/voicegateway2/index.js +5 -1
- package/build/shared/charts/descriptors/voicegateway2/nodes/dtmf.js +5 -5
- package/build/shared/charts/descriptors/voicegateway2/nodes/hangup.js +3 -4
- package/build/shared/charts/descriptors/voicegateway2/nodes/muteSpeechInput.js +49 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/play.js +40 -19
- package/build/shared/charts/descriptors/voicegateway2/nodes/record.js +108 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/refer.js +12 -13
- package/build/shared/charts/descriptors/voicegateway2/nodes/sendMetadata.js +14 -29
- package/build/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +383 -82
- package/build/shared/charts/descriptors/voicegateway2/nodes/transfer.js +214 -18
- package/build/shared/charts/descriptors/voicegateway2/utils/helper.js +21 -14
- package/build/shared/charts/descriptors/voicegateway2/utils/strip-nulls.js +8 -1
- package/build/shared/charts/helpers/generativeAI/getRephraseWithAIFields.js +100 -0
- package/build/shared/charts/helpers/generativeAI/rephraseSentenceWithAi.js +44 -0
- package/build/shared/constants.js +15 -1
- package/build/shared/errors/ErrorCode.js +1 -0
- package/build/shared/errors/TooManyRequestsError.js +59 -0
- package/build/shared/errors/baseError.js +6 -2
- package/build/shared/errors/codes.js +2 -1
- package/build/shared/errors/index.js +3 -1
- package/build/shared/helper/BaseContext.js +56 -3
- package/build/shared/helper/nlu/dicts/dicts.js +691 -0
- package/build/shared/helper/nlu/textCleaner.js +391 -0
- package/build/shared/interfaces/IApiKey.js +2 -7
- package/build/shared/interfaces/IOrganisation.js +2 -7
- package/build/shared/interfaces/IProfileSchema.js +1 -7
- package/build/shared/interfaces/agentAssist/ISendTileUpdateParams.js +3 -0
- package/build/shared/interfaces/agentAssist/ISendTileUpdateReferenceParams.js +3 -0
- package/build/shared/interfaces/agentAssist/index.js +3 -0
- package/build/shared/interfaces/amqpInterface.js +7 -1
- package/build/shared/interfaces/analytics/IAnalyticsDataGoals.js +3 -0
- package/build/shared/interfaces/endpointInterface.js +1 -0
- package/build/shared/interfaces/filemanager/IRuntimeFile.js +30 -0
- package/build/shared/interfaces/filemanager/index.js +1 -0
- package/build/shared/interfaces/generativeAI/IGenerativeAIModels.js +72 -0
- package/build/shared/interfaces/generativeAI/IGenerativeAIPrompts.js +3 -0
- package/build/shared/interfaces/generativeAI/IRunGenerativeAIPromptOptions.js +3 -0
- package/build/shared/interfaces/handover.js +52 -4
- package/build/shared/interfaces/knowledgesearch/search.js +3 -0
- package/build/shared/interfaces/messageAPI/ai.js +2 -1
- package/build/shared/interfaces/messageAPI/endpoints.js +93 -2
- package/build/shared/interfaces/messageAPI/handover.js +10 -1
- package/build/shared/interfaces/resources/IAgentAssistConfig.js +26 -20
- package/build/shared/interfaces/resources/IAuditEvent.js +8 -1
- package/build/shared/interfaces/resources/IChart.js +1 -10
- package/build/shared/interfaces/resources/IConnection.js +7 -1
- package/build/shared/interfaces/resources/IConnectionSchema.js +2 -1
- package/build/shared/interfaces/resources/IEndpoint.js +2 -14
- package/build/shared/interfaces/resources/IExtension.js +2 -1
- package/build/shared/interfaces/resources/IFlow.js +17 -11
- package/build/shared/interfaces/resources/IFunction.js +1 -7
- package/build/shared/interfaces/resources/IGenerateNodeOutput.js +3 -0
- package/build/shared/interfaces/resources/ILargeLanguageModel.js +54 -0
- package/build/shared/interfaces/resources/ILexicon.js +16 -8
- package/build/shared/interfaces/resources/INodeDescriptorSet.js +32 -29
- package/build/shared/interfaces/resources/IPackage.js +1 -7
- package/build/shared/interfaces/resources/IPlaybookRun.js +2 -1
- package/build/shared/interfaces/resources/IProject.js +1 -7
- package/build/shared/interfaces/resources/ISnapshot.js +2 -14
- package/build/shared/interfaces/resources/TNLUConnectorType.js +2 -1
- package/build/shared/interfaces/resources/TResourceType.js +16 -5
- package/build/shared/interfaces/resources/chart/IChartExecutable.js +1 -7
- package/build/shared/interfaces/resources/intent/IIntent.js +5 -2
- package/build/shared/interfaces/resources/intent/IIntentRelation.js +3 -1
- package/build/shared/interfaces/resources/knowledgeStore/IKnowledgeChunk.js +32 -0
- package/build/shared/interfaces/resources/knowledgeStore/IKnowledgeSource.js +31 -0
- package/build/shared/interfaces/resources/knowledgeStore/IKnowledgeStore.js +26 -0
- package/build/shared/interfaces/resources/settings/IAgentSettings.js +8 -46
- package/build/shared/interfaces/resources/settings/IAudioPreviewSettings.js +36 -0
- package/build/shared/interfaces/resources/settings/IGenerativeAISettings.js +69 -0
- package/build/shared/interfaces/resources/settings/IGenerativeAIUseCase.js +3 -0
- package/build/shared/interfaces/resources/settings/ISharedSettings.js +2 -2
- package/build/shared/interfaces/resources/settings/index.js +6 -1
- package/build/shared/interfaces/restAPI/administration/user/v2.1/IApiKeyIndexItem_2_1.js +3 -0
- package/build/shared/interfaces/restAPI/administration/user/v2.1/IApiKey_2_1.js +3 -0
- package/build/shared/interfaces/restAPI/administration/user/v2.1/ICreateApiKeyRest_2_1.js +3 -0
- package/build/shared/interfaces/restAPI/administration/user/v2.1/IIndexApiKeysMeRest_2_1.js +3 -0
- package/build/shared/interfaces/restAPI/administration/user/v2.1/index.js +3 -0
- package/build/shared/interfaces/restAPI/insights/reports/IGenerateReportRest_2_0.js +0 -2
- package/build/shared/interfaces/restAPI/resources/agentAssist/v2.0/IReadAgentAssistSessionDataRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/chart/v2.0/IGenerateNodeOutputRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/flow/v2.0/sentence/IGenerateSentencesRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeSearchIndex/v2.0/ICreateKnowledgeSearchIndexRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeSearchIndex/v2.0/IDeleteKnowledgeSearchIndexRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeSearchIndex/v2.0/index.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/ICreateKnowledgeStoreRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IDeleteKnowledgeStoreRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IIndexKnowledgeStoresRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IIngestKnowledgeStoreRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IKnowledgeStore_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IReadKnowledgeStoreRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IUpdateKnowledgeStoreRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/index.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/ICreateKnowledgeSourceRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/IDeleteKnowledgeSourceRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/IIndexKnowledgeSourcesRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/IKnowledgeSource_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/IReadKnowledgeSourceRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/IUpdateKnowledgeSourceRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/IUploadKnowledgeSourceFileRest_2_0.js +4 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/chunk/ICreateKnowledgeChunkRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/chunk/IDeleteKnowledgeChunkRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/chunk/IIndexKnowledgeChunksRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/chunk/IKnowledgeChunk_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/chunk/IReadKnowledgeChunkRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/source/chunk/IUpdateKnowledgeChunkRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/ICloneLargeLanguageModelRest_2_0.js +4 -0
- package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/ICreateLargeLanguageModelRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/IDeleteLargeLanguageModelRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/IIndexLargeLanguageModelsRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/ILargeLanguageModelIndexItem_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/ILargeLanguageModel_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/IReadLargeLanguageModelRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/ITestLargeLanguageModelRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/IUpdateLargeLanguageModelRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/index.js +3 -0
- package/build/shared/interfaces/restAPI/resources/nluconnector/v2.0/TNLUConnectorType_2_0.js +3 -1
- package/build/shared/interfaces/restAPI/resources/project/v2.0/settings/ISetupCognigyGenerativeAIRest_2_0.js +4 -0
- package/build/shared/interfaces/security/IACL.js +1 -7
- package/build/shared/interfaces/security/IIdentityProvider.js +1 -7
- package/build/shared/interfaces/security/IPermission.js +6 -2
- package/build/shared/interfaces/security/IRole.js +3 -1
- package/build/shared/interfaces/security/index.js +1 -2
- package/build/shared/interfaces/taskmanager/ITask.js +1 -0
- package/build/shared/interfaces/trainer/ITrainerRecord.js +1 -1
- package/build/shared/interfaces/user.js +1 -9
- package/package.json +1 -1
- package/types/index.d.ts +5297 -3423
- package/build/shared/charts/descriptors/voice/utils/constants.js +0 -8
- package/build/shared/charts/descriptors/voicegateway2/utils/constants.js +0 -7
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GPT_CONVERSATION = void 0;
|
|
4
|
+
/* Custom modules */
|
|
5
|
+
const createNodeDescriptor_1 = require("../../createNodeDescriptor");
|
|
6
|
+
const JSON5 = require("json5");
|
|
7
|
+
// @ts-ignore - ignore missing module to prevent installing this in multiple services
|
|
8
|
+
const jsonFix = require("json-fixer");
|
|
9
|
+
exports.GPT_CONVERSATION = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
10
|
+
type: "gptConversation",
|
|
11
|
+
defaultLabel: "GPT Conversation",
|
|
12
|
+
summary: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__SUMMARY__DEFAULT",
|
|
13
|
+
appearance: {
|
|
14
|
+
color: "#7F199B",
|
|
15
|
+
},
|
|
16
|
+
fields: [
|
|
17
|
+
{
|
|
18
|
+
key: "customDesc",
|
|
19
|
+
type: "description",
|
|
20
|
+
label: " ",
|
|
21
|
+
params: {
|
|
22
|
+
text: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__CUSTOM_DESC__TEXT"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
key: "mode",
|
|
27
|
+
type: "select",
|
|
28
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__MODE__LABEL__DEFAULT",
|
|
29
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__MODE__DESCRIPTION__DEFAULT",
|
|
30
|
+
defaultValue: "qna",
|
|
31
|
+
params: {
|
|
32
|
+
options: [
|
|
33
|
+
{
|
|
34
|
+
label: "QnA",
|
|
35
|
+
value: "qna"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__MODE__PARAMS__TRANSACTIONAL__LABEL",
|
|
39
|
+
value: "transaction"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
key: "companyName",
|
|
46
|
+
type: "cognigyText",
|
|
47
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__COMPANY_NAME__LABEL",
|
|
48
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__COMPANY_NAME__DESCRIPTION",
|
|
49
|
+
defaultValue: "Cognigy Clinic"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: "companyDescription",
|
|
53
|
+
type: "cognigyText",
|
|
54
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__COMPANY_DESCRIPTION__LABEL",
|
|
55
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__COMPANY_DESCRIPTION__DESCRIPTION",
|
|
56
|
+
defaultValue: "Cognigy Clinic is a fictitious healthcare provider from Düsseldorf, Germany."
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
key: "botName",
|
|
60
|
+
type: "cognigyText",
|
|
61
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__BOT_NAME__LABEL",
|
|
62
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__BOT_NAME__DESCRIPTION",
|
|
63
|
+
defaultValue: "Mr. Bot"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
key: "character",
|
|
67
|
+
type: "textArray",
|
|
68
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__CHARACTER__LABEL",
|
|
69
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__CHARACTER__DESCRIPTION",
|
|
70
|
+
defaultValue: ["professional", "patient"]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
key: "strictness",
|
|
74
|
+
type: "select",
|
|
75
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__STRICTNESS__LABEL",
|
|
76
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__STRICTNESS__DESCRIPTION",
|
|
77
|
+
defaultValue: "flexible",
|
|
78
|
+
params: {
|
|
79
|
+
options: [
|
|
80
|
+
{
|
|
81
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__STRICTNESS__OPTIONS__STRICT__LABEL",
|
|
82
|
+
value: "strict"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__STRICTNESS__OPTIONS__MODERATE__LABEL",
|
|
86
|
+
value: "moderate"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__STRICTNESS__OPTIONS__FLEXIBLE__LABEL",
|
|
90
|
+
value: "flexible"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__STRICTNESS__OPTIONS__FREESTYLE__LABEL",
|
|
94
|
+
value: "freestyle"
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
key: "task",
|
|
101
|
+
type: "cognigyText",
|
|
102
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__TASK__LABEL",
|
|
103
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__TASK__DESCRIPTION",
|
|
104
|
+
defaultValue: "booking of appointment"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
key: "steps",
|
|
108
|
+
type: "cognigyText",
|
|
109
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__STEPS__LABEL",
|
|
110
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__STEPS__DESCRIPTION",
|
|
111
|
+
defaultValue: "1. Check if the customer is an existing patient\n 2. Collect the mandatory information first name, last name, mobile number. Don't leave out information. \n 3. Check when the patient would like to come. Only appointments in the future between 8am and 5pm on weekdays are valid. \n 4. Call action 'checkAppointment' to check if the appointment is available. \n 5. Confirm with the customer.",
|
|
112
|
+
params: {
|
|
113
|
+
multiline: true,
|
|
114
|
+
rows: 5
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
key: "stepLabels",
|
|
119
|
+
type: "textArray",
|
|
120
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__STEPS_LABELS__LABEL",
|
|
121
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__STEPS_LABELS__DESCRIPTION",
|
|
122
|
+
defaultValue: ["Existing Patient Check", "Informationen sammeln", "Collect Appointment Time", "Check Appointment API", "Confirmation"]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
key: "availableActions",
|
|
126
|
+
type: "textArray",
|
|
127
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__AVAILABLE_ACTIONS__LABEL",
|
|
128
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__AVAILABLE_ACTIONS__DESCRIPTION",
|
|
129
|
+
defaultValue: ["checkAppointment"]
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
key: "slotsToCollect",
|
|
133
|
+
type: "textArray",
|
|
134
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__SLOTS_TO_COLLECT__LABEL",
|
|
135
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__SLOTS_TO_COLLECT__DESCRIPTION",
|
|
136
|
+
defaultValue: ["existingPatient", "firstName", "lastName", "mobile", "timeSlot"]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
key: "furtherExamples",
|
|
140
|
+
type: "cognigyText",
|
|
141
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__FURTHER_EXAMPLES__LABEL",
|
|
142
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__FURTHER_EXAMPLES__DESCRIPTION",
|
|
143
|
+
defaultValue: "Never talk about money or prices.",
|
|
144
|
+
params: {
|
|
145
|
+
multiline: true,
|
|
146
|
+
rows: 2
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
key: "injectedSlots",
|
|
151
|
+
type: "cognigyText",
|
|
152
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__INJECT_SLOTS__LABEL",
|
|
153
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__INJECT_SLOTS__DESCRIPTION",
|
|
154
|
+
defaultValue: `{{input.slots.DATE[0].start.plain ? "Date: " + input.slots.DATE[0].start.plain : "" }}`
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
key: "knowledge",
|
|
158
|
+
type: "cognigyText",
|
|
159
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__KNOWLEDGE__LABEL",
|
|
160
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__KNOWLEDGE__DESCRIPTION",
|
|
161
|
+
defaultValue: "Cognigy Clinic is a health care provider in Düsseldorf, Germany.\n We have 5 doctors and 12 nurses.\n We specialize in the following areas:\n - General Medicine\n - Pediatrics\n - Immunoallergology`\n ",
|
|
162
|
+
params: {
|
|
163
|
+
multiline: true,
|
|
164
|
+
rows: 5
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
key: "temperature",
|
|
169
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__TEMPERATURE__LABEL",
|
|
170
|
+
type: "slider",
|
|
171
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__TEMPERATURE__DESCRIPTION",
|
|
172
|
+
defaultValue: 0.7,
|
|
173
|
+
params: {
|
|
174
|
+
min: 0,
|
|
175
|
+
max: 1,
|
|
176
|
+
step: 0.1
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
key: "max_tokens",
|
|
181
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__MAX_TOKENS__LABEL",
|
|
182
|
+
type: "number",
|
|
183
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__MAX_TOKENS__DESCRIPTION",
|
|
184
|
+
defaultValue: 2000
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
key: "top_p",
|
|
188
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__TOP_P__LABEL",
|
|
189
|
+
type: "number",
|
|
190
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__TOP_P__DESCRIPTION",
|
|
191
|
+
defaultValue: 1
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
key: "frequency_penalty",
|
|
195
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__FREQUENCY_PENALTY__LABEL",
|
|
196
|
+
type: "number",
|
|
197
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__FREQUENCY_PENALTY__DESCRIPTION",
|
|
198
|
+
defaultValue: 0
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
key: "presence_penalty",
|
|
202
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__PRESENCE_PENALTY__LABEL",
|
|
203
|
+
type: "number",
|
|
204
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__PRESENCE_PENALTY__DESCRIPTION",
|
|
205
|
+
defaultValue: 0
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
key: "useStop",
|
|
209
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__USE_STOP__LABEL",
|
|
210
|
+
type: "toggle",
|
|
211
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__USE_STOP__DESCRIPTION",
|
|
212
|
+
defaultValue: false
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
key: "stop",
|
|
216
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__STOP__LABEL",
|
|
217
|
+
type: "textArray",
|
|
218
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__STOP__DESCRIPTION",
|
|
219
|
+
condition: {
|
|
220
|
+
key: "useStop",
|
|
221
|
+
value: true
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
key: "debug",
|
|
226
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__DEBUG__LABEL",
|
|
227
|
+
type: "toggle",
|
|
228
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__DEBUG__DESCRIPTION",
|
|
229
|
+
defaultValue: false
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
key: "timeout",
|
|
233
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__TIMEOUT__LABEL",
|
|
234
|
+
type: "number",
|
|
235
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__TIMEOUT__DESCRIPTION",
|
|
236
|
+
defaultValue: 3000
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
key: "timeoutMessage",
|
|
240
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__TIMEOUT_MESSAGE__LABEL",
|
|
241
|
+
type: "cognigyText",
|
|
242
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__FIELDS__TIMEOUT_MESSAGE__DESCRIPTION",
|
|
243
|
+
defaultValue: "I'm very sorry, but the GPT provider seems to be very slow today. Please call again later if possible."
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
sections: [
|
|
247
|
+
{
|
|
248
|
+
key: "persona",
|
|
249
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__SECTIONS__PERSONA__LABEL",
|
|
250
|
+
defaultCollapsed: true,
|
|
251
|
+
fields: [
|
|
252
|
+
"companyName",
|
|
253
|
+
"companyDescription",
|
|
254
|
+
"botName",
|
|
255
|
+
"botDescription",
|
|
256
|
+
"character",
|
|
257
|
+
"strictness"
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
key: "advanced",
|
|
262
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__SECTIONS__ADVANCED__LABEL",
|
|
263
|
+
defaultCollapsed: true,
|
|
264
|
+
fields: [
|
|
265
|
+
"engine",
|
|
266
|
+
"temperature",
|
|
267
|
+
"max_tokens",
|
|
268
|
+
"top_p",
|
|
269
|
+
"presence_penalty",
|
|
270
|
+
"frequency_penalty",
|
|
271
|
+
"useStop",
|
|
272
|
+
"stop"
|
|
273
|
+
]
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
key: "taskSettings",
|
|
277
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__SECTIONS__TASK_SETTINGS__LABEL",
|
|
278
|
+
defaultCollapsed: true,
|
|
279
|
+
fields: [
|
|
280
|
+
"task",
|
|
281
|
+
"steps",
|
|
282
|
+
"stepLabels",
|
|
283
|
+
"slotsToCollect",
|
|
284
|
+
"availableActions",
|
|
285
|
+
"furtherExamples"
|
|
286
|
+
],
|
|
287
|
+
condition: {
|
|
288
|
+
key: "mode",
|
|
289
|
+
value: "transaction"
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
key: "grounding",
|
|
294
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__SECTIONS__GROUNDING__LABEL",
|
|
295
|
+
defaultCollapsed: true,
|
|
296
|
+
fields: [
|
|
297
|
+
"knowledge",
|
|
298
|
+
"injectedSlots"
|
|
299
|
+
]
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
key: "timeouts",
|
|
303
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_CONVERSATION__SECTIONS__TIMEOUTS__LABEL",
|
|
304
|
+
defaultCollapsed: true,
|
|
305
|
+
fields: [
|
|
306
|
+
"timeout",
|
|
307
|
+
"timeoutMessage"
|
|
308
|
+
]
|
|
309
|
+
},
|
|
310
|
+
],
|
|
311
|
+
form: [
|
|
312
|
+
{ type: "field", key: "customDesc" },
|
|
313
|
+
{ type: "field", key: "mode" },
|
|
314
|
+
{ type: "section", key: "persona" },
|
|
315
|
+
{ type: "section", key: "taskSettings" },
|
|
316
|
+
{ type: "section", key: "grounding" },
|
|
317
|
+
{ type: "section", key: "advanced" },
|
|
318
|
+
{ type: "section", key: "timeouts" }
|
|
319
|
+
],
|
|
320
|
+
tags: ["service"],
|
|
321
|
+
function: async ({ cognigy, config }) => {
|
|
322
|
+
const { api, context, input } = cognigy;
|
|
323
|
+
const { debug, timeoutMessage } = config;
|
|
324
|
+
if (!context.parameters) {
|
|
325
|
+
context.parameters = {};
|
|
326
|
+
}
|
|
327
|
+
let prompt;
|
|
328
|
+
try {
|
|
329
|
+
prompt = await buildPrompt(context, input, api, config);
|
|
330
|
+
if (debug && input.channel === "adminconsole")
|
|
331
|
+
api.output(prompt, null);
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
if (debug && input.channel === "adminconsole")
|
|
335
|
+
api.output("Error in building prompt: " + error.message, null);
|
|
336
|
+
else
|
|
337
|
+
api.log("error", "Error in building prompt: " + error.message);
|
|
338
|
+
}
|
|
339
|
+
if (prompt) {
|
|
340
|
+
let response;
|
|
341
|
+
const data = { prompt };
|
|
342
|
+
try {
|
|
343
|
+
response = await api.runGenerativeAIPrompt(data, "gptConversation");
|
|
344
|
+
}
|
|
345
|
+
catch (error) {
|
|
346
|
+
if (debug && input.channel === "adminconsole")
|
|
347
|
+
api.output("Error in executing prompt: " + error.message, null);
|
|
348
|
+
else
|
|
349
|
+
api.log("error", "Error in executing prompt: " + error.message);
|
|
350
|
+
if (error.code && error.code === 'ECONNABORTED' && error.isAxiosError) {
|
|
351
|
+
api.output(timeoutMessage, null);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
if (!response) {
|
|
355
|
+
api.log("debug", "Re-trying OpenAI Request, as no result received");
|
|
356
|
+
try {
|
|
357
|
+
response = await api.runGenerativeAIPrompt(data, "gptConversation");
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
if (debug && input.channel === "adminconsole")
|
|
361
|
+
api.output("Error in executing prompt: " + error.message, null);
|
|
362
|
+
else
|
|
363
|
+
api.log("error", "Error in executing prompt: " + error.message);
|
|
364
|
+
if (error.code && error.code === 'ECONNABORTED' && error.isAxiosError) {
|
|
365
|
+
api.output(timeoutMessage, null);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (response) {
|
|
370
|
+
let commands;
|
|
371
|
+
try {
|
|
372
|
+
commands = await parseResponse(api, input, debug, response);
|
|
373
|
+
if (!commands || commands.length === 0) {
|
|
374
|
+
response = await api.runGenerativeAIPrompt(data, "gptConversation");
|
|
375
|
+
commands = await parseResponse(api, input, debug, response);
|
|
376
|
+
}
|
|
377
|
+
if (debug && input.channel === "adminconsole")
|
|
378
|
+
api.output(JSON.stringify(commands, null, 4), null);
|
|
379
|
+
}
|
|
380
|
+
catch (error) {
|
|
381
|
+
if (debug && input.channel === "adminconsole")
|
|
382
|
+
api.output("Error in parsing response: " + error.message, null);
|
|
383
|
+
else
|
|
384
|
+
api.log("error", "Error in parsing response: " + error.message);
|
|
385
|
+
}
|
|
386
|
+
try {
|
|
387
|
+
await handleCommands(context, input, api, debug, commands, config.stepLabels);
|
|
388
|
+
}
|
|
389
|
+
catch (error) {
|
|
390
|
+
if (debug && input.channel === "adminconsole")
|
|
391
|
+
api.output("Error in handling commands: " + error.message, null);
|
|
392
|
+
else
|
|
393
|
+
api.log("error", "Error in handling commands: " + error.message);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
async function buildPrompt(context, input, api, config) {
|
|
400
|
+
const { botName, character, companyName, companyDescription, strictness, furtherExamples, task, steps, injectedSlots, knowledge, mode, availableActions, slotsToCollect } = config;
|
|
401
|
+
// clean the text to prevent injections
|
|
402
|
+
const userText = input.text.replace(/bot:/gi, "").trim();
|
|
403
|
+
let prompt;
|
|
404
|
+
if (mode === "transaction") {
|
|
405
|
+
// add known information to the prompt from the context
|
|
406
|
+
let knownInformation = "\nInformation provided by the user:";
|
|
407
|
+
if (context.parameters) {
|
|
408
|
+
Object.keys(context.parameters).forEach((key) => {
|
|
409
|
+
if (key !== "lastOutput") {
|
|
410
|
+
knownInformation += `-${key}: ${context.parameters[key]}\n`;
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
// add available actions to the prompt
|
|
415
|
+
let actionInformation;
|
|
416
|
+
if (availableActions && Array.isArray(availableActions) && availableActions.length > 0) {
|
|
417
|
+
actionInformation = `\nYou can trigger actions by sending a command like {"action":"nameOfAction"}. If a step tells you to trigger an action, always do.\nThe following actions are available:`;
|
|
418
|
+
availableActions.forEach((action) => {
|
|
419
|
+
actionInformation += `\n-${action}`;
|
|
420
|
+
});
|
|
421
|
+
actionInformation += "\nDo not trigger any other actions than the ones above.";
|
|
422
|
+
}
|
|
423
|
+
// add slots to collec to the prompt
|
|
424
|
+
let slotInformation;
|
|
425
|
+
if (slotsToCollect && Array.isArray(slotsToCollect) && slotsToCollect.length > 0) {
|
|
426
|
+
slotInformation = "\nThe following slots need to be collected:";
|
|
427
|
+
slotsToCollect.forEach((slot) => {
|
|
428
|
+
slotInformation += `\n-${slot}`;
|
|
429
|
+
});
|
|
430
|
+
slotInformation += `\nWhen you hear a slot, make sure to output it in the following format: Bot: [{"slot": "salutation", value: "Mr"}`;
|
|
431
|
+
}
|
|
432
|
+
// choose how strict the bot will stick to the task
|
|
433
|
+
let strictnessLevel;
|
|
434
|
+
switch (strictness) {
|
|
435
|
+
case "freestyle":
|
|
436
|
+
strictnessLevel = "When asked random questions about trivia or small talk, answer the question as good as you can in one sentence.";
|
|
437
|
+
break;
|
|
438
|
+
case "flexible":
|
|
439
|
+
strictnessLevel = "When asked random questions about trivia or small talk, answer the question. Then in a next sentence guide the user back to the task.";
|
|
440
|
+
break;
|
|
441
|
+
case "moderate":
|
|
442
|
+
strictnessLevel = "When hit with small talk, answer something nice back. Don't answer questions unrelated to the task. Pretend you don't know anything else about the world.";
|
|
443
|
+
break;
|
|
444
|
+
default:
|
|
445
|
+
strictnessLevel = "Do no deviate from the task steps and don't answer unrelated questions. Only answer question about the provided knowledge or information provided by the user. Pretend you don't know anything else about the world.";
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
// check if knowledge was injected for grouding
|
|
449
|
+
let injectedKnowledge;
|
|
450
|
+
if (knowledge) {
|
|
451
|
+
injectedKnowledge = `You have the following contextual document from your internal knowledge base:
|
|
452
|
+
"${knowledge}" `;
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
injectedKnowledge = `You have not been given any contextual document from your internal knowledge base to answer the user's question. Don't make up an answer.`;
|
|
456
|
+
}
|
|
457
|
+
prompt = `You are a chatbot in customer service for ${companyName} (${companyDescription}). ${botName ? "Your name is " + botName : ""}
|
|
458
|
+
|
|
459
|
+
You can generate example outputs in the following format:
|
|
460
|
+
Bot: [{"message": "Welcome. I am here to help you make an appointment. Are you an existing patient?"}]
|
|
461
|
+
Bot: [{"slot": "salutation", value: "Mr"},{"slot": "lastName", value: "Heltewig"},{"slot": "mobile", value: "01751234567"},{"message": "Perfect. When would you like to come."},{"step":4}]
|
|
462
|
+
Bot: [{"slot": "timeStamp", value: "2022-12-28T16:00"},{"message": "Thank you. Let me confirm that."},{"action": "nameOfAction"}]
|
|
463
|
+
Bot: [{"message": "Let me check this"},{"action":"checkAPI"}]
|
|
464
|
+
|
|
465
|
+
${furtherExamples}
|
|
466
|
+
If a customer wishes to abort or cancel the process, output [{"action": "cancel" }]
|
|
467
|
+
|
|
468
|
+
Your current task "${task}" has the following steps:
|
|
469
|
+
${steps}
|
|
470
|
+
|
|
471
|
+
When finishing a step, send the number of the new step as {"step":3}
|
|
472
|
+
${actionInformation}
|
|
473
|
+
${slotInformation}
|
|
474
|
+
${injectedKnowledge}
|
|
475
|
+
${knownInformation}
|
|
476
|
+
|
|
477
|
+
Respond in a ${character} way.
|
|
478
|
+
Respond to all messages in JSON as per the above.
|
|
479
|
+
Only generate one Bot output and stop.
|
|
480
|
+
Do not generate API inputs. Do not generate User inputs.
|
|
481
|
+
Do not give answers that could be incorrect or misleading.
|
|
482
|
+
Do not give answers which portray ${companyName} negatively and harm its reputation.
|
|
483
|
+
${strictnessLevel}
|
|
484
|
+
|
|
485
|
+
Currently it is ${input.currentTime.dayOfWeek}, ${input.currentTime.plain}
|
|
486
|
+
|
|
487
|
+
${context.lastOutput ? 'Bot: {"message": "' + context.lastOutput + '"},' : ""}
|
|
488
|
+
${userText.startsWith("API") ? 'API' : 'User'}: ${userText.replace("API:", "")} ${injectedSlots}
|
|
489
|
+
Bot: [{`;
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
// choose how strict the bot will stick to the task
|
|
493
|
+
let strictnessLevel;
|
|
494
|
+
switch (strictness) {
|
|
495
|
+
case "freestyle":
|
|
496
|
+
strictnessLevel = "When asked random questions about trivia or small talk, answer the question as good as you can in one sentence.";
|
|
497
|
+
break;
|
|
498
|
+
case "flexible":
|
|
499
|
+
strictnessLevel = "When asked random questions about trivia or small talk, answer the question.";
|
|
500
|
+
break;
|
|
501
|
+
case "moderate":
|
|
502
|
+
strictnessLevel = "When hit with small talk, answer something nice back. Don't answer questions unrelated to the company. Pretend you don't know anything else about the world.";
|
|
503
|
+
break;
|
|
504
|
+
default:
|
|
505
|
+
strictnessLevel = "Only answer questions if you have been provided with the answer from the knowledge base. Pretend you don't know anything else about the world.";
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
// check if knowledge was injected for grouding
|
|
509
|
+
let injectedKnowledge;
|
|
510
|
+
if (knowledge) {
|
|
511
|
+
injectedKnowledge = `You have the following contextual document from your internal knowledge base:
|
|
512
|
+
"${knowledge}" `;
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
injectedKnowledge = `You have not been given any contextual document from your internal knowledge base to answer the user's question. Don't make up an answer.`;
|
|
516
|
+
}
|
|
517
|
+
prompt = `You are a chatbot in customer service for ${companyName} (${companyDescription}). ${botName ? "Your name is " + botName : ""}
|
|
518
|
+
|
|
519
|
+
Your task is to answer the users questions in a truthful and helpful way. Only base your answer on information provided above and not on the bot's previous answers.
|
|
520
|
+
|
|
521
|
+
${injectedKnowledge}
|
|
522
|
+
|
|
523
|
+
Use the following JSON format to respond:
|
|
524
|
+
Bot: [{"message": "Your answer here"}]
|
|
525
|
+
|
|
526
|
+
Respond in a ${character} way.
|
|
527
|
+
Only generate one Bot output and stop.
|
|
528
|
+
STOP after generating one line of output!
|
|
529
|
+
Do not give answers that could be incorrect or misleading.
|
|
530
|
+
Do not give answers which portray ${companyName} negatively and harm its reputation.
|
|
531
|
+
${strictnessLevel}
|
|
532
|
+
|
|
533
|
+
Currently it is ${input.currentTime.dayOfWeek}, ${input.currentTime.plain}
|
|
534
|
+
${context.lastOutput ? 'Bot: [{"message": "' + context.lastOutput + '"}]' : ""}
|
|
535
|
+
User: ${userText}
|
|
536
|
+
Bot: [{`;
|
|
537
|
+
}
|
|
538
|
+
return prompt;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Parses the response from the respective API and cleans it
|
|
542
|
+
* @param api
|
|
543
|
+
* @param input
|
|
544
|
+
* @param debug
|
|
545
|
+
* @param response
|
|
546
|
+
* @returns
|
|
547
|
+
*/
|
|
548
|
+
async function parseResponse(api, input, debug, response) {
|
|
549
|
+
let apiResponse = "[{" + response;
|
|
550
|
+
try {
|
|
551
|
+
// try to just parse the results and see if they work out
|
|
552
|
+
const commands = JSON5.parse(apiResponse);
|
|
553
|
+
return commands;
|
|
554
|
+
}
|
|
555
|
+
catch (err) {
|
|
556
|
+
api.log("debug", "OpenAI Parse Error Level 1 - " + err.message);
|
|
557
|
+
try {
|
|
558
|
+
// fix using jsonFix and again parse the results to see if they work out
|
|
559
|
+
const { data, changed } = jsonFix(apiResponse);
|
|
560
|
+
if (changed) {
|
|
561
|
+
apiResponse = data;
|
|
562
|
+
}
|
|
563
|
+
const commands = JSON5.parse(apiResponse);
|
|
564
|
+
return commands;
|
|
565
|
+
}
|
|
566
|
+
catch (err) {
|
|
567
|
+
api.log("debug", "OpenAI Parse Error Level 2 - " + err.message);
|
|
568
|
+
// manually make some adjustments and break the commands into individual commands to parse
|
|
569
|
+
if (apiResponse.endsWith(",]")) {
|
|
570
|
+
apiResponse = apiResponse.substr(0, apiResponse.length - 2) + "]";
|
|
571
|
+
}
|
|
572
|
+
apiResponse = apiResponse.replace(/\}.?,.?\{/g, "}##BREAK##{");
|
|
573
|
+
const individualCommands = apiResponse.substr(1, apiResponse.length - 1).split("##BREAK##");
|
|
574
|
+
individualCommands[individualCommands.length - 1] = individualCommands[individualCommands.length - 1].substring(0, individualCommands[individualCommands.length - 1].length - 1);
|
|
575
|
+
const newCommands = [];
|
|
576
|
+
individualCommands.forEach((command) => {
|
|
577
|
+
try {
|
|
578
|
+
// again try to just fix the command and parse
|
|
579
|
+
const { data, changed } = jsonFix(command);
|
|
580
|
+
if (changed) {
|
|
581
|
+
command = data;
|
|
582
|
+
}
|
|
583
|
+
command = JSON5.parse(command);
|
|
584
|
+
newCommands.push(command);
|
|
585
|
+
}
|
|
586
|
+
catch (err) {
|
|
587
|
+
try {
|
|
588
|
+
// fix using module and manual fixes, try again
|
|
589
|
+
command = command.replace(/(":\s*)'(.*?)'/g, '$1"$2"');
|
|
590
|
+
command = command.replace(/“/g, '"');
|
|
591
|
+
command = command.replace(/”/g, '"');
|
|
592
|
+
command = command.replace(/\\n/g, "").trim();
|
|
593
|
+
if (command.substring(1, 10).indexOf("action") > -1) {
|
|
594
|
+
command = command.replace(/\{action:/g, "{\"action\":");
|
|
595
|
+
command = command.replace(/\{action\":/g, "{\"action\":");
|
|
596
|
+
command = command.replace(/\{'action':\s'(.*)'}/g, '{"action": "$1"}');
|
|
597
|
+
}
|
|
598
|
+
if (command.substring(1, 10).indexOf("message") > -1) {
|
|
599
|
+
command = command.replace(/\{message:/g, "{\"message\":");
|
|
600
|
+
command = command.replace(/\{message\":/g, "{\"message\":");
|
|
601
|
+
command = command.replace(/\{'message':\s'(.*)'}/g, '{"message": "$1"}');
|
|
602
|
+
command = command.replace(/\{"message":\s'(.*)'}/g, '{"message": "$1"}');
|
|
603
|
+
}
|
|
604
|
+
if (command.substring(1, 10).indexOf("slot") > -1) {
|
|
605
|
+
command = command.replace(/\{slot:/g, '{"slot":');
|
|
606
|
+
command = command.replace(/\{slot\":/g, '{"slot":');
|
|
607
|
+
command = command.replace(/\svalue:/g, 'value:');
|
|
608
|
+
command = command.replace(/\svalue\":/g, 'value:');
|
|
609
|
+
command = command.replace(/\{'slot':.+'(.*).+,'/g, '{"slot": "$1", ');
|
|
610
|
+
command = command.replace(/'value':.+'(.*)'}/g, 'value: "$2"}');
|
|
611
|
+
}
|
|
612
|
+
const { data, changed } = jsonFix(command);
|
|
613
|
+
if (changed) {
|
|
614
|
+
command = data;
|
|
615
|
+
}
|
|
616
|
+
command = JSON5.parse(command);
|
|
617
|
+
newCommands.push(command);
|
|
618
|
+
}
|
|
619
|
+
catch (err) {
|
|
620
|
+
// if all fails, output an error
|
|
621
|
+
if (debug && input.channel === "adminconsole")
|
|
622
|
+
api.output("Error in parsing command " + command + " : " + err.message, null);
|
|
623
|
+
else
|
|
624
|
+
api.log("debug", "Error in parsing command " + command + " : " + err.message);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
return newCommands;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Handle commands sent to us from GPT (messages, slots, actions)
|
|
634
|
+
* @param context Cognigy Context object
|
|
635
|
+
* @param input Cognigy Input object
|
|
636
|
+
* @param api Cognigy API object
|
|
637
|
+
* @param debug Debug mode toggle
|
|
638
|
+
* @param commands The commands to handle
|
|
639
|
+
* @param config Node Config
|
|
640
|
+
*/
|
|
641
|
+
async function handleCommands(context, input, api, debug, commands, stepLabels) {
|
|
642
|
+
let outputs = false;
|
|
643
|
+
context.action = null;
|
|
644
|
+
for (let command of commands) {
|
|
645
|
+
try {
|
|
646
|
+
if (command.message) {
|
|
647
|
+
context.lastOutput = command.message;
|
|
648
|
+
api.output(command.message, null);
|
|
649
|
+
outputs = true;
|
|
650
|
+
}
|
|
651
|
+
if (command.action) {
|
|
652
|
+
context.action = command.action;
|
|
653
|
+
outputs = true;
|
|
654
|
+
}
|
|
655
|
+
if (command.slot) {
|
|
656
|
+
// use cumbersome way to update context, as updating object keys will not trigger proxy
|
|
657
|
+
const newParameters = JSON.parse(JSON.stringify(context.parameters));
|
|
658
|
+
newParameters[command.slot] = command.value;
|
|
659
|
+
context.parameters = newParameters;
|
|
660
|
+
}
|
|
661
|
+
if (command.step) {
|
|
662
|
+
context.step = command.step;
|
|
663
|
+
context.stepLabel = stepLabels[command.step - 1];
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
catch (err) {
|
|
667
|
+
if (debug && input.channel === "adminconsole")
|
|
668
|
+
api.output("Couldn't parse command " + command, null);
|
|
669
|
+
else
|
|
670
|
+
api.log("error", "Couldn't parse command " + command);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
if (!outputs) {
|
|
674
|
+
api.output("Sorry, I was absentminded for a second, could you say that again please?", null);
|
|
675
|
+
api.log("error", JSON.stringify(commands));
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
//# sourceMappingURL=GPTConversation.js.map
|