@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sentimentAnalysis = void 0;
|
|
4
|
+
const sentimentList = ["Positive", "Neutral", "Negative"];
|
|
4
5
|
/**
|
|
5
6
|
* This method is used to analyze the sentiment based on the given prompt string.
|
|
6
7
|
* It returns either the detected sentiment or 'Neutral' if the sentiment could not be detected or was not clear.
|
|
@@ -9,18 +10,16 @@ exports.sentimentAnalysis = void 0;
|
|
|
9
10
|
* @param prompt The prompt to be analyzed
|
|
10
11
|
*/
|
|
11
12
|
const sentimentAnalysis = async (api, prompt) => {
|
|
12
|
-
|
|
13
|
+
var _a;
|
|
13
14
|
const payload = {
|
|
14
15
|
prompt,
|
|
15
16
|
useCase: "sentimentAnalysis",
|
|
16
17
|
};
|
|
17
|
-
const llmResponse = await api.runGenerativeAIPrompt(payload, "sentimentAnalysis");
|
|
18
|
-
//TODO: remove if the lookup works
|
|
19
|
-
api.log("info", `Sentiment: ${llmResponse}`);
|
|
18
|
+
const llmResponse = await ((_a = api.runGenerativeAIPrompt) === null || _a === void 0 ? void 0 : _a.call(api, payload, "sentimentAnalysis"));
|
|
20
19
|
if (llmResponse) {
|
|
21
|
-
|
|
20
|
+
return getSentiment(llmResponse);
|
|
22
21
|
}
|
|
23
|
-
return
|
|
22
|
+
return "";
|
|
24
23
|
};
|
|
25
24
|
exports.sentimentAnalysis = sentimentAnalysis;
|
|
26
25
|
/**
|
|
@@ -30,12 +29,7 @@ exports.sentimentAnalysis = sentimentAnalysis;
|
|
|
30
29
|
* @param text The text to be analyzed
|
|
31
30
|
*/
|
|
32
31
|
function getSentiment(text) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (text.includes(sentiment) || text.includes(sentiment.toLowerCase())) {
|
|
36
|
-
return sentiment;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return sentimentList[1];
|
|
32
|
+
var _a;
|
|
33
|
+
return (_a = sentimentList.find((sentiment) => text.toLowerCase().includes(sentiment.toLowerCase()))) !== null && _a !== void 0 ? _a : "Neutral";
|
|
40
34
|
}
|
|
41
35
|
//# sourceMappingURL=sentiment.helper.js.map
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const identityAssistTemplate = ({ widgetLayout = "horizontal", imageShape = "round", imageUrl, customer, customerData, }) => {
|
|
3
|
+
const identityAssistTemplate = ({ widgetLayout = "horizontal", imageShape = "round", imageUrl, customer, customerData, fontSize, profileFontSize, keyValueFontSize, showProfileImage, profileImageSize }) => {
|
|
4
4
|
const imageClass = imageShape === "round" ? "rounded-full" : "rounded-none";
|
|
5
5
|
let layoutClass = "";
|
|
6
6
|
let marginClass = "";
|
|
7
7
|
let textClass = "";
|
|
8
8
|
let imageHTML = "";
|
|
9
9
|
let customerDataHTML = "";
|
|
10
|
-
layoutClass +=
|
|
11
|
-
widgetLayout === "horizontal"
|
|
12
|
-
? ""
|
|
13
|
-
: "flex-col";
|
|
10
|
+
layoutClass += widgetLayout === "horizontal" ? "" : "flex-col";
|
|
14
11
|
marginClass = widgetLayout === "horizontal" ? "ml-2" : "";
|
|
15
12
|
imageHTML = `
|
|
16
|
-
<div class="mt-6 flex justify-center"
|
|
17
|
-
<img class="
|
|
13
|
+
<div class="mt-6 flex justify-center">
|
|
14
|
+
<img class="${profileImageSize} object-cover ${marginClass} ${imageClass}" src="${imageUrl || "https://cdn-icons-png.flaticon.com/512/149/149071.png"}" alt="User Avatar" />
|
|
18
15
|
</div>
|
|
19
16
|
`;
|
|
20
17
|
if (widgetLayout === "horizontal") {
|
|
21
18
|
textClass = "flex-grow";
|
|
22
19
|
}
|
|
23
20
|
for (const [key, value] of Object.entries(customerData)) {
|
|
24
|
-
customerDataHTML += `<p class="mt-1 text-gray-500">${key}: ${value}</p>`;
|
|
21
|
+
customerDataHTML += `<p class="mt-1 ${keyValueFontSize} text-gray-500">${key}: ${value}</p>`;
|
|
25
22
|
}
|
|
26
23
|
return `
|
|
27
24
|
<!DOCTYPE html>
|
|
@@ -34,18 +31,20 @@ const identityAssistTemplate = ({ widgetLayout = "horizontal", imageShape = "rou
|
|
|
34
31
|
</head>
|
|
35
32
|
<body>
|
|
36
33
|
<div class="flex h-screen items-center justify-center bg-gray-100">
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
<div class="h-full w-full rounded-lg bg-white shadow-md overflow-hidden">
|
|
35
|
+
<div class="flex h-full ${layoutClass}">
|
|
36
|
+
${showProfileImage ? imageHTML : ''}
|
|
37
|
+
<div class="mt-2 pl-4 pt-4 pb-4 flex flex-col h-full break-all overflow-hidden ${textClass}">
|
|
38
|
+
<div class="${fontSize} pl-4 font-semibold uppercase tracking-wide text-indigo-500">User Profile</div>
|
|
39
|
+
<div class="mt-2 pl-4 ${profileFontSize} font-semibold">
|
|
40
|
+
${customer}
|
|
41
|
+
</div>
|
|
42
|
+
<div class="flex-grow overflow-auto p-4 h-full break-words">
|
|
43
|
+
${customerDataHTML}
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
45
46
|
</div>
|
|
46
47
|
</div>
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
48
|
</div>
|
|
50
49
|
</body>
|
|
51
50
|
</html>`;
|
package/build/shared/charts/descriptors/agentAssist/htmlTemplates/knowledgeAssistTemplate.js
CHANGED
|
@@ -1,203 +1,380 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.knowledgeAssistTemplate = void 0;
|
|
4
|
-
const knowledgeAssistTemplate = (data, promptResponse, tileId, searchString) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</button>
|
|
23
|
-
</div>
|
|
24
|
-
${postbackScript(tileId)}
|
|
25
|
-
<div class="text-sm mt-5 tracking-wide text-indigo-500">${searchString}</div>
|
|
26
|
-
${renderResults(data, promptResponse)}
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
</body>
|
|
30
|
-
</html>
|
|
31
|
-
`;
|
|
32
|
-
};
|
|
33
|
-
exports.knowledgeAssistTemplate = knowledgeAssistTemplate;
|
|
34
|
-
const renderResults = (data, promptResponse) => {
|
|
35
|
-
let currentResultIndex = 0;
|
|
36
|
-
const navigate = (direction) => {
|
|
37
|
-
var _a, _b, _c, _d;
|
|
38
|
-
currentResultIndex = currentResultIndex + direction;
|
|
39
|
-
if (((_a = data === null || data === void 0 ? void 0 : data.topK) === null || _a === void 0 ? void 0 : _a.length) && currentResultIndex >= ((_b = data === null || data === void 0 ? void 0 : data.topK) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
40
|
-
currentResultIndex = 0;
|
|
4
|
+
const knowledgeAssistTemplate = ({ data, promptResponse, tileId, searchString, postMessageUrl, enableCopyToClipboard, fontSize, }) => `
|
|
5
|
+
<!doctype html>
|
|
6
|
+
<html lang="en" class="h-full">
|
|
7
|
+
<head>
|
|
8
|
+
<meta charset="UTF-8" />
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
10
|
+
<title>Search Knowledge Base</title>
|
|
11
|
+
<link
|
|
12
|
+
rel="stylesheet"
|
|
13
|
+
href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css"
|
|
14
|
+
/>
|
|
15
|
+
<style>
|
|
16
|
+
.min-w-20 {
|
|
17
|
+
min-width: 5rem
|
|
18
|
+
}
|
|
19
|
+
@keyframes blinkGreen {
|
|
20
|
+
50% {
|
|
21
|
+
background-color: #10b981;
|
|
41
22
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.blink-green {
|
|
26
|
+
animation: blinkGreen 0.5s ease-in-out;
|
|
27
|
+
}
|
|
28
|
+
.knowledgeContainer {
|
|
29
|
+
display: grid;
|
|
30
|
+
grid-auto-rows: 1fr;
|
|
31
|
+
grid-template-columns: 1fr;
|
|
32
|
+
grid-template-rows: 0.5fr 2fr 0.5fr;
|
|
33
|
+
grid-template-areas:
|
|
34
|
+
"search"
|
|
35
|
+
"content"
|
|
36
|
+
"footer";
|
|
37
|
+
}
|
|
38
|
+
.search { grid-area: search; }
|
|
39
|
+
.content {
|
|
40
|
+
grid-area: content;
|
|
41
|
+
overflow: auto;
|
|
42
|
+
}
|
|
43
|
+
.footer { grid-area: footer; }
|
|
44
|
+
</style>
|
|
45
|
+
${postbackScript(tileId, postMessageUrl, enableCopyToClipboard)}
|
|
46
|
+
</head>
|
|
47
|
+
<body class="h-full">
|
|
48
|
+
<div
|
|
49
|
+
class="h-full items-center bg-white rounded-xl shadow-md p-4 knowledgeContainer overflow-auto"
|
|
50
|
+
data-cognigy-copilot-tile-ka
|
|
51
|
+
data-cognigy-copilot-tile
|
|
52
|
+
>
|
|
53
|
+
<div class="flex flex-wrap items-center w-full h-auto search">
|
|
54
|
+
<div
|
|
55
|
+
class="${fontSize} font-semibold uppercase tracking-wide text-indigo-500"
|
|
56
|
+
>
|
|
57
|
+
Search
|
|
58
|
+
</div>
|
|
59
|
+
<div class="flex flex-grow rounded-md border ml-2 min-w-20">
|
|
60
|
+
<input
|
|
61
|
+
id="searchInput"
|
|
62
|
+
type="text"
|
|
63
|
+
class="w-full rounded-md p-2 focus:outline-none ${fontSize}"
|
|
64
|
+
placeholder="Search your knowledge base"
|
|
65
|
+
/>
|
|
55
66
|
<button
|
|
56
|
-
id="
|
|
57
|
-
|
|
58
|
-
class="hidden absolute bottom-0 right-0 flex items-center justify-center"
|
|
67
|
+
id="postbackButton"
|
|
68
|
+
class="flex items-center rounded-r-md px-4 py-2"
|
|
59
69
|
>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
>
|
|
66
|
-
<path
|
|
67
|
-
d="M 18.17 19.653 C 18.538 19.338 16.6 12.9 30.995 15.028 L 30.968 18.05 L 39.7 12.4 L 31.021 6.619 L 31.021 9.326 C 30.1 10.2 16.042 8.143 18.118 19.627"
|
|
68
|
-
fill="#0b3694"
|
|
69
|
-
transform="scale(-1, 1) translate(-50, 0)"
|
|
70
|
-
/>
|
|
71
|
-
</svg>
|
|
70
|
+
<img
|
|
71
|
+
src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5A6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5S14 7.01 14 9.5S11.99 14 9.5 14'/%3E%3C/svg%3E"
|
|
72
|
+
alt="Search Icon"
|
|
73
|
+
class="h-6 w-8 text-white"
|
|
74
|
+
/>
|
|
72
75
|
</button>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<div class="flex flex-col w-full h-full content overflow-auto">
|
|
80
|
+
<div class="${fontSize} mt-5 tracking-wide text-indigo-500">
|
|
81
|
+
${searchString}
|
|
82
|
+
</div>
|
|
83
|
+
${renderPrompt(promptResponse, fontSize)} ${renderSourceElements(data, fontSize)}
|
|
84
|
+
</div>
|
|
85
|
+
<div class="flex mt-auto justify-between w-full py-2 footer">
|
|
86
|
+
${renderButtons(enableCopyToClipboard, fontSize)}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</body>
|
|
90
|
+
</html>
|
|
91
|
+
`;
|
|
92
|
+
exports.knowledgeAssistTemplate = knowledgeAssistTemplate;
|
|
93
|
+
const renderPrompt = (promptResponse, fontSize) => `
|
|
94
|
+
<div class="flex-grow">
|
|
95
|
+
<div
|
|
96
|
+
id="resultContainer"
|
|
97
|
+
class="flex items-center justify-center mt-2 h-full"
|
|
98
|
+
>
|
|
99
|
+
<textarea
|
|
100
|
+
id="textArea"
|
|
101
|
+
class="w-full h-full rounded-md border p-2 ${fontSize} focus:outline-none"
|
|
102
|
+
placeholder="Your search results will be displayed here"
|
|
103
|
+
data-cognigy-content
|
|
104
|
+
>
|
|
105
|
+
${promptResponse}
|
|
106
|
+
</textarea>
|
|
107
|
+
<div
|
|
108
|
+
id="loader"
|
|
109
|
+
class="w-2 hidden h-30 rounded-full border-t-4 border-gray-300 border-solid animate-spin"
|
|
110
|
+
style="border-width: 16px; border-top-color: #3498db"
|
|
111
|
+
></div>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
`;
|
|
115
|
+
const renderSourceElements = (data, fontSize) => {
|
|
116
|
+
const result = data === null || data === void 0 ? void 0 : data.topK[0];
|
|
117
|
+
const hasSource = result === null || result === void 0 ? void 0 : result.sourceMetaData.sourceName;
|
|
118
|
+
return hasSource ? sourcesElements(fontSize, result === null || result === void 0 ? void 0 : result.sourceMetaData) : "";
|
|
79
119
|
};
|
|
120
|
+
const renderButtons = (enableCopyToClipboard, fontSize) => `
|
|
121
|
+
${enableCopyToClipboard
|
|
122
|
+
? `
|
|
123
|
+
<button
|
|
124
|
+
class="min-w-20 bg-blue-500 hover:bg-blue-700 text-white font-bold rounded focus:ring-4 focus:outline-none focus:ring-blue-300 ${fontSize} py-2 items-center inline-flex justify-center hidden"
|
|
125
|
+
data-cognigy-clipboard-button
|
|
126
|
+
disabled
|
|
127
|
+
>
|
|
128
|
+
<span class="default-message">Copy</span>
|
|
129
|
+
<span class="success-message hidden inline-flex items-center gap-1">
|
|
130
|
+
<svg
|
|
131
|
+
class="w-3 h-3 text-white me-1.5"
|
|
132
|
+
aria-hidden="true"
|
|
133
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
134
|
+
fill="none"
|
|
135
|
+
viewBox="0 0 16 12"
|
|
136
|
+
>
|
|
137
|
+
<path
|
|
138
|
+
stroke="currentColor"
|
|
139
|
+
stroke-linecap="round"
|
|
140
|
+
stroke-linejoin="round"
|
|
141
|
+
stroke-width="2"
|
|
142
|
+
d="M1 5.917 5.724 10.5 15 1.5"
|
|
143
|
+
/>
|
|
144
|
+
</svg>
|
|
145
|
+
Copied!
|
|
146
|
+
</span>
|
|
147
|
+
</button>
|
|
148
|
+
`
|
|
149
|
+
: "<div></div>"}
|
|
150
|
+
<button
|
|
151
|
+
id="liveAgentForwardButton"
|
|
152
|
+
class="hidden"
|
|
153
|
+
disabled
|
|
154
|
+
>
|
|
155
|
+
<svg
|
|
156
|
+
width="45px"
|
|
157
|
+
height="auto"
|
|
158
|
+
viewBox="0 0 45 35"
|
|
159
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
160
|
+
>
|
|
161
|
+
<path
|
|
162
|
+
d="M 18.17 19.653 C 18.538 19.338 16.6 12.9 30.995 15.028 L 30.968 18.05 L 39.7 12.4 L 31.021 6.619 L 31.021 9.326 C 30.1 10.2 16.042 8.143 18.118 19.627"
|
|
163
|
+
fill="#0b3694"
|
|
164
|
+
transform="scale(-1, 1) translate(-50, 0)"
|
|
165
|
+
/>
|
|
166
|
+
</svg>
|
|
167
|
+
</button>
|
|
168
|
+
`;
|
|
80
169
|
/**
|
|
81
170
|
* Helper function to dynamically render the sources section based on the data provided by the search.
|
|
82
171
|
*
|
|
83
172
|
* @param source
|
|
84
173
|
* @returns
|
|
85
174
|
*/
|
|
86
|
-
const sourcesElements = (source) => {
|
|
175
|
+
const sourcesElements = (fontSize, source) => {
|
|
87
176
|
var _a;
|
|
88
177
|
if (!source || !source.url) {
|
|
89
178
|
return "";
|
|
90
179
|
}
|
|
91
180
|
return `
|
|
92
181
|
<div class="mt-4">
|
|
93
|
-
<div class="
|
|
182
|
+
<div class="${fontSize} font-semibold uppercase tracking-wide text-indigo-500">Source</div>
|
|
94
183
|
<div class="mt-2">
|
|
95
184
|
<div class="flex flex-col flex-wrap gap-2">
|
|
96
|
-
<a href="${source.url}" target="_blank" class="text-indigo-500 hover:text-indigo-600">${(_a = source.title) !== null && _a !== void 0 ? _a : source.url}</a>
|
|
97
|
-
${source.sourceType
|
|
185
|
+
<a href="${source.url}" target="_blank" class="break-all text-indigo-500 ${fontSize} hover:text-indigo-600">${(_a = source.title) !== null && _a !== void 0 ? _a : source.url}</a>
|
|
186
|
+
${source.sourceType
|
|
187
|
+
? `<p class="${fontSize} break-all">${source.sourceType}</p>`
|
|
188
|
+
: ""}
|
|
98
189
|
</div>
|
|
99
190
|
</div>
|
|
100
191
|
</div>
|
|
101
192
|
`;
|
|
102
193
|
};
|
|
103
|
-
const postbackScript = (tileId) => `
|
|
194
|
+
const postbackScript = (tileId, postMessageUrl, enableCopyToClipboard) => `
|
|
104
195
|
<script>
|
|
196
|
+
(function () {
|
|
105
197
|
const u = (o) => ({ __INTER_FRAME_SOCKET_MESSAGE: !0, workspaceEvent: o }),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
198
|
+
h = (o, e) => ({ type: o, payload: e }),
|
|
199
|
+
w = (o) => {
|
|
200
|
+
var e;
|
|
201
|
+
return !!((e = o.data) != null && e.__INTER_FRAME_SOCKET_MESSAGE);
|
|
202
|
+
};
|
|
111
203
|
class b {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
204
|
+
constructor(e, a, d) {
|
|
205
|
+
(this.sourceWindow = e),
|
|
206
|
+
(this.targetWindow = a),
|
|
207
|
+
(this.targetOrigin = d),
|
|
208
|
+
(this.emit = (s, r) => {
|
|
209
|
+
const t = h(s, r),
|
|
210
|
+
i = u(t);
|
|
211
|
+
this.targetWindow.postMessage(i, this.targetOrigin);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
122
214
|
}
|
|
123
215
|
class c {
|
|
124
|
-
|
|
125
|
-
|
|
216
|
+
constructor() {
|
|
217
|
+
console.log(document.referrer ?? window.origin);
|
|
126
218
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
219
|
+
this.socket = new b(
|
|
220
|
+
window,
|
|
221
|
+
window.parent,
|
|
222
|
+
new URL(
|
|
223
|
+
document?.referrer ||
|
|
224
|
+
window?.origin ||
|
|
225
|
+
"https://agent-assist-dev.cognigy.ai",
|
|
226
|
+
).origin,
|
|
227
|
+
);
|
|
228
|
+
c.log("initialized");
|
|
229
|
+
return this; // Return this object.
|
|
230
|
+
}
|
|
231
|
+
postback(e) {
|
|
232
|
+
this.socket.emit("postback", e); // Send the postback event immediately.
|
|
233
|
+
return this; // Return this object for chaining.
|
|
234
|
+
}
|
|
235
|
+
static log(...e) {
|
|
236
|
+
console.log("[AgentAssistWorkspaceSDK]", ...e);
|
|
237
|
+
}
|
|
142
238
|
}
|
|
143
239
|
window.SDK = new c();
|
|
144
240
|
|
|
145
241
|
const triggerSearch = () => {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
242
|
+
const input = document.getElementById("searchInput").value;
|
|
243
|
+
const data = { searchString: input, tileId: "${tileId}" };
|
|
244
|
+
window.SDK.postback(data);
|
|
149
245
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
246
|
+
document.getElementById("searchInput").value = "";
|
|
247
|
+
document.getElementById("loader").style.display = "block";
|
|
248
|
+
document.getElementById("textArea").style.display = "none";
|
|
153
249
|
};
|
|
154
250
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
251
|
+
let showButton = false;
|
|
252
|
+
let showCopyButton = true;
|
|
253
|
+
|
|
254
|
+
function updateButtonVisibility() {
|
|
255
|
+
const elements = document.querySelectorAll(
|
|
256
|
+
"[data-cognigy-copilot-tile-ka]",
|
|
257
|
+
);
|
|
158
258
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
259
|
+
elements.forEach((element) => {
|
|
260
|
+
const button = element.querySelector("#liveAgentForwardButton");
|
|
261
|
+
if (button) {
|
|
262
|
+
button.className = showButton
|
|
263
|
+
? "justify-self-end col-start-8"
|
|
264
|
+
: "hidden";
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function updateCopyButtonVisibility() {
|
|
270
|
+
const elements = document.querySelectorAll(
|
|
271
|
+
"[data-cognigy-copilot-tile-ka]",
|
|
272
|
+
);
|
|
165
273
|
|
|
166
|
-
|
|
274
|
+
elements.forEach((element) => {
|
|
275
|
+
const button = element.querySelector("[data-cognigy-clipboard-button]");
|
|
276
|
+
if(!button) return;
|
|
277
|
+
|
|
278
|
+
if (showCopyButton) {
|
|
279
|
+
button.classList.remove("hidden");
|
|
280
|
+
} else {
|
|
281
|
+
button.classList.add("hidden");
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
167
285
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const resultContainer = document.getElementById("resultContainer");
|
|
286
|
+
window.addEventListener("message", (event) => {
|
|
287
|
+
const message = event.data;
|
|
171
288
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
289
|
+
if (message.type === "toggleButton") {
|
|
290
|
+
showButton = message.show;
|
|
291
|
+
updateButtonVisibility();
|
|
292
|
+
}
|
|
293
|
+
if (message.type === "toggleCopyButton") {
|
|
294
|
+
showCopyButton = message.show;
|
|
295
|
+
updateCopyButtonVisibility();
|
|
296
|
+
}
|
|
297
|
+
});
|
|
182
298
|
|
|
299
|
+
function sendPostMessage() {
|
|
300
|
+
const wrapper = event.target.closest("[data-cognigy-copilot-tile]");
|
|
301
|
+
const contentElement = wrapper.querySelector(
|
|
302
|
+
"[data-cognigy-content]",
|
|
303
|
+
);
|
|
304
|
+
const content = contentElement.value.trim();
|
|
305
|
+
window.parent.postMessage(
|
|
306
|
+
{ type: "replyBoxContent", content },
|
|
307
|
+
"${postMessageUrl}",
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
${enableCopyToClipboard
|
|
312
|
+
? ` async function copyToClipboard(event) {
|
|
313
|
+
const wrapper = event.target.closest("[data-cognigy-copilot-tile]");
|
|
314
|
+
const contentElement = wrapper.querySelector(
|
|
315
|
+
"[data-cognigy-content]",
|
|
316
|
+
);
|
|
317
|
+
const button = wrapper.querySelector(
|
|
318
|
+
"[data-cognigy-clipboard-button]",
|
|
319
|
+
);
|
|
320
|
+
button.classList.add("blink-green");
|
|
321
|
+
button.addEventListener(
|
|
322
|
+
"animationend",
|
|
323
|
+
function () {
|
|
324
|
+
button.classList.remove("blink-green");
|
|
325
|
+
},
|
|
326
|
+
{ once: true },
|
|
327
|
+
);
|
|
183
328
|
|
|
184
|
-
|
|
185
|
-
|
|
329
|
+
const defaultMessage = button.querySelector(".default-message");
|
|
330
|
+
const successMessage = button.querySelector(".success-message");
|
|
186
331
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
});
|
|
332
|
+
try {
|
|
333
|
+
await navigator.clipboard.writeText(contentElement.value.trim());
|
|
334
|
+
defaultMessage.classList.add("hidden");
|
|
335
|
+
successMessage.classList.remove("hidden");
|
|
192
336
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
337
|
+
// reset to default state
|
|
338
|
+
setTimeout(() => {
|
|
339
|
+
defaultMessage.classList.remove("hidden");
|
|
340
|
+
successMessage.classList.add("hidden");
|
|
341
|
+
}, 2000);
|
|
342
|
+
} catch (err) {
|
|
343
|
+
console.error("Failed to copy: ", err);
|
|
344
|
+
}
|
|
345
|
+
}`
|
|
346
|
+
: ""}
|
|
200
347
|
|
|
201
|
-
|
|
202
|
-
|
|
348
|
+
document.addEventListener("DOMContentLoaded", updateButtonVisibility);
|
|
349
|
+
document.addEventListener("DOMContentLoaded", updateCopyButtonVisibility);
|
|
350
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
351
|
+
document
|
|
352
|
+
.getElementById("searchInput")
|
|
353
|
+
.addEventListener("keypress", (event) => {
|
|
354
|
+
if (event.key === "Enter") {
|
|
355
|
+
event.preventDefault();
|
|
356
|
+
triggerSearch();
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
document.querySelector("#postbackButton").addEventListener("click", triggerSearch);
|
|
360
|
+
document
|
|
361
|
+
.querySelector("[data-cognigy-copilot-tile-ka] #liveAgentForwardButton")
|
|
362
|
+
.addEventListener("click", sendPostMessage);
|
|
363
|
+
${enableCopyToClipboard
|
|
364
|
+
? `document
|
|
365
|
+
.querySelector("[data-cognigy-copilot-tile-ka] [data-cognigy-clipboard-button]")
|
|
366
|
+
.addEventListener("click", copyToClipboard);
|
|
367
|
+
|
|
368
|
+
document
|
|
369
|
+
.querySelector("[data-cognigy-copilot-tile-ka] [data-cognigy-clipboard-button]")
|
|
370
|
+
.removeAttribute("disabled");`
|
|
371
|
+
: ""}
|
|
372
|
+
|
|
373
|
+
document
|
|
374
|
+
.querySelector("[data-cognigy-copilot-tile-ka] #liveAgentForwardButton")
|
|
375
|
+
.removeAttribute("disabled");
|
|
376
|
+
});
|
|
377
|
+
})();
|
|
378
|
+
</script>
|
|
379
|
+
`;
|
|
203
380
|
//# sourceMappingURL=knowledgeAssistTemplate.js.map
|