@cognigy/rest-api-client 0.17.0 → 0.19.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 +12 -0
- package/build/GenericTusFn.js +6 -1
- package/build/GenericUploadFn.js +3 -5
- package/build/apigroups/AdministrationAPIGroup_2_0.js +3 -1
- package/build/apigroups/MetricsAPIGroup_2_0.js +5 -0
- package/build/apigroups/ResourcesAPIGroup_2_0.js +21 -7
- package/build/connector/AxiosAdapter.js +35 -15
- package/build/shared/charts/createNodeDescriptor.js +5 -5
- package/build/shared/charts/descriptors/agentAssist/constants/constants.js +16 -1
- package/build/shared/charts/descriptors/agentAssist/helpers/agentAssistTranslator.helper.js +19 -0
- package/build/shared/charts/descriptors/agentAssist/helpers/determineMetadata.js +15 -0
- package/build/shared/charts/descriptors/agentAssist/helpers/getFontSizeFieldOptions.js +84 -0
- package/build/shared/charts/descriptors/agentAssist/helpers/getLanguageName.helper.js +33 -0
- package/build/shared/charts/descriptors/agentAssist/helpers/knowledgeSearch/answerExtraction.helper.js +59 -0
- package/build/shared/charts/descriptors/agentAssist/helpers/knowledgeSearch/configValidator.helper.js +20 -0
- package/build/shared/charts/descriptors/agentAssist/helpers/knowledgeSearch/errorHandler.helper.js +64 -0
- package/build/shared/charts/descriptors/agentAssist/helpers/knowledgeSearch/followUpDetection.helper.js +72 -0
- package/build/shared/charts/descriptors/agentAssist/helpers/knowledgeSearch/knowledgeSearch.helper.js +58 -0
- package/build/shared/charts/descriptors/agentAssist/helpers/sentiment.helper.js +7 -13
- package/build/shared/charts/descriptors/agentAssist/htmlTemplates/identityAssistTemplate.js +17 -18
- package/build/shared/charts/descriptors/agentAssist/htmlTemplates/knowledgeAssistTemplate.js +330 -153
- package/build/shared/charts/descriptors/agentAssist/htmlTemplates/nextActionWidgetTemplate.js +212 -80
- package/build/shared/charts/descriptors/agentAssist/htmlTemplates/sentimentAnalysisTemplate.js +11 -6
- package/build/shared/charts/descriptors/agentAssist/htmlTemplates/transcriptAssistTemplate.js +15 -13
- package/build/shared/charts/descriptors/agentAssist/identityAssist.js +88 -15
- package/build/shared/charts/descriptors/agentAssist/knowledgeAssist.js +192 -327
- package/build/shared/charts/descriptors/agentAssist/locales/cs.locale.js +11 -0
- package/build/shared/charts/descriptors/agentAssist/locales/de.locale.js +11 -0
- package/build/shared/charts/descriptors/agentAssist/locales/en.locale.js +11 -0
- package/build/shared/charts/descriptors/agentAssist/locales/es.locale.js +11 -0
- package/build/shared/charts/descriptors/agentAssist/locales/fr.locale.js +11 -0
- package/build/shared/charts/descriptors/agentAssist/locales/index.js +22 -0
- package/build/shared/charts/descriptors/agentAssist/locales/ja.locale.js +11 -0
- package/build/shared/charts/descriptors/agentAssist/locales/ko.locale.js +11 -0
- package/build/shared/charts/descriptors/agentAssist/locales/pt.locale.js +11 -0
- package/build/shared/charts/descriptors/agentAssist/nextActionAssist.js +484 -10
- package/build/shared/charts/descriptors/agentAssist/sentimentAssist.js +32 -9
- package/build/shared/charts/descriptors/agentAssist/setAdaptiveCardTile.js +2 -0
- package/build/shared/charts/descriptors/agentAssist/setAgentAssistGrid.js +2 -1
- package/build/shared/charts/descriptors/agentAssist/setHtmlTile.js +5 -3
- package/build/shared/charts/descriptors/agentAssist/setIframeTile.js +5 -3
- package/build/shared/charts/descriptors/agentAssist/setSecureFormsTile.js +2 -2
- package/build/shared/charts/descriptors/agentAssist/transcriptAssist.js +42 -3
- package/build/shared/charts/descriptors/analytics/activateProfile.js +1 -0
- package/build/shared/charts/descriptors/analytics/blindMode.js +2 -0
- package/build/shared/charts/descriptors/analytics/completeGoal.js +1 -0
- package/build/shared/charts/descriptors/analytics/deactivateProfile.js +1 -0
- package/build/shared/charts/descriptors/analytics/deleteProfile.js +1 -0
- package/build/shared/charts/descriptors/analytics/index.js +3 -1
- package/build/shared/charts/descriptors/analytics/mergeProfile.js +1 -0
- package/build/shared/charts/descriptors/analytics/overwriteAnalytics.js +9 -0
- package/build/shared/charts/descriptors/analytics/requestRating.js +56 -2
- package/build/shared/charts/descriptors/analytics/setRating.js +4 -2
- package/build/shared/charts/descriptors/analytics/trackMilestone.js +95 -0
- package/build/shared/charts/descriptors/analytics/updateProfile.js +1 -0
- package/build/shared/charts/descriptors/apps/initAppSession.js +1 -0
- package/build/shared/charts/descriptors/apps/setAdaptiveCardAppState.js +35 -10
- package/build/shared/charts/descriptors/apps/setHtmlAppState.js +25 -2
- package/build/shared/charts/descriptors/apps/utils/getXAppsOverlaySettings.js +54 -0
- package/build/shared/charts/descriptors/connectionNodes/documentParserProviders/azureAIDocumentIntelligenceConnection.js +12 -0
- package/build/shared/charts/descriptors/connectionNodes/documentParserProviders/index.js +13 -0
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/awsBedrockProviderConnection.js +12 -0
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/azureOpenAIProviderConnection.js +4 -3
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/azureOpenAIProviderConnectionV2.js +3 -3
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/azureOpenAIProviderOauth2Connection.js +14 -0
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/index.js +16 -8
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/openAIProviderConnection.js +3 -3
- package/build/shared/charts/descriptors/data/addToContext.js +7 -0
- package/build/shared/charts/descriptors/data/copyDataToContext.js +3 -0
- package/build/shared/charts/descriptors/data/copySlotsToContext.js +3 -0
- package/build/shared/charts/descriptors/data/debugMessage.js +73 -0
- package/build/shared/charts/descriptors/data/index.js +3 -1
- package/build/shared/charts/descriptors/data/removeFromContext.js +9 -1
- package/build/shared/charts/descriptors/data/resetContext.js +1 -0
- package/build/shared/charts/descriptors/index.js +8 -4
- package/build/shared/charts/descriptors/knowledgeSearch/searchExtractOutput.js +36 -11
- package/build/shared/charts/descriptors/logic/resetState.js +1 -0
- package/build/shared/charts/descriptors/logic/setState.js +2 -1
- package/build/shared/charts/descriptors/logic/setTranslation.js +3 -1
- package/build/shared/charts/descriptors/logic/switchLocale.js +1 -0
- package/build/shared/charts/descriptors/logic/think.js +3 -1
- package/build/shared/charts/descriptors/logic/thinkV2.js +2 -0
- package/build/shared/charts/descriptors/message/question/optionalQuestion.js +1 -1
- package/build/shared/charts/descriptors/message/question/question.js +173 -7
- package/build/shared/charts/descriptors/message/question/utils/evaluateQuestionAnswer.js +44 -3
- package/build/shared/charts/descriptors/message/question/utils/validateQuestionAnswer.js +4 -2
- package/build/shared/charts/descriptors/nlu/cleanText.js +1 -0
- package/build/shared/charts/descriptors/nlu/fuzzySearch.js +23 -1
- package/build/shared/charts/descriptors/nlu/generativeSlotFiller/prompt.js +45 -19
- package/build/shared/charts/descriptors/nlu/index.js +1 -3
- package/build/shared/charts/descriptors/service/GPTPrompt.js +362 -29
- package/build/shared/charts/descriptors/service/LLMEntityExtract.js +283 -0
- package/build/shared/charts/descriptors/service/handoverV2.js +84 -1
- package/build/shared/charts/descriptors/service/httpRequest.js +68 -3
- package/build/shared/charts/descriptors/service/index.js +3 -1
- package/build/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +110 -27
- package/build/shared/charts/descriptors/voice/mappers/transfer.mapper.js +4 -4
- package/build/shared/charts/descriptors/voice/nodes/bargeIn.js +2 -0
- package/build/shared/charts/descriptors/voice/nodes/continuousAsr.js +2 -0
- package/build/shared/charts/descriptors/voice/nodes/dtmf.js +2 -0
- package/build/shared/charts/descriptors/voice/nodes/muteSpeechInput.js +1 -0
- package/build/shared/charts/descriptors/voice/nodes/noUserInput.js +2 -0
- package/build/shared/charts/descriptors/voice/nodes/play.js +8 -1
- package/build/shared/charts/descriptors/voice/nodes/sessionSpeechParameters.js +46 -45
- package/build/shared/charts/descriptors/voice/nodes/transfer.js +2 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/dtmf.js +2 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/hangup.js +2 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/muteSpeechInput.js +3 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/play.js +1 -1
- package/build/shared/charts/descriptors/voicegateway2/nodes/record.js +1 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/refer.js +1 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/sendMetadata.js +1 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +329 -47
- package/build/shared/charts/descriptors/voicegateway2/nodes/transfer.js +27 -31
- package/build/shared/charts/descriptors/voicegateway2/utils/helper.js +2 -2
- package/build/shared/charts/helpers/generativeAI/generativeAIPrompts.js +55 -0
- package/build/shared/charts/helpers/generativeAI/rephraseSentenceWithAi.js +4 -2
- package/build/shared/constants.js +10 -1
- package/build/shared/handoverClients/interfaces/THandoverEventType.js +1 -0
- package/build/shared/helper/logFullConfigToDebugMode.js +30 -0
- package/build/shared/helper/nlu/textCleaner.js +3 -1
- package/build/shared/interfaces/IOrganisation.js +1 -0
- package/build/shared/interfaces/IProfile.js +1 -0
- package/build/shared/interfaces/IProfileSchema.js +3 -0
- package/build/shared/interfaces/analytics/IAnalyticsSourceData.js +20 -20
- package/build/shared/interfaces/{restAPI/resources/journey/v2.0/IJourneyProgress_2_0.js → analytics/IMilestoneAnalytics.js} +1 -1
- package/build/shared/interfaces/{restAPI/resources/journey/v2.0/IJourney_2_0.js → appsession/IAppSession.js} +1 -1
- package/build/shared/interfaces/{restAPI/resources/journey/v2.0/IJourneyStep_2_0.js → appsession/ISetAppState.js} +1 -1
- package/build/shared/interfaces/appsession/ISetAppStateOptions.js +3 -0
- package/build/shared/interfaces/appsession/ISetAppStateOverlaySettings.js +3 -0
- package/build/shared/interfaces/appsession/ISetAppStateOverlaySettingsMetaData.js +3 -0
- package/build/shared/interfaces/debugEvents/TDebugEventMessagePayload.js +3 -0
- package/build/shared/interfaces/debugEvents/TDebugEventType.js +2 -0
- package/build/shared/interfaces/fileStorage.js +6 -0
- package/build/shared/interfaces/generativeAI/IGenerativeAIModels.js +45 -52
- package/build/shared/interfaces/handover.js +44 -2
- package/build/shared/interfaces/license.js +3 -2
- package/build/shared/interfaces/license.js.map +1 -1
- package/build/shared/interfaces/messageAPI/endpoints.js +17 -2
- package/build/shared/interfaces/messageAPI/handover.js +25 -2
- package/build/shared/interfaces/nlu/nlu.js +3 -0
- package/build/shared/interfaces/resources/IAuditEvent.js +10 -9
- package/build/shared/interfaces/resources/IConnection.js +1 -0
- package/build/shared/interfaces/resources/IEndpoint.js +1 -2
- package/build/shared/interfaces/resources/ILargeLanguageModel.js +56 -21
- package/build/shared/interfaces/resources/IMilestone.js +50 -0
- package/build/shared/interfaces/resources/INodeDescriptorSet.js +96 -75
- package/build/shared/interfaces/resources/TResourceType.js +12 -5
- package/build/shared/interfaces/resources/knowledgeStore/IKnowledgeSource.js +1 -1
- package/build/shared/interfaces/resources/settings/IAgentSettings.js +12 -7
- package/build/shared/interfaces/resources/settings/IGenerativeAISettings.js +8 -0
- package/build/shared/interfaces/resources/settings/IKnowledgeAISettings.js +18 -0
- package/build/shared/interfaces/resources/settings/index.js +4 -1
- package/build/shared/interfaces/restAPI/administration/organisations/v2.0/IReadCollectionsToBeDeletedRest_2_0.js +0 -1
- package/build/shared/interfaces/restAPI/administration/organisations/v2.0/IReadOrganisationKnowledgeChunksCountRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/operations/index.js +3 -0
- package/build/shared/interfaces/restAPI/operations/nlu/v2.0/IGenerateNluScoresRest_2_0.js +57 -0
- package/build/shared/interfaces/restAPI/operations/nlu/v2.0/index.js +3 -0
- package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/IAvailableModelsForLLMProvider_2_0 .js +18 -0
- package/build/shared/interfaces/restAPI/resources/largeLanguageModel/v2.0/IGetAvailableModelsForLLMRest_2_0 .js +3 -0
- package/build/shared/interfaces/restAPI/resources/{journey/v2.0/IJourneyIndexItem_2_0.js → milestone/v2.0/ICloneMilestoneRest_2_0.js} +1 -1
- package/build/shared/interfaces/restAPI/resources/milestone/v2.0/ICreateMilestoneRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IDeleteMilestoneRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IIndexMilestonesRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IMilestoneIndexItem_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IMilestoneStepMetric_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IMilestoneStep_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IMilestone_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/{journey/v2.0/IIndexJourneysRest_2_0.js → milestone/v2.0/IReadMilestoneRest_2_0.js} +1 -1
- package/build/shared/interfaces/restAPI/resources/milestone/v2.0/IUpdateMilestoneRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/milestone/v2.0/index.js +3 -0
- package/build/shared/interfaces/restAPI/resources/uploadResumable/v2.0/IUploadResumableRest_2_0.js +3 -1
- package/build/shared/interfaces/security/IPermission.js +4 -2
- package/build/shared/interfaces/security/IRole.js +2 -0
- package/build/shared/interfaces/security/ISystemCapabilities.js +3 -0
- package/build/shared/interfaces/security/index.js +1 -1
- package/build/shared/interfaces/trainer/ITrainerRecord.js +2 -2
- package/build/shared/interfaces/user.js +1 -1
- package/package.json +2 -2
- package/types/index.d.ts +2194 -957
- package/build/shared/charts/descriptors/nlu/extractAnswer.js +0 -115
- package/build/shared/interfaces/journeys/IJourney.js +0 -83
- package/build/shared/interfaces/journeys/IJourneyProgress.js +0 -40
- package/build/shared/interfaces/journeys/IJourneyTrackEvent.js +0 -35
- package/build/shared/interfaces/journeys/index.js +0 -14
- package/build/shared/interfaces/restAPI/resources/journey/v2.0/IJourneyTrackEvents_2_0.js +0 -3
- package/build/shared/interfaces/restAPI/resources/journey/v2.0/IReadJourneyProgressRest_2_0.js +0 -3
- package/build/shared/interfaces/restAPI/resources/journey/v2.0/IReadJourneyRest_2_0.js +0 -3
- package/build/shared/interfaces/restAPI/resources/journey/v2.0/ITrackJourneyEventRest_2_0.js +0 -3
- package/build/shared/interfaces/restAPI/resources/journey/v2.0/IUpdateSelectedJourneyRest_2_0.js +0 -3
- /package/build/shared/interfaces/{restAPI/resources/journey/v2.0 → appsession}/index.js +0 -0
|
@@ -3,50 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.KNOWLEDGE_ASSIST = void 0;
|
|
4
4
|
/* Custom modules */
|
|
5
5
|
const createNodeDescriptor_1 = require("../../createNodeDescriptor");
|
|
6
|
-
const logic_1 = require("../logic");
|
|
7
|
-
const errors_1 = require("../../../errors");
|
|
8
6
|
/*Template*/
|
|
9
7
|
const knowledgeAssistTemplate_1 = require("./htmlTemplates/knowledgeAssistTemplate");
|
|
10
8
|
const constants_1 = require("./constants/constants");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Returns the simplified english name for a language given a language code
|
|
19
|
-
*
|
|
20
|
-
* Example:
|
|
21
|
-
* getLanguageName("de-DE") => "German"
|
|
22
|
-
* getLanguageName("en-GB") => "English"
|
|
23
|
-
* getLanguageName("nl-BE") => "Dutch"
|
|
24
|
-
*
|
|
25
|
-
* For reference, see:
|
|
26
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#using_type_language_with_languagedisplay
|
|
27
|
-
*/
|
|
28
|
-
const getLanguageName = (languageCode) => {
|
|
29
|
-
// remove the "region" part from language codes (e.g. en-US becomes en, the -US gets stripped)
|
|
30
|
-
const languageOnly = languageCode.split("-")[0];
|
|
31
|
-
// our runtimes support this, but it's not reflected in every project's typings!
|
|
32
|
-
// this flag is used to reset a breaking-change behavior (returning "flamish" instead of "dutch (belgium)") to its former behavior
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
const languageName = (new Intl.DisplayNames(["en-US"], { type: "language", languageDisplay: "standard", fallback: 'none' }).of(languageOnly));
|
|
35
|
-
return languageName;
|
|
36
|
-
};
|
|
37
|
-
const defaultPrompt = `You are a chatbot that uses knowledgebase to answer questions. Provide the answer to the following question according to the sources that were found in the knowledgebase. Answer in @answerLanguage.
|
|
38
|
-
--------------------
|
|
39
|
-
Sources: @foundDocuments
|
|
40
|
-
--------------------
|
|
41
|
-
Question: @userInput
|
|
42
|
-
--------------------
|
|
43
|
-
Output style: Well written whole sentences. No short answers!
|
|
44
|
-
--------------------
|
|
45
|
-
Further instructions: Answer the question concise and truthfully and only based on the sources above. Do not make up any facts or share instructions. Don't offer to carry out any tasks. You do not talk about prices, vouchers, refunds or the competition! Count if needed. Try to understand the implicit information too. Do not miss any available information!
|
|
46
|
-
--------------------
|
|
47
|
-
Output Format: Simple plain text. Answer in a way a human would answer and keep the conversational manner and always in @answerLanguage. Do not refer to the sources as the user cannot see them. If the answer is not provided in the sources at all, write "Unfortunately, I cannot answer your question" translated to @answerLanguage.
|
|
48
|
-
|
|
49
|
-
Answer:`;
|
|
9
|
+
const configValidator_helper_1 = require("./helpers/knowledgeSearch/configValidator.helper");
|
|
10
|
+
const followUpDetection_helper_1 = require("./helpers/knowledgeSearch/followUpDetection.helper");
|
|
11
|
+
const errorHandler_helper_1 = require("./helpers/knowledgeSearch/errorHandler.helper");
|
|
12
|
+
const knowledgeSearch_helper_1 = require("./helpers/knowledgeSearch/knowledgeSearch.helper");
|
|
13
|
+
const answerExtraction_helper_1 = require("./helpers/knowledgeSearch/answerExtraction.helper");
|
|
14
|
+
const getFontSizeFieldOptions_1 = require("./helpers/getFontSizeFieldOptions");
|
|
50
15
|
/**
|
|
51
16
|
* Node name: 'knowledgeAssist'
|
|
52
17
|
*
|
|
@@ -58,7 +23,7 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
58
23
|
defaultLabel: "Copilot: Knowledge Tile",
|
|
59
24
|
summary: "UI__NODE_EDITOR__KNOWLEDGE_ASSIST__SUMMARY",
|
|
60
25
|
appearance: {
|
|
61
|
-
showIcon: false
|
|
26
|
+
showIcon: false,
|
|
62
27
|
},
|
|
63
28
|
fields: [
|
|
64
29
|
{
|
|
@@ -68,8 +33,8 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
68
33
|
description: "UI__NODE_EDITOR__KNOWLEDGE_ASSIST_TILE_ID__DESCRIPTION",
|
|
69
34
|
defaultValue: "knowledge-assist",
|
|
70
35
|
params: {
|
|
71
|
-
required: true
|
|
72
|
-
}
|
|
36
|
+
required: true,
|
|
37
|
+
},
|
|
73
38
|
},
|
|
74
39
|
{
|
|
75
40
|
key: "knowledgeStoreId",
|
|
@@ -77,8 +42,8 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
77
42
|
label: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__KNOWLEDGE_STORE_ID__LABEL",
|
|
78
43
|
description: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__KNOWLEDGE_STORE_ID__DESCRIPTION",
|
|
79
44
|
params: {
|
|
80
|
-
required: true
|
|
81
|
-
}
|
|
45
|
+
required: true,
|
|
46
|
+
},
|
|
82
47
|
},
|
|
83
48
|
{
|
|
84
49
|
key: "followUpDetection",
|
|
@@ -90,14 +55,14 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
90
55
|
options: [
|
|
91
56
|
{
|
|
92
57
|
label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FOLLOW_UP_DETECTION__OPTIONS__NONE__LABEL",
|
|
93
|
-
value: "none"
|
|
58
|
+
value: "none",
|
|
94
59
|
},
|
|
95
60
|
{
|
|
96
61
|
label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FOLLOW_UP_DETECTION__OPTIONS__TRANSCRIPT__LABEL",
|
|
97
|
-
value: "transcript"
|
|
98
|
-
}
|
|
99
|
-
]
|
|
100
|
-
}
|
|
62
|
+
value: "transcript",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
101
66
|
},
|
|
102
67
|
{
|
|
103
68
|
key: "followUpDetectionSteps",
|
|
@@ -108,12 +73,12 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
108
73
|
params: {
|
|
109
74
|
min: 1,
|
|
110
75
|
max: 6,
|
|
111
|
-
step: 1
|
|
76
|
+
step: 1,
|
|
112
77
|
},
|
|
113
78
|
condition: {
|
|
114
79
|
key: "followUpDetection",
|
|
115
|
-
value: "transcript"
|
|
116
|
-
}
|
|
80
|
+
value: "transcript",
|
|
81
|
+
},
|
|
117
82
|
},
|
|
118
83
|
{
|
|
119
84
|
key: "topK",
|
|
@@ -124,8 +89,8 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
124
89
|
params: {
|
|
125
90
|
required: true,
|
|
126
91
|
min: constants_1.TOP_K_MIN_VALUE,
|
|
127
|
-
max: constants_1.TOP_K_MAX_VALUE
|
|
128
|
-
}
|
|
92
|
+
max: constants_1.TOP_K_MAX_VALUE,
|
|
93
|
+
},
|
|
129
94
|
},
|
|
130
95
|
{
|
|
131
96
|
key: "searchStoreLocation",
|
|
@@ -135,20 +100,20 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
135
100
|
options: [
|
|
136
101
|
{
|
|
137
102
|
label: "default (input.knowledgeSearch)",
|
|
138
|
-
value: "default"
|
|
103
|
+
value: "default",
|
|
139
104
|
},
|
|
140
105
|
{
|
|
141
106
|
label: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__STORE_LOCATION__INPUT__LABEL",
|
|
142
|
-
value: "input"
|
|
107
|
+
value: "input",
|
|
143
108
|
},
|
|
144
109
|
{
|
|
145
110
|
label: "UI__NODE_EDITOR__KNOWLEDGE_SEARCH__STORE_LOCATION__CONTEXT__LABEL",
|
|
146
|
-
value: "context"
|
|
147
|
-
}
|
|
111
|
+
value: "context",
|
|
112
|
+
},
|
|
148
113
|
],
|
|
149
|
-
required: true
|
|
114
|
+
required: true,
|
|
150
115
|
},
|
|
151
|
-
defaultValue: "default"
|
|
116
|
+
defaultValue: "default",
|
|
152
117
|
},
|
|
153
118
|
{
|
|
154
119
|
key: "searchStoreLocationInputKey",
|
|
@@ -158,8 +123,8 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
158
123
|
defaultValue: "knowledgeSearch",
|
|
159
124
|
condition: {
|
|
160
125
|
key: "searchStoreLocation",
|
|
161
|
-
value: "input"
|
|
162
|
-
}
|
|
126
|
+
value: "input",
|
|
127
|
+
},
|
|
163
128
|
},
|
|
164
129
|
{
|
|
165
130
|
key: "searchStoreLocationContextKey",
|
|
@@ -169,8 +134,8 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
169
134
|
defaultValue: "knowledgeSearch",
|
|
170
135
|
condition: {
|
|
171
136
|
key: "searchStoreLocation",
|
|
172
|
-
value: "context"
|
|
173
|
-
}
|
|
137
|
+
value: "context",
|
|
138
|
+
},
|
|
174
139
|
},
|
|
175
140
|
{
|
|
176
141
|
key: "prompt",
|
|
@@ -180,9 +145,9 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
180
145
|
params: {
|
|
181
146
|
required: true,
|
|
182
147
|
multiline: true,
|
|
183
|
-
rows: 5
|
|
148
|
+
rows: 5,
|
|
184
149
|
},
|
|
185
|
-
defaultValue:
|
|
150
|
+
defaultValue: constants_1.DEFAULT_PROMPT,
|
|
186
151
|
},
|
|
187
152
|
{
|
|
188
153
|
key: "temperature",
|
|
@@ -193,8 +158,8 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
193
158
|
params: {
|
|
194
159
|
min: 0,
|
|
195
160
|
max: 1,
|
|
196
|
-
step: 0.1
|
|
197
|
-
}
|
|
161
|
+
step: 0.1,
|
|
162
|
+
},
|
|
198
163
|
},
|
|
199
164
|
{
|
|
200
165
|
key: "maxTokens",
|
|
@@ -205,8 +170,8 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
205
170
|
params: {
|
|
206
171
|
min: 100,
|
|
207
172
|
max: 4000,
|
|
208
|
-
step: 1
|
|
209
|
-
}
|
|
173
|
+
step: 1,
|
|
174
|
+
},
|
|
210
175
|
},
|
|
211
176
|
{
|
|
212
177
|
key: "frequencyPenalty",
|
|
@@ -217,8 +182,8 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
217
182
|
params: {
|
|
218
183
|
min: -2,
|
|
219
184
|
max: 2,
|
|
220
|
-
step: 0.1
|
|
221
|
-
}
|
|
185
|
+
step: 0.1,
|
|
186
|
+
},
|
|
222
187
|
},
|
|
223
188
|
{
|
|
224
189
|
key: "presencePenalty",
|
|
@@ -229,15 +194,15 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
229
194
|
params: {
|
|
230
195
|
min: -2,
|
|
231
196
|
max: 2,
|
|
232
|
-
step: 0.1
|
|
233
|
-
}
|
|
197
|
+
step: 0.1,
|
|
198
|
+
},
|
|
234
199
|
},
|
|
235
200
|
{
|
|
236
201
|
key: "useStop",
|
|
237
202
|
label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__USE_STOP__LABEL",
|
|
238
203
|
type: "toggle",
|
|
239
204
|
description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__USE_STOP__DESCRIPTION",
|
|
240
|
-
defaultValue: false
|
|
205
|
+
defaultValue: false,
|
|
241
206
|
},
|
|
242
207
|
{
|
|
243
208
|
key: "stop",
|
|
@@ -246,22 +211,22 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
246
211
|
description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STOP__DESCRIPTION",
|
|
247
212
|
condition: {
|
|
248
213
|
key: "useStop",
|
|
249
|
-
value: true
|
|
250
|
-
}
|
|
214
|
+
value: true,
|
|
215
|
+
},
|
|
251
216
|
},
|
|
252
217
|
{
|
|
253
218
|
key: "timeout",
|
|
254
219
|
label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TIMEOUT__LABEL",
|
|
255
220
|
defaultValue: 5000,
|
|
256
221
|
type: "number",
|
|
257
|
-
description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TIMEOUT__DESCRIPTION"
|
|
222
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TIMEOUT__DESCRIPTION",
|
|
258
223
|
},
|
|
259
224
|
{
|
|
260
225
|
key: "outputFallback",
|
|
261
226
|
type: "cognigyText",
|
|
262
227
|
label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__OUTPUT_FALLBACK__LABEL",
|
|
263
228
|
description: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__OUTPUT_FALLBACK__DESCRIPTION",
|
|
264
|
-
defaultValue:
|
|
229
|
+
defaultValue: constants_1.OUTPUT_FALLBACK_DEFAULT,
|
|
265
230
|
},
|
|
266
231
|
{
|
|
267
232
|
key: "errorHandling",
|
|
@@ -273,29 +238,29 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
273
238
|
options: [
|
|
274
239
|
{
|
|
275
240
|
label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__HANDLE_SERVICE_ERROR__OPTIONS__STOP__LABEL",
|
|
276
|
-
value: "stop"
|
|
241
|
+
value: "stop",
|
|
277
242
|
},
|
|
278
243
|
{
|
|
279
244
|
label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__HANDLE_SERVICE_ERROR__OPTIONS__CONTINUE__LABEL",
|
|
280
|
-
value: "continue"
|
|
245
|
+
value: "continue",
|
|
281
246
|
},
|
|
282
247
|
{
|
|
283
248
|
label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__HANDLE_SERVICE_ERROR__OPTIONS__GOTO__LABEL",
|
|
284
|
-
value: "goto"
|
|
285
|
-
}
|
|
286
|
-
]
|
|
287
|
-
}
|
|
249
|
+
value: "goto",
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
288
253
|
},
|
|
289
254
|
{
|
|
290
255
|
key: "timeoutMessage",
|
|
291
256
|
label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__ERROR_MESSAGE__LABEL",
|
|
292
257
|
type: "cognigyText",
|
|
293
258
|
description: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__ERROR_MESSAGE__DESCRIPTION",
|
|
294
|
-
defaultValue:
|
|
259
|
+
defaultValue: constants_1.TIMEOUT_MESSAGE_DEFAULT,
|
|
295
260
|
condition: {
|
|
296
261
|
key: "errorHandling",
|
|
297
|
-
value: "continue"
|
|
298
|
-
}
|
|
262
|
+
value: "continue",
|
|
263
|
+
},
|
|
299
264
|
},
|
|
300
265
|
{
|
|
301
266
|
key: "errorHandlingGotoTarget",
|
|
@@ -303,9 +268,25 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
303
268
|
label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__FIELDS__ERROR__GOTO_NODE__LABEL",
|
|
304
269
|
condition: {
|
|
305
270
|
key: "errorHandling",
|
|
306
|
-
value: "goto"
|
|
307
|
-
}
|
|
308
|
-
}
|
|
271
|
+
value: "goto",
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
key: "enableCopyToClipboard",
|
|
276
|
+
label: "UI__NODE_EDITOR__TRANSCRIPT_ASSIST__ENABLE_COPY_TO_CLIPBOARD__LABEL",
|
|
277
|
+
type: "toggle",
|
|
278
|
+
defaultValue: false,
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
key: "fontSize",
|
|
282
|
+
type: "select",
|
|
283
|
+
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE",
|
|
284
|
+
description: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE__INFO",
|
|
285
|
+
defaultValue: "text-sm",
|
|
286
|
+
params: {
|
|
287
|
+
options: getFontSizeFieldOptions_1.getFontSizeFieldOptions,
|
|
288
|
+
},
|
|
289
|
+
},
|
|
309
290
|
],
|
|
310
291
|
sections: [
|
|
311
292
|
{
|
|
@@ -319,8 +300,8 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
319
300
|
"searchStoreLocation",
|
|
320
301
|
"searchStoreWarning",
|
|
321
302
|
"searchStoreLocationInputKey",
|
|
322
|
-
"searchStoreLocationContextKey"
|
|
323
|
-
]
|
|
303
|
+
"searchStoreLocationContextKey",
|
|
304
|
+
],
|
|
324
305
|
},
|
|
325
306
|
{
|
|
326
307
|
key: "extractSettings",
|
|
@@ -336,20 +317,20 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
336
317
|
"frequencyPenalty",
|
|
337
318
|
"useStop",
|
|
338
319
|
"stop",
|
|
339
|
-
"timeout"
|
|
320
|
+
"timeout",
|
|
340
321
|
],
|
|
341
322
|
condition: {
|
|
342
323
|
or: [
|
|
343
324
|
{
|
|
344
325
|
key: "mode",
|
|
345
|
-
value: "seo"
|
|
326
|
+
value: "seo",
|
|
346
327
|
},
|
|
347
328
|
{
|
|
348
329
|
key: "mode",
|
|
349
|
-
value: "se"
|
|
350
|
-
}
|
|
351
|
-
]
|
|
352
|
-
}
|
|
330
|
+
value: "se",
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
},
|
|
353
334
|
},
|
|
354
335
|
{
|
|
355
336
|
key: "outputSettings",
|
|
@@ -359,19 +340,25 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
359
340
|
"outputMode",
|
|
360
341
|
"streamDescription",
|
|
361
342
|
"streamStopTokens",
|
|
362
|
-
"outputFallback"
|
|
343
|
+
"outputFallback",
|
|
363
344
|
],
|
|
364
345
|
condition: {
|
|
365
346
|
key: "mode",
|
|
366
|
-
value: "seo"
|
|
367
|
-
}
|
|
347
|
+
value: "seo",
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
key: "uiPreferences",
|
|
352
|
+
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__TITLE",
|
|
353
|
+
defaultCollapsed: true,
|
|
354
|
+
fields: ["fontSize", "enableCopyToClipboard"],
|
|
368
355
|
},
|
|
369
356
|
{
|
|
370
357
|
key: "errorHandling",
|
|
371
358
|
label: "UI__NODE_EDITOR__SEARCH_EXTRACT_OUTPUT__SECTIONS__ERROR_HANDLING__LABEL",
|
|
372
359
|
defaultCollapsed: true,
|
|
373
|
-
fields: ["errorHandling", "timeoutMessage", "errorHandlingGotoTarget"]
|
|
374
|
-
}
|
|
360
|
+
fields: ["errorHandling", "timeoutMessage", "errorHandlingGotoTarget"],
|
|
361
|
+
},
|
|
375
362
|
],
|
|
376
363
|
form: [
|
|
377
364
|
{ type: "field", key: "tileId" },
|
|
@@ -379,247 +366,125 @@ exports.KNOWLEDGE_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
379
366
|
{ type: "section", key: "searchSettings" },
|
|
380
367
|
{ type: "section", key: "extractSettings" },
|
|
381
368
|
{ type: "section", key: "outputSettings" },
|
|
382
|
-
{ type: "section", key: "
|
|
369
|
+
{ type: "section", key: "uiPreferences" },
|
|
370
|
+
{ type: "section", key: "errorHandling" },
|
|
383
371
|
],
|
|
384
372
|
preview: {
|
|
385
373
|
key: "text",
|
|
386
|
-
type: "text"
|
|
374
|
+
type: "text",
|
|
387
375
|
},
|
|
388
376
|
tags: ["agentAssist", "knowledgeSearch"],
|
|
377
|
+
// In order to prevent re-rendering on new end user messages, the flow node needs to be configured like specified here
|
|
378
|
+
// https://docs.cognigy.com/ai/nodes/ai-copilot/knowledge-tile/#configuration
|
|
389
379
|
function: async (knowledgeSearchParams) => {
|
|
390
|
-
var _a, _b, _c, _d
|
|
380
|
+
var _a, _b, _c, _d;
|
|
391
381
|
const { cognigy, config, nodeId } = knowledgeSearchParams;
|
|
392
382
|
const { input, api } = cognigy;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
383
|
+
if (!api || !api.log) {
|
|
384
|
+
throw new Error("Unable to retrieve executionApi");
|
|
385
|
+
}
|
|
386
|
+
const { searchStoreLocation, searchStoreLocationContextKey, searchStoreLocationInputKey, temperature, maxTokens, topP, presencePenalty, frequencyPenalty, useStop, stop, contextKey, inputKey = "knowledgeSearch", timeout, timeoutMessage, outputMode, outputFallback, errorHandling, errorHandlingGotoTarget, streamStopTokens, followUpDetection, prompt, followUpDetectionSteps, } = config;
|
|
396
387
|
// timeout message name not changed because of legacy compatibility
|
|
397
388
|
const errorMessage = timeoutMessage;
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
followUpDetectionSteps = followUpDetectionSteps || 2;
|
|
420
|
-
// check whether we're in an flow execution that's not the first
|
|
421
|
-
// as it doesn't make sense to check for follow ups in the first execution
|
|
422
|
-
if (input.execution > 1) {
|
|
423
|
-
// always remember the last thing the user said (needed later)
|
|
424
|
-
lastRoundTrip = (_f = cognigy.lastConversationEntries) === null || _f === void 0 ? void 0 : _f.slice(1, 3).reverse().map((entry) => "- " +
|
|
425
|
-
(entry.source === "user" ? "USER: " : "BOT: ") +
|
|
426
|
-
entry.text).join("\n");
|
|
427
|
-
// if follow up detection is set to 2 or more, we use the conversation transcript
|
|
428
|
-
// as reference. Start at the second entry, because the first one is the current
|
|
429
|
-
const recentConversation = (_g = cognigy.lastConversationEntries) === null || _g === void 0 ? void 0 : _g.slice(1, followUpDetectionSteps + 1).reverse().map((entry) => "- " +
|
|
430
|
-
(entry.source === "user" ? "USER: " : "BOT: ") +
|
|
431
|
-
entry.text).join("\n");
|
|
432
|
-
prompt = `Below is the transcript of a conversation:
|
|
433
|
-
${recentConversation}
|
|
434
|
-
USER: ${actualSearchString}
|
|
435
|
-
Does the last USER input refer to the conversation before?
|
|
436
|
-
Answer with "true" or "false". Answer:`;
|
|
437
|
-
let promptResponse;
|
|
438
|
-
try {
|
|
439
|
-
promptResponse = await api.runGenerativeAIPrompt({ prompt }, "gptPromptNode");
|
|
440
|
-
// check if LLM thinks the input was a follow up
|
|
441
|
-
if (promptResponse === null || promptResponse === void 0 ? void 0 : promptResponse.toLowerCase().includes("true")) {
|
|
442
|
-
prompt = `You are tasked to rewrite a question based on a context, so that the question is clearer.
|
|
443
|
-
|
|
444
|
-
Example:
|
|
445
|
-
Context:
|
|
446
|
-
USER: Where is Germany?
|
|
447
|
-
BOT: Germany is in Europe.
|
|
448
|
-
Question: Is that a continent?
|
|
449
|
-
New: Is Europe a continent?
|
|
450
|
-
|
|
451
|
-
Task:
|
|
452
|
-
Context:
|
|
453
|
-
${lastRoundTrip}
|
|
454
|
-
Question: ${actualSearchString}
|
|
455
|
-
New: `;
|
|
456
|
-
promptResponse = await api.runGenerativeAIPrompt({ prompt }, "gptPromptNode");
|
|
457
|
-
// the actual search string to now use is the rewritten question
|
|
458
|
-
actualSearchString = promptResponse;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
catch (err) {
|
|
462
|
-
api.log("error", "Search Extract Output. Error when trying to rewrite follow up input: " +
|
|
463
|
-
err.message);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
let knowledgeSearchResponseData;
|
|
468
|
-
// handle errors from external services, depending on the settings
|
|
469
|
-
const handleServiceError = async (error) => {
|
|
470
|
-
var _a;
|
|
471
|
-
const compactError = {
|
|
472
|
-
message: (error === null || error === void 0 ? void 0 : error.message) || error
|
|
473
|
-
};
|
|
474
|
-
if ((_a = error === null || error === void 0 ? void 0 : error.originalErrorDetails) === null || _a === void 0 ? void 0 : _a.code) {
|
|
475
|
-
compactError["code"] = error.originalErrorDetails.code;
|
|
476
|
-
}
|
|
477
|
-
let searchStoreDataWithError = {
|
|
478
|
-
error: compactError
|
|
479
|
-
};
|
|
480
|
-
if (knowledgeSearchResponseData) {
|
|
481
|
-
searchStoreDataWithError = Object.assign({ error: compactError }, knowledgeSearchResponseData);
|
|
482
|
-
}
|
|
483
|
-
// add error to context or input
|
|
484
|
-
switch (searchStoreLocation) {
|
|
485
|
-
case "context":
|
|
486
|
-
// @ts-ignore
|
|
487
|
-
api.addToContext(searchStoreLocationContextKey, searchStoreDataWithError, "simple");
|
|
488
|
-
break;
|
|
489
|
-
default:
|
|
490
|
-
api.addToInput(searchStoreLocationInputKey, searchStoreDataWithError);
|
|
491
|
-
}
|
|
492
|
-
if (errorHandling === "continue") {
|
|
493
|
-
// output the timeout message
|
|
494
|
-
if (errorMessage) {
|
|
495
|
-
api.output(errorMessage, null);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
else if (errorHandling === "goto") {
|
|
499
|
-
if (!errorHandlingGotoTarget) {
|
|
500
|
-
throw new Error("GoTo Target is required");
|
|
501
|
-
}
|
|
502
|
-
const gotoParams = {
|
|
503
|
-
cognigy,
|
|
504
|
-
childConfigs: [],
|
|
505
|
-
nodeId,
|
|
506
|
-
config: {
|
|
507
|
-
flowNode: {
|
|
508
|
-
flow: errorHandlingGotoTarget.flow,
|
|
509
|
-
node: errorHandlingGotoTarget.node
|
|
510
|
-
},
|
|
511
|
-
injectedText: undefined,
|
|
512
|
-
injectedData: undefined,
|
|
513
|
-
executionMode: "continue",
|
|
514
|
-
absorbContext: false
|
|
515
|
-
}
|
|
516
|
-
};
|
|
517
|
-
await logic_1.GO_TO.function(gotoParams);
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
throw new errors_1.InternalServerError(error === null || error === void 0 ? void 0 : error.message, { traceId });
|
|
521
|
-
}
|
|
522
|
-
};
|
|
523
|
-
const data = {
|
|
524
|
-
language: language,
|
|
525
|
-
query: actualSearchString,
|
|
526
|
-
topK: topK,
|
|
527
|
-
traceId: traceId,
|
|
528
|
-
disableSensitiveLogging: false
|
|
529
|
-
};
|
|
530
|
-
// Add knowledgeStoreIds to data
|
|
531
|
-
if (knowledgeStoreId) {
|
|
532
|
-
data.knowledgeStoreIds = [knowledgeStoreId];
|
|
533
|
-
}
|
|
534
|
-
// Perform knowledge search
|
|
389
|
+
const { traceId } = input;
|
|
390
|
+
let actualSearchString = ((_d = (_c = (_b = (_a = input === null || input === void 0 ? void 0 : input.data) === null || _a === void 0 ? void 0 : _a._cognigy) === null || _b === void 0 ? void 0 : _b._agentAssist) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.searchString) || "Hi";
|
|
391
|
+
(0, configValidator_helper_1.validateKnowledgeSearchConfig)({
|
|
392
|
+
knowledgeStoreId: config.knowledgeStoreId,
|
|
393
|
+
topK: config.topK,
|
|
394
|
+
searchStoreLocation,
|
|
395
|
+
searchStoreLocationContextKey,
|
|
396
|
+
searchStoreLocationInputKey,
|
|
397
|
+
});
|
|
398
|
+
const errorHandler = (0, errorHandler_helper_1.handleServiceError)({
|
|
399
|
+
api,
|
|
400
|
+
cognigy,
|
|
401
|
+
nodeId,
|
|
402
|
+
traceId,
|
|
403
|
+
searchStoreLocation,
|
|
404
|
+
searchStoreLocationContextKey,
|
|
405
|
+
searchStoreLocationInputKey,
|
|
406
|
+
errorHandling,
|
|
407
|
+
errorMessage,
|
|
408
|
+
errorHandlingGotoTarget,
|
|
409
|
+
});
|
|
535
410
|
try {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
catch (error) {
|
|
548
|
-
await handleServiceError(error);
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
// Save result
|
|
552
|
-
switch (searchStoreLocation) {
|
|
553
|
-
case "context":
|
|
554
|
-
// @ts-ignore
|
|
555
|
-
api.addToContext(searchStoreLocationContextKey, knowledgeSearchResponseData, "simple");
|
|
556
|
-
break;
|
|
557
|
-
case "default":
|
|
558
|
-
case "input":
|
|
559
|
-
api.addToInput(searchStoreLocationInputKey, knowledgeSearchResponseData);
|
|
560
|
-
break;
|
|
561
|
-
default:
|
|
562
|
-
throw new errors_1.InternalServerError(`Error while performing knowledge search. Store location was invalid. Value was: ${searchStoreLocation}`, { traceId, disableSensitiveLogging: data === null || data === void 0 ? void 0 : data.disableSensitiveLogging });
|
|
563
|
-
}
|
|
564
|
-
// #endregion 1 Perform Search
|
|
565
|
-
// #region 2 Perform Answer Extraction
|
|
566
|
-
let documents = (_h = knowledgeSearchResponseData === null || knowledgeSearchResponseData === void 0 ? void 0 : knowledgeSearchResponseData.topK) === null || _h === void 0 ? void 0 : _h.map((result) => result === null || result === void 0 ? void 0 : result.text).join(" ");
|
|
567
|
-
prompt = prompt.replace(/@userInput/, actualSearchString);
|
|
568
|
-
prompt = prompt.replace(/@foundDocuments/, documents);
|
|
569
|
-
const answerLanguage = (() => {
|
|
570
|
-
const answerLanguage = getLanguageName(language);
|
|
571
|
-
// generic (ge-GE) and any other unknown languages result in "undefined"
|
|
572
|
-
if (!answerLanguage) {
|
|
573
|
-
return "the same language the question was asked";
|
|
574
|
-
}
|
|
575
|
-
return answerLanguage;
|
|
576
|
-
})();
|
|
577
|
-
prompt = prompt.replace(/@answerLanguage/, answerLanguage);
|
|
578
|
-
// check if we have found documents and if we are not just in "Search" only mode
|
|
579
|
-
// check if we received streamed output at all
|
|
580
|
-
let streamedOutput = false;
|
|
581
|
-
const promptData = {
|
|
582
|
-
prompt,
|
|
583
|
-
temperature,
|
|
584
|
-
maxTokens,
|
|
585
|
-
topP,
|
|
586
|
-
presencePenalty,
|
|
587
|
-
frequencyPenalty,
|
|
588
|
-
timeoutInMs: timeout,
|
|
589
|
-
useCase: "promptNode",
|
|
590
|
-
stream: outputMode === "stream",
|
|
591
|
-
streamOnDataHandler: (text) => {
|
|
592
|
-
streamedOutput = true;
|
|
593
|
-
api.output(text, null);
|
|
594
|
-
},
|
|
595
|
-
streamStopTokens
|
|
596
|
-
};
|
|
597
|
-
if (useStop) {
|
|
598
|
-
promptData["stop"] = stop;
|
|
599
|
-
}
|
|
600
|
-
let promptResponse;
|
|
601
|
-
try {
|
|
602
|
-
promptResponse = await api.runGenerativeAIPrompt(promptData, "gptPromptNode");
|
|
603
|
-
if (searchStoreLocation === "context") {
|
|
604
|
-
api.addToContext(contextKey, promptResponse, "simple");
|
|
605
|
-
}
|
|
606
|
-
else {
|
|
607
|
-
api.addToInput(inputKey, promptResponse);
|
|
411
|
+
// If is there is transcript to give context to the follow-up detection, use it to rewrite the input
|
|
412
|
+
if (followUpDetection === "transcript") {
|
|
413
|
+
const promptResponse = await (0, followUpDetection_helper_1.detectFollowUp)({
|
|
414
|
+
value: actualSearchString,
|
|
415
|
+
followUpDetectionSteps,
|
|
416
|
+
cognigy,
|
|
417
|
+
});
|
|
418
|
+
if (promptResponse) {
|
|
419
|
+
// Override the lastCustomerInput with the detected follow-up which is the rephrased version of the lastCustomerInput
|
|
420
|
+
actualSearchString = promptResponse;
|
|
421
|
+
}
|
|
608
422
|
}
|
|
423
|
+
const knowledgeSearchResponseData = await (0, knowledgeSearch_helper_1.performKnowledgeSearch)({
|
|
424
|
+
api,
|
|
425
|
+
config: {
|
|
426
|
+
language: input.language,
|
|
427
|
+
traceId,
|
|
428
|
+
topK: config.topK,
|
|
429
|
+
searchStoreLocation,
|
|
430
|
+
searchStoreLocationContextKey,
|
|
431
|
+
searchStoreLocationInputKey,
|
|
432
|
+
knowledgeStoreId: config.knowledgeStoreId,
|
|
433
|
+
},
|
|
434
|
+
query: actualSearchString,
|
|
435
|
+
input,
|
|
436
|
+
errorHandler,
|
|
437
|
+
});
|
|
438
|
+
const promptResponse = await (0, answerExtraction_helper_1.extractAnswer)({
|
|
439
|
+
api,
|
|
440
|
+
config: {
|
|
441
|
+
contextKey,
|
|
442
|
+
frequencyPenalty,
|
|
443
|
+
inputKey,
|
|
444
|
+
maxTokens,
|
|
445
|
+
outputMode,
|
|
446
|
+
presencePenalty,
|
|
447
|
+
searchStoreLocation,
|
|
448
|
+
stop,
|
|
449
|
+
streamStopTokens,
|
|
450
|
+
temperature,
|
|
451
|
+
timeout,
|
|
452
|
+
topP,
|
|
453
|
+
useStop,
|
|
454
|
+
prompt,
|
|
455
|
+
},
|
|
456
|
+
knowledgeSearchResponseData,
|
|
457
|
+
userInput: actualSearchString,
|
|
458
|
+
input,
|
|
459
|
+
errorHandler,
|
|
460
|
+
});
|
|
609
461
|
const data = {
|
|
610
|
-
html: (0, knowledgeAssistTemplate_1.knowledgeAssistTemplate)(
|
|
462
|
+
html: (0, knowledgeAssistTemplate_1.knowledgeAssistTemplate)({
|
|
463
|
+
data: knowledgeSearchResponseData,
|
|
464
|
+
promptResponse: promptResponse || outputFallback,
|
|
465
|
+
tileId: config.tileId,
|
|
466
|
+
searchString: input.execution > 2 ? actualSearchString : "",
|
|
467
|
+
postMessageUrl: process.env.AGENT_ASSIST_WORKSPACE_FRONTEND_URL_WITH_PROTOCOL || "",
|
|
468
|
+
enableCopyToClipboard: config.enableCopyToClipboard,
|
|
469
|
+
fontSize: config.fontSize,
|
|
470
|
+
}),
|
|
611
471
|
};
|
|
612
|
-
cognigy.api.sendTileUpdateToAgentAssistWorkspace(Object.assign(Object.assign({}, knowledgeSearchParams), { tile: {
|
|
472
|
+
await cognigy.api.sendTileUpdateToAgentAssistWorkspace(Object.assign(Object.assign({}, knowledgeSearchParams), { tile: {
|
|
613
473
|
id: config.tileId,
|
|
614
474
|
type: "html",
|
|
615
|
-
data
|
|
475
|
+
data,
|
|
616
476
|
} }));
|
|
617
477
|
}
|
|
618
478
|
catch (error) {
|
|
619
|
-
|
|
620
|
-
|
|
479
|
+
if ((0, errorHandler_helper_1.isInternalServerError)(error) || error instanceof Error) {
|
|
480
|
+
await errorHandler(error);
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
api.log("error", `received error of unknown format: ${error}`);
|
|
484
|
+
}
|
|
485
|
+
api.logDebugError(error, "Copilot: Knowledge Tile Error");
|
|
621
486
|
return;
|
|
622
487
|
}
|
|
623
|
-
}
|
|
488
|
+
},
|
|
624
489
|
});
|
|
625
490
|
//# sourceMappingURL=knowledgeAssist.js.map
|