@cognigy/rest-api-client 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/build/GenericTusFn.js +6 -1
- package/build/GenericUploadFn.js +3 -5
- package/build/apigroups/ResourcesAPIGroup_2_0.js +12 -1
- 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/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 +87 -14
- 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 +485 -10
- package/build/shared/charts/descriptors/agentAssist/sentimentAssist.js +31 -8
- package/build/shared/charts/descriptors/agentAssist/transcriptAssist.js +40 -2
- package/build/shared/charts/descriptors/analytics/requestRating.js +56 -2
- package/build/shared/charts/descriptors/index.js +1 -3
- package/build/shared/charts/descriptors/knowledgeSearch/searchExtractOutput.js +1 -1
- package/build/shared/charts/descriptors/message/question/optionalQuestion.js +1 -1
- package/build/shared/charts/descriptors/message/question/question.js +123 -2
- package/build/shared/charts/descriptors/message/question/utils/evaluateQuestionAnswer.js +44 -3
- package/build/shared/charts/descriptors/nlu/generativeSlotFiller/prompt.js +28 -12
- package/build/shared/charts/descriptors/nlu/index.js +1 -3
- package/build/shared/charts/descriptors/service/GPTPrompt.js +320 -22
- package/build/shared/charts/descriptors/service/LLMEntityExtract.js +274 -0
- package/build/shared/charts/descriptors/service/httpRequest.js +33 -1
- package/build/shared/charts/descriptors/service/index.js +3 -1
- package/build/shared/charts/descriptors/voice/mappers/setSessionConfig.mapper.js +17 -13
- package/build/shared/charts/descriptors/voice/mappers/transfer.mapper.js +4 -4
- package/build/shared/charts/descriptors/voice/nodes/play.js +8 -1
- package/build/shared/charts/descriptors/voice/nodes/sessionSpeechParameters.js +44 -45
- package/build/shared/charts/descriptors/voicegateway2/nodes/play.js +0 -1
- package/build/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +31 -39
- package/build/shared/charts/descriptors/voicegateway2/nodes/transfer.js +17 -25
- package/build/shared/charts/helpers/generativeAI/generativeAIPrompts.js +55 -0
- package/build/shared/interfaces/appsession/IAppSession.js +3 -0
- package/build/shared/interfaces/appsession/ISetAppState.js +3 -0
- package/build/shared/interfaces/appsession/index.js +3 -0
- package/build/shared/interfaces/fileStorage.js +6 -0
- package/build/shared/interfaces/generativeAI/IGenerativeAIModels.js +32 -3
- package/build/shared/interfaces/handover.js +2 -1
- package/build/shared/interfaces/messageAPI/endpoints.js +15 -2
- package/build/shared/interfaces/messageAPI/handover.js +5 -1
- package/build/shared/interfaces/nlu/nlu.js +3 -0
- package/build/shared/interfaces/resources/IAuditEvent.js +10 -9
- package/build/shared/interfaces/resources/ILargeLanguageModel.js +34 -20
- package/build/shared/interfaces/resources/IMilestone.js +50 -0
- package/build/shared/interfaces/resources/INodeDescriptorSet.js +84 -75
- package/build/shared/interfaces/resources/TResourceType.js +12 -5
- package/build/shared/interfaces/resources/settings/IGenerativeAISettings.js +4 -0
- package/build/shared/interfaces/restAPI/resources/milestone/v2.0/ICloneMilestoneRest_2_0.js +3 -0
- 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/milestone/v2.0/IReadMilestoneRest_2_0.js +3 -0
- 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/index.js +1 -1
- package/package.json +2 -2
- package/types/index.d.ts +938 -285
- package/build/shared/charts/descriptors/nlu/extractAnswer.js +0 -115
|
@@ -8,6 +8,7 @@ const sentimentAnalysisTemplate_1 = require("./htmlTemplates/sentimentAnalysisTe
|
|
|
8
8
|
const prompt_1 = require("../nlu/generativeSlotFiller/prompt");
|
|
9
9
|
const constants_1 = require("./constants/constants");
|
|
10
10
|
const sentiment_helper_1 = require("./helpers/sentiment.helper");
|
|
11
|
+
const getFontSizeFieldOptions_1 = require("./helpers/getFontSizeFieldOptions");
|
|
11
12
|
/**
|
|
12
13
|
* Node name: "sentimentAssist"
|
|
13
14
|
*
|
|
@@ -39,24 +40,42 @@ exports.SENTIMENT_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
39
40
|
options: [
|
|
40
41
|
{
|
|
41
42
|
label: "UI__NODE_EDITOR__SENTIMENT_ASSIST__FIELDS__SENTIMENT_ANALYSIS_INPUT__OPTIONS__LAST_INPUT__LABEL",
|
|
42
|
-
value: "lastInput"
|
|
43
|
+
value: "lastInput",
|
|
43
44
|
},
|
|
44
45
|
{
|
|
45
46
|
label: "UI__NODE_EDITOR__SENTIMENT_ASSIST__FIELDS__SENTIMENT_ANALYSIS_INPUT__OPTIONS__LAST_TEN_INPUTS__LABEL",
|
|
46
|
-
value: "lastTenInputs"
|
|
47
|
+
value: "lastTenInputs",
|
|
47
48
|
},
|
|
48
|
-
]
|
|
49
|
-
}
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
key: "fontSize",
|
|
54
|
+
type: "select",
|
|
55
|
+
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE",
|
|
56
|
+
description: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE__INFO",
|
|
57
|
+
defaultValue: "text-sm",
|
|
58
|
+
params: {
|
|
59
|
+
options: getFontSizeFieldOptions_1.getFontSizeFieldOptions,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
sections: [
|
|
64
|
+
{
|
|
65
|
+
key: "uiPreferences",
|
|
66
|
+
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__TITLE",
|
|
67
|
+
defaultCollapsed: true,
|
|
68
|
+
fields: ["fontSize"],
|
|
50
69
|
},
|
|
51
70
|
],
|
|
52
|
-
sections: [],
|
|
53
71
|
form: [
|
|
54
72
|
{ type: "field", key: "tileId" },
|
|
55
73
|
{ type: "field", key: "sentimentAnalysisInput" },
|
|
74
|
+
{ type: "section", key: "uiPreferences" },
|
|
56
75
|
].filter((element) => !!element),
|
|
57
76
|
function: async (params) => {
|
|
58
77
|
const { cognigy, config } = params;
|
|
59
|
-
const { api } = cognigy;
|
|
78
|
+
const { api, input } = cognigy;
|
|
60
79
|
const sentimentSelection = config.sentimentAnalysisInput;
|
|
61
80
|
try {
|
|
62
81
|
let prompt = "";
|
|
@@ -70,7 +89,11 @@ exports.SENTIMENT_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
70
89
|
}
|
|
71
90
|
const sentiment = await (0, sentiment_helper_1.sentimentAnalysis)(api, prompt);
|
|
72
91
|
const data = {
|
|
73
|
-
html: (0, sentimentAnalysisTemplate_1.default)(
|
|
92
|
+
html: (0, sentimentAnalysisTemplate_1.default)({
|
|
93
|
+
sentiment,
|
|
94
|
+
fontSize: config.fontSize,
|
|
95
|
+
input,
|
|
96
|
+
}),
|
|
74
97
|
};
|
|
75
98
|
cognigy.api.sendTileUpdateToAgentAssistWorkspace(Object.assign(Object.assign({}, params), { tile: {
|
|
76
99
|
id: config.tileId,
|
|
@@ -81,6 +104,6 @@ exports.SENTIMENT_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
81
104
|
catch (err) {
|
|
82
105
|
api.log("error", err);
|
|
83
106
|
}
|
|
84
|
-
}
|
|
107
|
+
},
|
|
85
108
|
});
|
|
86
109
|
//# sourceMappingURL=sentimentAssist.js.map
|
|
@@ -6,6 +6,7 @@ const createNodeDescriptor_1 = require("../../createNodeDescriptor");
|
|
|
6
6
|
const transcriptAssistTemplate_1 = require("./htmlTemplates/transcriptAssistTemplate");
|
|
7
7
|
const constants_1 = require("./constants/constants");
|
|
8
8
|
const sentiment_helper_1 = require("./helpers/sentiment.helper");
|
|
9
|
+
const getFontSizeFieldOptions_1 = require("./helpers/getFontSizeFieldOptions");
|
|
9
10
|
/**
|
|
10
11
|
* Node name: "transcriptAssist"
|
|
11
12
|
*
|
|
@@ -37,11 +38,39 @@ exports.TRANSCRIPT_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
37
38
|
type: "toggle",
|
|
38
39
|
defaultValue: false,
|
|
39
40
|
},
|
|
41
|
+
{
|
|
42
|
+
key: "fontSize",
|
|
43
|
+
type: "select",
|
|
44
|
+
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE",
|
|
45
|
+
description: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE__INFO",
|
|
46
|
+
defaultValue: "text-sm",
|
|
47
|
+
params: {
|
|
48
|
+
options: getFontSizeFieldOptions_1.getFontSizeFieldOptions,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: "messageFontSize",
|
|
53
|
+
type: "select",
|
|
54
|
+
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE",
|
|
55
|
+
description: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__FONT_SIZE__INFO",
|
|
56
|
+
defaultValue: "text-sm",
|
|
57
|
+
params: {
|
|
58
|
+
options: getFontSizeFieldOptions_1.getFontSizeFieldOptions,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
sections: [
|
|
63
|
+
{
|
|
64
|
+
key: "uiPreferences",
|
|
65
|
+
label: "UI__NODE_EDITOR__COPILOT__TILE_UI_PREFERENCES__TITLE",
|
|
66
|
+
defaultCollapsed: true,
|
|
67
|
+
fields: ["fontSize", "messageFontSize"],
|
|
68
|
+
},
|
|
40
69
|
],
|
|
41
|
-
sections: [],
|
|
42
70
|
form: [
|
|
43
71
|
{ type: "field", key: "tileId" },
|
|
44
72
|
{ type: "field", key: "enableSentiment" },
|
|
73
|
+
{ type: "section", key: "uiPreferences" },
|
|
45
74
|
].filter((element) => !!element),
|
|
46
75
|
function: async (params) => {
|
|
47
76
|
const { cognigy, config } = params;
|
|
@@ -50,12 +79,21 @@ exports.TRANSCRIPT_ASSIST = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
50
79
|
let sentiment;
|
|
51
80
|
try {
|
|
52
81
|
const inputText = cognigy.input.text;
|
|
82
|
+
if (!inputText) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
53
85
|
if (sentimentEnabled) {
|
|
54
86
|
const prompt = `${constants_1.LAST_INPUT_PROMPT} ${inputText}`;
|
|
55
87
|
sentiment = await (0, sentiment_helper_1.sentimentAnalysis)(api, prompt);
|
|
56
88
|
}
|
|
57
89
|
const data = {
|
|
58
|
-
html: (0, transcriptAssistTemplate_1.default)(
|
|
90
|
+
html: (0, transcriptAssistTemplate_1.default)({
|
|
91
|
+
message: inputText,
|
|
92
|
+
assetsBaseURL: process.env.AGENT_ASSIST_WORKSPACE_FRONTEND_URL_WITH_PROTOCOL || "",
|
|
93
|
+
sentiment,
|
|
94
|
+
fontSize: config.fontSize,
|
|
95
|
+
messageFontSize: config.messageFontSize
|
|
96
|
+
}),
|
|
59
97
|
};
|
|
60
98
|
cognigy.api.sendTileUpdateToAgentAssistWorkspace(Object.assign(Object.assign({}, params), { tile: {
|
|
61
99
|
id: config.tileId,
|
|
@@ -21,37 +21,91 @@ exports.REQUEST_RATING = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
21
21
|
type: "text",
|
|
22
22
|
},
|
|
23
23
|
fields: [
|
|
24
|
+
{
|
|
25
|
+
key: "ratingScreenTitleText",
|
|
26
|
+
type: "cognigyText",
|
|
27
|
+
label: "UI__NODE_EDITOR__REQUEST_RATING__RATING_SCREEN_TITLE_TEXT__LABEL",
|
|
28
|
+
description: "UI__NODE_EDITOR__REQUEST_RATING__RATING_SCREEN_TITLE_TEXT__DESCRIPTION",
|
|
29
|
+
params: {
|
|
30
|
+
placeholder: "UI__NODE_EDITOR__REQUEST_RATING__RATING_SCREEN_TITLE_TEXT__PLACEHOLDER",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
24
33
|
{
|
|
25
34
|
key: "ratingTitleText",
|
|
26
35
|
type: "cognigyText",
|
|
27
36
|
label: "UI__NODE_EDITOR__REQUEST_RATING__RATING_TITLE_TEXT__LABEL",
|
|
28
37
|
description: "UI__NODE_EDITOR__REQUEST_RATING__RATING_TITLE_TEXT__DESCRIPTION",
|
|
38
|
+
params: {
|
|
39
|
+
placeholder: "UI__NODE_EDITOR__REQUEST_RATING__RATING_TITLE_TEXT__PLACEHOLDER",
|
|
40
|
+
},
|
|
29
41
|
},
|
|
30
42
|
{
|
|
31
43
|
key: "ratingCommentText",
|
|
32
44
|
type: "cognigyText",
|
|
33
45
|
label: "UI__NODE_EDITOR__REQUEST_RATING__RATING_COMMENT_TEXT__LABEL",
|
|
34
46
|
description: "UI__NODE_EDITOR__REQUEST_RATING__RATING_COMMENT_TEXT__DESCRIPTION",
|
|
47
|
+
params: {
|
|
48
|
+
placeholder: "UI__NODE_EDITOR__REQUEST_RATING__RATING_COMMENT_TEXT__PLACEHOLDER",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: "ratingSubmitButtonText",
|
|
53
|
+
type: "cognigyText",
|
|
54
|
+
label: "UI__NODE_EDITOR__REQUEST_RATING__RATING_SUBMIT_BUTTON_TEXT__LABEL",
|
|
55
|
+
description: "UI__NODE_EDITOR__REQUEST_RATING__RATING_SUBMIT_BUTTON_TEXT__DESCRIPTION",
|
|
56
|
+
params: {
|
|
57
|
+
placeholder: "UI__NODE_EDITOR__REQUEST_RATING__RATING_SUBMIT_BUTTON_TEXT__PLACEHOLDER",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: "ratingEventBannerText",
|
|
62
|
+
type: "cognigyText",
|
|
63
|
+
label: "UI__NODE_EDITOR__REQUEST_RATING__RATING_EVENT_BANNER_TEXT__LABEL",
|
|
64
|
+
description: "UI__NODE_EDITOR__REQUEST_RATING__RATING_EVENT_BANNER_TEXT__DESCRIPTION",
|
|
65
|
+
params: {
|
|
66
|
+
placeholder: "UI__NODE_EDITOR__REQUEST_RATING__RATING_EVENT_BANNER_TEXT__PLACEHOLDER",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: "ratingChatStatusMessage",
|
|
71
|
+
type: "cognigyText",
|
|
72
|
+
label: "UI__NODE_EDITOR__REQUEST_RATING__RATING_STATUS_MESSAGE__LABEL",
|
|
73
|
+
description: "UI__NODE_EDITOR__REQUEST_RATING__RATING_STATUS_MESSAGE__DESCRIPTION",
|
|
74
|
+
params: {
|
|
75
|
+
placeholder: "UI__NODE_EDITOR__REQUEST_RATING__RATING_STATUS_MESSAGE__PLACEHOLDER",
|
|
76
|
+
},
|
|
35
77
|
},
|
|
36
78
|
],
|
|
37
79
|
form: [
|
|
80
|
+
{ type: "field", key: "ratingScreenTitleText" },
|
|
38
81
|
{ type: "field", key: "ratingTitleText" },
|
|
39
82
|
{ type: "field", key: "ratingCommentText" },
|
|
83
|
+
{ type: "field", key: "ratingSubmitButtonText" },
|
|
84
|
+
{ type: "field", key: "ratingEventBannerText" },
|
|
85
|
+
{ type: "field", key: "ratingChatStatusMessage" },
|
|
40
86
|
],
|
|
41
|
-
tags: ["analytics", "rating"
|
|
87
|
+
tags: ["analytics", "rating"],
|
|
42
88
|
function: async ({ cognigy, config }) => {
|
|
43
89
|
const { api } = cognigy;
|
|
90
|
+
const ratingScreenTitleText = config.ratingScreenTitleText;
|
|
44
91
|
const ratingTitleText = config.ratingTitleText;
|
|
45
92
|
const ratingCommentText = config.ratingCommentText;
|
|
93
|
+
const ratingSubmitButtonText = config.ratingSubmitButtonText;
|
|
94
|
+
const ratingEventBannerText = config.ratingEventBannerText;
|
|
95
|
+
const ratingChatStatusMessage = config.ratingChatStatusMessage;
|
|
46
96
|
api.say("", {
|
|
47
97
|
_plugin: {
|
|
48
98
|
type: "request-rating",
|
|
49
99
|
data: {
|
|
100
|
+
ratingScreenTitleText,
|
|
50
101
|
ratingTitleText,
|
|
51
102
|
ratingCommentText,
|
|
103
|
+
ratingSubmitButtonText,
|
|
104
|
+
ratingEventBannerText,
|
|
105
|
+
ratingChatStatusMessage,
|
|
52
106
|
},
|
|
53
107
|
},
|
|
54
108
|
});
|
|
55
|
-
}
|
|
109
|
+
},
|
|
56
110
|
});
|
|
57
111
|
//# sourceMappingURL=requestRating.js.map
|
|
@@ -90,6 +90,7 @@ const nodes = [
|
|
|
90
90
|
service_1.GPT_PROMPT,
|
|
91
91
|
service_1.GPT_CONVERSATION,
|
|
92
92
|
service_1.GPT_CONVERSATION_SUMMARY,
|
|
93
|
+
service_1.LLM_ENTITY_EXTRACT,
|
|
93
94
|
service_1.TRIGGER_FUNCTION,
|
|
94
95
|
service_1.ON_SCHEDULED,
|
|
95
96
|
service_1.ON_SCHEDULING_ERROR,
|
|
@@ -131,9 +132,6 @@ if (process.env.FEATURE_USE_COGNIGY_LIVE_AGENT === "true") {
|
|
|
131
132
|
if (process.env.FEATURE_DISABLE_INSIGHTS !== "true") {
|
|
132
133
|
nodes.push(analytics_1.SET_RATING, analytics_1.REQUEST_RATING);
|
|
133
134
|
}
|
|
134
|
-
if (process.env.FEATURE_ENABLE_EXTRACT_ANSWER === "true") {
|
|
135
|
-
nodes.push(nlu_1.EXTRACT_ANSWER);
|
|
136
|
-
}
|
|
137
135
|
exports.cognigyBasicModule = (0, createNodeDescriptor_1.createExtension)({
|
|
138
136
|
nodes,
|
|
139
137
|
connections: [
|
|
@@ -738,7 +738,7 @@ New: `;
|
|
|
738
738
|
frequencyPenalty,
|
|
739
739
|
timeoutInMs: timeout,
|
|
740
740
|
useCase: "promptNode",
|
|
741
|
-
stream: outputMode === "stream",
|
|
741
|
+
stream: outputMode === "stream" && mode === "seo",
|
|
742
742
|
streamOnDataHandler: (text) => {
|
|
743
743
|
streamedOutput = true;
|
|
744
744
|
api.output(text, null);
|
|
@@ -346,7 +346,7 @@ exports.OPTIONAL_QUESTION = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
346
346
|
}
|
|
347
347
|
return;
|
|
348
348
|
}
|
|
349
|
-
const result = (0, evaluateQuestionAnswer_1.evaluateQuestionAnswer)({ cognigy, config });
|
|
349
|
+
const result = await (0, evaluateQuestionAnswer_1.evaluateQuestionAnswer)({ cognigy, config });
|
|
350
350
|
if (storeResultInContext && contextKey) {
|
|
351
351
|
// check whether contextKey is a deep query and set
|
|
352
352
|
// context storage location accordingly
|
|
@@ -78,6 +78,7 @@ var QuestionTypes;
|
|
|
78
78
|
QuestionTypes[QuestionTypes["ipv4"] = 20] = "ipv4";
|
|
79
79
|
QuestionTypes[QuestionTypes["creditcard"] = 21] = "creditcard";
|
|
80
80
|
QuestionTypes[QuestionTypes["phonenumber"] = 22] = "phonenumber";
|
|
81
|
+
QuestionTypes[QuestionTypes["llm_entity"] = 23] = "llm_entity";
|
|
81
82
|
})(QuestionTypes = exports.QuestionTypes || (exports.QuestionTypes = {}));
|
|
82
83
|
//#endregion Interfaces
|
|
83
84
|
exports.QUESTION = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
@@ -156,6 +157,10 @@ exports.QUESTION = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
156
157
|
label: "UI__NODE_EDITOR__MESSAGE__QUESTION__QUESTION__FIELDS_TYPE_OPTIONS__REGEX__LABEL",
|
|
157
158
|
value: "regex",
|
|
158
159
|
},
|
|
160
|
+
{
|
|
161
|
+
label: "UI__NODE_EDITOR__MESSAGE__QUESTION__QUESTION__FIELDS_TYPE_OPTIONS__LLM_ENTITY__LABEL",
|
|
162
|
+
value: "llm_entity"
|
|
163
|
+
},
|
|
159
164
|
{
|
|
160
165
|
label: "UI__NODE_EDITOR__MESSAGE__QUESTION__QUESTION__FIELDS_TYPE_OPTIONS__DATA__LABEL",
|
|
161
166
|
value: "data",
|
|
@@ -1370,6 +1375,97 @@ DO NOT talk about other topics. Do not offer general assistance.`,
|
|
|
1370
1375
|
value: "reconfirm"
|
|
1371
1376
|
}
|
|
1372
1377
|
},
|
|
1378
|
+
{
|
|
1379
|
+
key: "llmEntityExtractLLMProviderReferenceId",
|
|
1380
|
+
type: "llmSelect",
|
|
1381
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__LLM_SELECT__LABEL",
|
|
1382
|
+
defaultValue: "default",
|
|
1383
|
+
params: {
|
|
1384
|
+
required: true
|
|
1385
|
+
},
|
|
1386
|
+
condition: {
|
|
1387
|
+
key: "type",
|
|
1388
|
+
value: "llm_entity"
|
|
1389
|
+
}
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
key: "entityName",
|
|
1393
|
+
type: "cognigyText",
|
|
1394
|
+
label: "UI__NODE_EDITOR__SERVICE__LLM_ENTITY_EXTRACT__FIELDS__ENTITY_NAME__LABEL",
|
|
1395
|
+
description: "UI__NODE_EDITOR__SERVICE__LLM_ENTITY_EXTRACT__FIELDS__ENTITY_NAME__DESCRIPTION",
|
|
1396
|
+
defaultValue: "customerID",
|
|
1397
|
+
params: {
|
|
1398
|
+
required: true
|
|
1399
|
+
},
|
|
1400
|
+
condition: {
|
|
1401
|
+
key: "type",
|
|
1402
|
+
value: "llm_entity"
|
|
1403
|
+
}
|
|
1404
|
+
},
|
|
1405
|
+
{
|
|
1406
|
+
key: "examples",
|
|
1407
|
+
type: "keyValuePairs",
|
|
1408
|
+
label: "UI__NODE_EDITOR__SERVICE__LLM_ENTITY_EXTRACT__FIELDS__EXAMPLES__LABEL",
|
|
1409
|
+
description: "UI__NODE_EDITOR__SERVICE__LLM_ENTITY_EXTRACT__FIELDS__EXAMPLES__DESCRIPTION",
|
|
1410
|
+
defaultValue: {
|
|
1411
|
+
"My ID is AB54EE, is that ok?": "AB54EE",
|
|
1412
|
+
"That would be ah bee see double 4 three": "ABC443",
|
|
1413
|
+
"I guess it's 49 A B 8 K": "49AB8K"
|
|
1414
|
+
},
|
|
1415
|
+
params: {
|
|
1416
|
+
keyLabel: "UI__NODE_EDITOR__SERVICE__LLM_ENTITY_EXTRACT__FIELDS__EXAMPLES__INPUT__KEY__LABEL",
|
|
1417
|
+
valueLabel: "UI__NODE_EDITOR__SERVICE__LLM_ENTITY_EXTRACT__FIELDS__EXAMPLES__INPUT__VALUE__LABEL"
|
|
1418
|
+
},
|
|
1419
|
+
condition: {
|
|
1420
|
+
key: "type",
|
|
1421
|
+
value: "llm_entity"
|
|
1422
|
+
}
|
|
1423
|
+
},
|
|
1424
|
+
{
|
|
1425
|
+
key: "entityDescription",
|
|
1426
|
+
type: "cognigyText",
|
|
1427
|
+
label: "UI__NODE_EDITOR__SERVICE__LLM_ENTITY_EXTRACT__FIELDS__ENTITY_DESCRIPTION__LABEL",
|
|
1428
|
+
description: "UI__NODE_EDITOR__SERVICE__LLM_ENTITY_EXTRACT__FIELDS__ENTITY_DESCRIPTION__DESCRIPTION",
|
|
1429
|
+
defaultValue: "a customer ID, which has 6 alphanumeric characters (e.g. ABC123).",
|
|
1430
|
+
params: {
|
|
1431
|
+
required: true
|
|
1432
|
+
},
|
|
1433
|
+
condition: {
|
|
1434
|
+
key: "type",
|
|
1435
|
+
value: "llm_entity"
|
|
1436
|
+
}
|
|
1437
|
+
},
|
|
1438
|
+
{
|
|
1439
|
+
key: "llmEntityExtractDescription",
|
|
1440
|
+
type: "description",
|
|
1441
|
+
label: " ",
|
|
1442
|
+
params: {
|
|
1443
|
+
text: "UI__NODE_EDITOR__SERVICE__LLM_ENTITY_EXTRACT__FIELDS__DESCRIPTION__TEXT",
|
|
1444
|
+
},
|
|
1445
|
+
condition: {
|
|
1446
|
+
key: "type",
|
|
1447
|
+
value: "llm_entity"
|
|
1448
|
+
}
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
key: "llmentityTemperature",
|
|
1452
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TEMPERATURE__LABEL",
|
|
1453
|
+
type: "slider",
|
|
1454
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TEMPERATURE__DESCRIPTION",
|
|
1455
|
+
defaultValue: 0.7,
|
|
1456
|
+
params: {
|
|
1457
|
+
min: 0,
|
|
1458
|
+
max: 1,
|
|
1459
|
+
step: 0.1
|
|
1460
|
+
}
|
|
1461
|
+
},
|
|
1462
|
+
{
|
|
1463
|
+
key: "llmentityTimeout",
|
|
1464
|
+
label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TIMEOUT__LABEL",
|
|
1465
|
+
defaultValue: 5000,
|
|
1466
|
+
type: "number",
|
|
1467
|
+
description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TIMEOUT__DESCRIPTION",
|
|
1468
|
+
},
|
|
1373
1469
|
...(0, datepickerUtils_1.getDatePickerFields)({
|
|
1374
1470
|
"key": "type",
|
|
1375
1471
|
"value": "date"
|
|
@@ -1653,6 +1749,24 @@ DO NOT talk about other topics. Do not offer general assistance.`,
|
|
|
1653
1749
|
"cleanTextLocale"
|
|
1654
1750
|
],
|
|
1655
1751
|
},
|
|
1752
|
+
{
|
|
1753
|
+
key: "llmEntityExtractOptions",
|
|
1754
|
+
label: "UI__NODE_EDITOR__MESSAGE__QUESTION__QUESTION__SECTIONS__LLM_ENTITY_EXTRACT_OPTIONS__LABEL",
|
|
1755
|
+
defaultCollapsed: true,
|
|
1756
|
+
fields: [
|
|
1757
|
+
"llmEntityExtractLLMProviderReferenceId",
|
|
1758
|
+
"entityName",
|
|
1759
|
+
"entityDescription",
|
|
1760
|
+
"examples",
|
|
1761
|
+
"additionalValidation",
|
|
1762
|
+
"llmentityTemperature",
|
|
1763
|
+
"llmentityTimeout"
|
|
1764
|
+
],
|
|
1765
|
+
condition: {
|
|
1766
|
+
key: "type",
|
|
1767
|
+
value: "llm_entity"
|
|
1768
|
+
},
|
|
1769
|
+
},
|
|
1656
1770
|
...(0, datepickerUtils_1.getDatePickerSections)("Datepicker - ", {
|
|
1657
1771
|
"key": "type",
|
|
1658
1772
|
"value": "date"
|
|
@@ -1661,10 +1775,12 @@ DO NOT talk about other topics. Do not offer general assistance.`,
|
|
|
1661
1775
|
].filter(section => !!section),
|
|
1662
1776
|
form: [
|
|
1663
1777
|
{ type: "field", key: "type" },
|
|
1778
|
+
{ type: "field", key: "llmEntityExtractDescription" },
|
|
1664
1779
|
{ type: "field", key: "keyphraseTag" },
|
|
1665
1780
|
{ type: "field", key: "usePositiveOnly" },
|
|
1666
1781
|
{ type: "field", key: "regex" },
|
|
1667
1782
|
{ type: "field", key: "say" },
|
|
1783
|
+
{ type: "section", key: "llmEntityExtractOptions" },
|
|
1668
1784
|
{ type: "section", key: "context" },
|
|
1669
1785
|
{ type: "section", key: "reprompt" },
|
|
1670
1786
|
{ type: "section", key: "reconfirmation" },
|
|
@@ -1753,9 +1869,14 @@ DO NOT talk about other topics. Do not offer general assistance.`,
|
|
|
1753
1869
|
}
|
|
1754
1870
|
// if we're in a subsequent execution or we want to parse results
|
|
1755
1871
|
// immediately on entry, continue with evaluation
|
|
1756
|
-
let result = (0, evaluateQuestionAnswer_1.evaluateQuestionAnswer)({ cognigy, config }, overwriteAnswer);
|
|
1872
|
+
let result = await (0, evaluateQuestionAnswer_1.evaluateQuestionAnswer)({ cognigy, config }, overwriteAnswer);
|
|
1873
|
+
// set input.result, so we can use it for validation
|
|
1874
|
+
input.result = result;
|
|
1757
1875
|
// Verify that answer is valid based on some other conditions defined in the function
|
|
1758
1876
|
const isValid = (0, validateQuestionAnswer_1.validateQuestionAnswer)(cognigy, config);
|
|
1877
|
+
if (!isValid) {
|
|
1878
|
+
input.result = null;
|
|
1879
|
+
}
|
|
1759
1880
|
// compute how often this node was hit
|
|
1760
1881
|
const executionAmount = api.getExecutionAmount(nodeId);
|
|
1761
1882
|
// compute how long ago this node was hit
|
|
@@ -1792,7 +1913,7 @@ DO NOT talk about other topics. Do not offer general assistance.`,
|
|
|
1792
1913
|
// #region 0 CheckIfReconfirmationInProgress
|
|
1793
1914
|
if (api.getSystemContext("reconfirmationQuestionInProgress")) {
|
|
1794
1915
|
// if this is the case, we are now a YN question
|
|
1795
|
-
let res = (0, evaluateQuestionAnswer_1.evaluateQuestionAnswer)({
|
|
1916
|
+
let res = await (0, evaluateQuestionAnswer_1.evaluateQuestionAnswer)({
|
|
1796
1917
|
cognigy, config: {
|
|
1797
1918
|
"type": "yesNo"
|
|
1798
1919
|
}
|
|
@@ -3,12 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.evaluateQuestionAnswer = void 0;
|
|
4
4
|
/* Custom modules */
|
|
5
5
|
const getQuestionText_1 = require("./getQuestionText");
|
|
6
|
+
const generativeAIPrompts_1 = require("../../../../helpers/generativeAI/generativeAIPrompts");
|
|
7
|
+
const prompt_1 = require("../../../nlu/generativeSlotFiller/prompt");
|
|
6
8
|
/**
|
|
7
9
|
* Evaluates the answer of a question against its type
|
|
8
10
|
*/
|
|
9
|
-
function evaluateQuestionAnswer({ cognigy, config }, overwriteAnswer) {
|
|
10
|
-
var _a, _b, _c, _d, _e;
|
|
11
|
-
const { type,
|
|
11
|
+
async function evaluateQuestionAnswer({ cognigy, config }, overwriteAnswer) {
|
|
12
|
+
var _a, _b, _c, _d, _e, _f;
|
|
13
|
+
const { type, keyphraseTag, usePositiveOnly, regex: regexField, storeDetailedResults,
|
|
14
|
+
// for LLM Extract functionality
|
|
15
|
+
entityName, entityDescription, examples, llmEntityExtractLLMProviderReferenceId } = config;
|
|
12
16
|
const { api, input } = cognigy;
|
|
13
17
|
const answer = overwriteAnswer || input;
|
|
14
18
|
let result;
|
|
@@ -106,6 +110,43 @@ function evaluateQuestionAnswer({ cognigy, config }, overwriteAnswer) {
|
|
|
106
110
|
case "phonenumber":
|
|
107
111
|
result = api.matchPattern(type, answer.text, input.language);
|
|
108
112
|
break;
|
|
113
|
+
case "llm_entity":
|
|
114
|
+
const prompt = (0, generativeAIPrompts_1.getLLMEntityExtractPrompt)(entityName, entityDescription, examples, answer.text);
|
|
115
|
+
const options = {
|
|
116
|
+
prompt,
|
|
117
|
+
temperature: (config === null || config === void 0 ? void 0 : config.llmentityTemperature) || 0.7,
|
|
118
|
+
maxTokens: 1000,
|
|
119
|
+
timeoutInMs: (config === null || config === void 0 ? void 0 : config.llmentityTimeout) || 5000,
|
|
120
|
+
useCase: "promptNode",
|
|
121
|
+
detailedResults: true
|
|
122
|
+
};
|
|
123
|
+
if (llmEntityExtractLLMProviderReferenceId && llmEntityExtractLLMProviderReferenceId !== "default") {
|
|
124
|
+
options["llmProviderReferenceId"] = llmEntityExtractLLMProviderReferenceId;
|
|
125
|
+
}
|
|
126
|
+
options["chat"] = (0, prompt_1.createLastConversationChatObject)(cognigy.lastConversationEntries, (0, generativeAIPrompts_1.getLLMEntityExtractSystemMessage)(entityName, entityDescription, examples), 5, true);
|
|
127
|
+
try {
|
|
128
|
+
const response = await api.runGenerativeAIPrompt(options, "gptPromptNode");
|
|
129
|
+
// find the entity in the response
|
|
130
|
+
result = (_f = response === null || response === void 0 ? void 0 : response.result) === null || _f === void 0 ? void 0 : _f[entityName];
|
|
131
|
+
if (!result) {
|
|
132
|
+
try {
|
|
133
|
+
result = JSON.parse(`{"${entityName}": ${response.result}`)[entityName];
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
try {
|
|
137
|
+
result = JSON.parse(response.result)[entityName];
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
result = null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
api.log("error", `Error in evaluation of Question Node type LLM Entity Extract. Error was: ${err.message}`);
|
|
147
|
+
result = null;
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
109
150
|
case "custom":
|
|
110
151
|
// the custom type is always true
|
|
111
152
|
result = true;
|
|
@@ -80,7 +80,7 @@ exports.createLastConverationString = createLastConverationString;
|
|
|
80
80
|
}
|
|
81
81
|
]
|
|
82
82
|
*/
|
|
83
|
-
const createLastConversationChatObject = (lastConversationEntries, systemMessage, turnLimit = 100) => {
|
|
83
|
+
const createLastConversationChatObject = (lastConversationEntries, systemMessage, turnLimit = 100, limitToOnlyUserMessages) => {
|
|
84
84
|
const conversation = [];
|
|
85
85
|
if (systemMessage) {
|
|
86
86
|
conversation.push({
|
|
@@ -88,16 +88,31 @@ const createLastConversationChatObject = (lastConversationEntries, systemMessage
|
|
|
88
88
|
content: systemMessage
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
if (limitToOnlyUserMessages) {
|
|
92
|
+
// limit the conversation entries to the last X messages with source user
|
|
93
|
+
lastConversationEntries === null || lastConversationEntries === void 0 ? void 0 : lastConversationEntries.filter(entry => entry.source === "user").slice(0, turnLimit).reverse().map(entry => {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
if ((_b = (_a = entry === null || entry === void 0 ? void 0 : entry.text) === null || _a === void 0 ? void 0 : _a.trim()) === null || _b === void 0 ? void 0 : _b.length) {
|
|
96
|
+
conversation.push({
|
|
97
|
+
role: "user",
|
|
98
|
+
content: entry.text.trim()
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
lastConversationEntries === null || lastConversationEntries === void 0 ? void 0 : lastConversationEntries.slice(0, turnLimit).reverse().map(entry => {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
// if text exists, add to conversation
|
|
107
|
+
// necessary to prevent data only messages from being added
|
|
108
|
+
if ((_b = (_a = entry === null || entry === void 0 ? void 0 : entry.text) === null || _a === void 0 ? void 0 : _a.trim()) === null || _b === void 0 ? void 0 : _b.length) {
|
|
109
|
+
conversation.push({
|
|
110
|
+
role: entry.source === "user" ? "user" : "assistant",
|
|
111
|
+
content: entry.text.trim()
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
101
116
|
return conversation;
|
|
102
117
|
};
|
|
103
118
|
exports.createLastConversationChatObject = createLastConversationChatObject;
|
|
@@ -132,7 +147,8 @@ const writeLLMDebugLogs = async (label, prompt, response, debugLogTokenCount, de
|
|
|
132
147
|
requestTokenMessage = ` (${requestTokens} Tokens)`;
|
|
133
148
|
}
|
|
134
149
|
if (response) {
|
|
135
|
-
const
|
|
150
|
+
const message = response.result || response;
|
|
151
|
+
const completionTokens = await api.countGPTTokens(message);
|
|
136
152
|
completionTokenMessage = ` (${completionTokens} Tokens)`;
|
|
137
153
|
}
|
|
138
154
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CLEAN_TEXT = exports.GENERATIVE_SLOT_FILLER_FALLBACK = exports.GENERATIVE_SLOT_FILLER_SUCCESS = exports.GENERATIVE_SLOT_FILLER = exports.FUZZY_SEARCH = exports.MATCH_PATTERN = exports.REGEX_SLOT_FILLER = exports.
|
|
3
|
+
exports.CLEAN_TEXT = exports.GENERATIVE_SLOT_FILLER_FALLBACK = exports.GENERATIVE_SLOT_FILLER_SUCCESS = exports.GENERATIVE_SLOT_FILLER = exports.FUZZY_SEARCH = exports.MATCH_PATTERN = exports.REGEX_SLOT_FILLER = exports.EXECUTE_COGNIGY_NLU = exports.ADD_LEXICON_KEYPHRASE = void 0;
|
|
4
4
|
var addLexiconKeyphrase_1 = require("./addLexiconKeyphrase");
|
|
5
5
|
Object.defineProperty(exports, "ADD_LEXICON_KEYPHRASE", { enumerable: true, get: function () { return addLexiconKeyphrase_1.ADD_LEXICON_KEYPHRASE; } });
|
|
6
6
|
var executeCognigyNLU_1 = require("./executeCognigyNLU");
|
|
7
7
|
Object.defineProperty(exports, "EXECUTE_COGNIGY_NLU", { enumerable: true, get: function () { return executeCognigyNLU_1.EXECUTE_COGNIGY_NLU; } });
|
|
8
|
-
var extractAnswer_1 = require("./extractAnswer");
|
|
9
|
-
Object.defineProperty(exports, "EXTRACT_ANSWER", { enumerable: true, get: function () { return extractAnswer_1.EXTRACT_ANSWER; } });
|
|
10
8
|
var regexSlotFiller_1 = require("./regexSlotFiller");
|
|
11
9
|
Object.defineProperty(exports, "REGEX_SLOT_FILLER", { enumerable: true, get: function () { return regexSlotFiller_1.REGEX_SLOT_FILLER; } });
|
|
12
10
|
var matchPattern_1 = require("./matchPattern");
|