@cognigy/rest-api-client 4.95.0 → 4.97.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 +10 -0
- package/build/apigroups/ManagementAPIGroup_2_0.js +2 -1
- package/build/apigroups/ResourcesAPIGroup_2_0.js +9 -0
- package/build/authentication/AuthenticationAPI.js +6 -1
- package/build/authentication/JWT/IJwtTokenAuthentication.js +3 -0
- package/build/authentication/JWT/JwtTokenAuthentication.js +22 -0
- package/build/shared/charts/descriptors/allFields.js +6 -0
- package/build/shared/charts/descriptors/analytics/addMemory.js +1 -1
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/index.js +6 -2
- package/build/shared/charts/descriptors/connectionNodes/generativeAIProviders/openAICompatibleProviderConnection.js +11 -0
- package/build/shared/charts/descriptors/connectionNodes/speechProviders/deepgramSpeechProviderConnection.js +11 -0
- package/build/shared/charts/descriptors/connectionNodes/speechProviders/index.js +2 -0
- package/build/shared/charts/descriptors/index.js +6 -0
- package/build/shared/charts/descriptors/knowledgeSearch/searchExtractOutput.js +13 -1
- package/build/shared/charts/descriptors/message/question/question.js +21 -13
- package/build/shared/charts/descriptors/message/say.js +25 -2
- package/build/shared/charts/descriptors/service/GPTPrompt.js +10 -2
- package/build/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +184 -51
- package/build/shared/charts/descriptors/service/checkAgentAvailability.js +63 -3
- package/build/shared/charts/descriptors/service/handoverConnections.js +51 -0
- package/build/shared/charts/descriptors/service/handoverV2.js +124 -64
- package/build/shared/charts/descriptors/service/index.js +8 -1
- package/build/shared/charts/descriptors/voice/mappers/transfer.mapper.js +4 -1
- package/build/shared/charts/descriptors/voice/nodes/bargeIn.js +1 -1
- package/build/shared/charts/descriptors/voice/nodes/continuousAsr.js +1 -1
- package/build/shared/charts/descriptors/voice/nodes/dtmf.js +1 -1
- package/build/shared/charts/descriptors/voice/nodes/hangup.js +1 -1
- package/build/shared/charts/descriptors/voice/nodes/muteSpeechInput.js +1 -1
- package/build/shared/charts/descriptors/voice/nodes/noUserInput.js +1 -1
- package/build/shared/charts/descriptors/voice/nodes/play.js +1 -1
- package/build/shared/charts/descriptors/voice/nodes/sendMetadata.js +1 -1
- package/build/shared/charts/descriptors/voice/nodes/sessionSpeechParameters.js +1 -1
- package/build/shared/charts/descriptors/voice/nodes/transfer.js +1 -1
- package/build/shared/charts/descriptors/voicegateway2/nodes/dtmf.js +1 -1
- package/build/shared/charts/descriptors/voicegateway2/nodes/hangup.js +1 -1
- package/build/shared/charts/descriptors/voicegateway2/nodes/muteSpeechInput.js +1 -1
- package/build/shared/charts/descriptors/voicegateway2/nodes/play.js +1 -1
- package/build/shared/charts/descriptors/voicegateway2/nodes/record.js +1 -1
- package/build/shared/charts/descriptors/voicegateway2/nodes/refer.js +1 -1
- package/build/shared/charts/descriptors/voicegateway2/nodes/sendMetadata.js +1 -1
- package/build/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +1 -1
- package/build/shared/charts/descriptors/voicegateway2/nodes/transfer.js +47 -2
- package/build/shared/constants.js +10 -1
- package/build/shared/helper/nlu/textCleaner.js +10 -2
- package/build/shared/interfaces/generativeAI/IGenerativeAIModels.js +3 -0
- package/build/shared/interfaces/handover.js +74 -10
- package/build/shared/interfaces/handoverProviders.js +23 -0
- package/build/shared/interfaces/messageAPI/endpoints.js +2 -0
- package/build/shared/interfaces/messageAPI/handover.js +25 -5
- package/build/shared/interfaces/resources/IAiAgent.js +10 -0
- package/build/shared/interfaces/resources/IExternalModel.js +3 -0
- package/build/shared/interfaces/resources/IHandoverProvider.js +3 -0
- package/build/shared/interfaces/resources/ILargeLanguageModel.js +13 -2
- package/build/shared/interfaces/resources/INodeDescriptorSet.js +9 -5
- package/build/shared/interfaces/resources/TResourceType.js +6 -0
- package/build/shared/interfaces/resources/intent/IDefaultReply.js +0 -1
- package/build/shared/interfaces/resources/settings/IAudioPreviewSettings.js +8 -2
- package/build/shared/interfaces/restAPI/resources/handoverProvider/v2.0/ICreateHandoverProviderRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IDeleteHandoverProviderRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IHandoverProvider_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IHandoverService_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IIndexHandoverProvidersRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IIndexHandoverServicesRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IReadHandoverProviderRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IUpdateHandoverProviderRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/handoverProvider/v2.0/index.js +3 -0
- package/build/shared/interfaces/security/IPermission.js +2 -0
- package/build/shared/interfaces/security/IRole.js +2 -0
- package/build/shared/interfaces/security/index.js +1 -1
- package/dist/esm/apigroups/ManagementAPIGroup_2_0.js +2 -1
- package/dist/esm/apigroups/ResourcesAPIGroup_2_0.js +9 -0
- package/dist/esm/authentication/AuthenticationAPI.js +6 -1
- package/dist/esm/authentication/JWT/IJwtTokenAuthentication.js +2 -0
- package/dist/esm/authentication/JWT/JwtTokenAuthentication.js +21 -0
- package/dist/esm/shared/charts/descriptors/allFields.js +6 -0
- package/dist/esm/shared/charts/descriptors/analytics/addMemory.js +1 -1
- package/dist/esm/shared/charts/descriptors/connectionNodes/generativeAIProviders/index.js +4 -1
- package/dist/esm/shared/charts/descriptors/connectionNodes/generativeAIProviders/openAICompatibleProviderConnection.js +8 -0
- package/dist/esm/shared/charts/descriptors/connectionNodes/speechProviders/deepgramSpeechProviderConnection.js +8 -0
- package/dist/esm/shared/charts/descriptors/connectionNodes/speechProviders/index.js +2 -0
- package/dist/esm/shared/charts/descriptors/index.js +7 -1
- package/dist/esm/shared/charts/descriptors/knowledgeSearch/searchExtractOutput.js +13 -1
- package/dist/esm/shared/charts/descriptors/message/question/question.js +21 -13
- package/dist/esm/shared/charts/descriptors/message/say.js +25 -2
- package/dist/esm/shared/charts/descriptors/service/GPTPrompt.js +10 -2
- package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +184 -51
- package/dist/esm/shared/charts/descriptors/service/checkAgentAvailability.js +63 -3
- package/dist/esm/shared/charts/descriptors/service/handoverConnections.js +48 -0
- package/dist/esm/shared/charts/descriptors/service/handoverV2.js +124 -64
- package/dist/esm/shared/charts/descriptors/service/index.js +1 -0
- package/dist/esm/shared/charts/descriptors/voice/mappers/transfer.mapper.js +4 -1
- package/dist/esm/shared/charts/descriptors/voice/nodes/bargeIn.js +1 -1
- package/dist/esm/shared/charts/descriptors/voice/nodes/continuousAsr.js +1 -1
- package/dist/esm/shared/charts/descriptors/voice/nodes/dtmf.js +1 -1
- package/dist/esm/shared/charts/descriptors/voice/nodes/hangup.js +1 -1
- package/dist/esm/shared/charts/descriptors/voice/nodes/muteSpeechInput.js +1 -1
- package/dist/esm/shared/charts/descriptors/voice/nodes/noUserInput.js +1 -1
- package/dist/esm/shared/charts/descriptors/voice/nodes/play.js +1 -1
- package/dist/esm/shared/charts/descriptors/voice/nodes/sendMetadata.js +1 -1
- package/dist/esm/shared/charts/descriptors/voice/nodes/sessionSpeechParameters.js +1 -1
- package/dist/esm/shared/charts/descriptors/voice/nodes/transfer.js +1 -1
- package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/dtmf.js +1 -1
- package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/hangup.js +1 -1
- package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/muteSpeechInput.js +1 -1
- package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/play.js +1 -1
- package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/record.js +1 -1
- package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/refer.js +1 -1
- package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/sendMetadata.js +1 -1
- package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +1 -1
- package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/transfer.js +47 -2
- package/dist/esm/shared/constants.js +9 -0
- package/dist/esm/shared/helper/nlu/textCleaner.js +10 -2
- package/dist/esm/shared/interfaces/generativeAI/IGenerativeAIModels.js +3 -0
- package/dist/esm/shared/interfaces/handover.js +73 -9
- package/dist/esm/shared/interfaces/handoverProviders.js +20 -0
- package/dist/esm/shared/interfaces/messageAPI/endpoints.js +2 -0
- package/dist/esm/shared/interfaces/messageAPI/handover.js +24 -4
- package/dist/esm/shared/interfaces/resources/IAiAgent.js +10 -0
- package/dist/esm/shared/interfaces/resources/IExternalModel.js +2 -0
- package/dist/esm/shared/interfaces/resources/IHandoverProvider.js +2 -0
- package/dist/esm/shared/interfaces/resources/ILargeLanguageModel.js +12 -1
- package/dist/esm/shared/interfaces/resources/INodeDescriptorSet.js +9 -5
- package/dist/esm/shared/interfaces/resources/TResourceType.js +6 -0
- package/dist/esm/shared/interfaces/resources/intent/IDefaultReply.js +0 -1
- package/dist/esm/shared/interfaces/resources/settings/IAudioPreviewSettings.js +8 -2
- package/dist/esm/shared/interfaces/restAPI/resources/handoverProvider/v2.0/ICreateHandoverProviderRest_2_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IDeleteHandoverProviderRest_2_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IHandoverProvider_2_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IHandoverService_2_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IIndexHandoverProvidersRest_2_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IIndexHandoverServicesRest_2_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IReadHandoverProviderRest_2_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/resources/handoverProvider/v2.0/IUpdateHandoverProviderRest_2_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/resources/handoverProvider/v2.0/index.js +2 -0
- package/dist/esm/shared/interfaces/security/IPermission.js +2 -0
- package/dist/esm/shared/interfaces/security/IRole.js +2 -0
- package/dist/esm/shared/interfaces/security/index.js +1 -1
- package/package.json +2 -2
- package/types/index.d.ts +626 -25
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { __awaiter, __rest } from "tslib";
|
|
2
2
|
/* Custom modules */
|
|
3
3
|
import { createNodeDescriptor } from "../../../createNodeDescriptor";
|
|
4
|
+
import { randomUUID } from 'crypto';
|
|
5
|
+
import { setSessionConfig } from "../../voice/mappers/setSessionConfig.mapper";
|
|
6
|
+
import { voiceConfigParamsToVoiceSettings } from "../../voice/mappers/setSessionConfig.mapper";
|
|
7
|
+
import { logFullConfigToDebugMode } from "../../../../helper/logFullConfigToDebugMode";
|
|
4
8
|
import { TranscriptEntryType, TranscriptRole } from "../../../../interfaces/transcripts/transcripts";
|
|
5
9
|
import { createSystemMessage, validateToolId } from "./helpers/createSystemMessage";
|
|
6
10
|
import { generateSearchPrompt } from "./helpers/generateSearchPrompt";
|
|
@@ -70,7 +74,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
70
74
|
{
|
|
71
75
|
key: "description",
|
|
72
76
|
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__JOB_DESCRIPTION__LABEL",
|
|
73
|
-
type: "
|
|
77
|
+
type: "cognigyLLMText",
|
|
74
78
|
defaultValue: "You resolve customer issues, ensure a positive experience, troubleshoot problems, and escalate complex cases as needed. You provide product guidance, communicate effectively, and stay calm under pressure.",
|
|
75
79
|
params: {
|
|
76
80
|
required: false,
|
|
@@ -84,7 +88,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
84
88
|
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__INSCTRUCTIONS__DESCRIPTION",
|
|
85
89
|
defaultValue: `- Pretend to be an expert in your area.
|
|
86
90
|
- Never answer questions that are outside your job.`,
|
|
87
|
-
type: "
|
|
91
|
+
type: "cognigyLLMText",
|
|
88
92
|
params: {
|
|
89
93
|
required: false,
|
|
90
94
|
rows: 5,
|
|
@@ -164,7 +168,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
164
168
|
},
|
|
165
169
|
{
|
|
166
170
|
key: "memoryContextInjection",
|
|
167
|
-
type: "
|
|
171
|
+
type: "cognigyLLMText",
|
|
168
172
|
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__CONTEXT_INJECTION__LABEL",
|
|
169
173
|
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__CONTEXT_INJECTION__DESCRIPTION",
|
|
170
174
|
defaultValue: "[[snippet-eyJ0eXBlIjoiY29udGV4dCIsImxhYmVsIjoiU2hvcnQtVGVybSBNZW1vcnkiLCJzY3JpcHQiOiJjb250ZXh0LnNob3J0VGVybU1lbW9yeSJ9]]",
|
|
@@ -610,6 +614,60 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
610
614
|
}
|
|
611
615
|
],
|
|
612
616
|
},
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
key: "voiceSetting",
|
|
620
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__VOICE_SETTING__LABEL",
|
|
621
|
+
description: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__VOICE_SETTING__DESCRIPTION",
|
|
622
|
+
type: "select",
|
|
623
|
+
defaultValue: "inheritFromAiAgent",
|
|
624
|
+
params: {
|
|
625
|
+
options: [
|
|
626
|
+
{
|
|
627
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__VOICE_SETTING__OPTIONS__INHERIT__LABEL",
|
|
628
|
+
value: "inheritFromAiAgent"
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__FIELDS__VOICE_SETTING__OPTIONS__USE_JOB_VOICE__LABEL",
|
|
632
|
+
value: "jobVoice"
|
|
633
|
+
}
|
|
634
|
+
]
|
|
635
|
+
}
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
key: "ttsVendor",
|
|
639
|
+
defaultValue: "",
|
|
640
|
+
type: "ttsSelect",
|
|
641
|
+
label: "_unused_",
|
|
642
|
+
description: "_unused_",
|
|
643
|
+
params: {
|
|
644
|
+
languageKey: "config.ttsLanguage",
|
|
645
|
+
modelKey: "config.ttsModel",
|
|
646
|
+
voiceKey: "config.ttsVoice"
|
|
647
|
+
},
|
|
648
|
+
condition: {
|
|
649
|
+
key: "voiceSetting",
|
|
650
|
+
value: "jobVoice"
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
key: "ttsLanguage",
|
|
655
|
+
type: "ttsSelect",
|
|
656
|
+
defaultValue: "",
|
|
657
|
+
label: "_unused_",
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
key: "ttsModel",
|
|
661
|
+
type: "ttsSelect",
|
|
662
|
+
label: "_unused_",
|
|
663
|
+
description: "_unused_",
|
|
664
|
+
defaultValue: "",
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
key: "ttsVoice",
|
|
668
|
+
type: "ttsSelect",
|
|
669
|
+
defaultValue: "",
|
|
670
|
+
label: "_unused_",
|
|
613
671
|
}
|
|
614
672
|
],
|
|
615
673
|
sections: [
|
|
@@ -653,6 +711,15 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
653
711
|
"streamStopTokens"
|
|
654
712
|
]
|
|
655
713
|
},
|
|
714
|
+
{
|
|
715
|
+
key: "voice",
|
|
716
|
+
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__VOICE__LABEL",
|
|
717
|
+
defaultCollapsed: true,
|
|
718
|
+
fields: [
|
|
719
|
+
"voiceSetting",
|
|
720
|
+
"ttsVendor",
|
|
721
|
+
],
|
|
722
|
+
},
|
|
656
723
|
{
|
|
657
724
|
key: "toolSettings",
|
|
658
725
|
label: "UI__NODE_EDITOR__SERVICE__AI_AGENT_JOB__SECTIONS__TOOL_SETTINGS__LABEL",
|
|
@@ -714,6 +781,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
714
781
|
{ type: "section", key: "memory" },
|
|
715
782
|
{ type: "section", key: "knowledgeSearch" },
|
|
716
783
|
{ type: "section", key: "storage" },
|
|
784
|
+
{ type: "section", key: "voice" },
|
|
717
785
|
{ type: "section", key: "toolSettings" },
|
|
718
786
|
{ type: "section", key: "imageHandling" },
|
|
719
787
|
{ type: "section", key: "advanced" },
|
|
@@ -722,23 +790,62 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
722
790
|
],
|
|
723
791
|
tags: ["ai", "aiAgent"],
|
|
724
792
|
function: ({ cognigy, config, childConfigs, nodeId }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
725
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
|
|
793
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12;
|
|
726
794
|
const { api, context, input, profile, flowReferenceId } = cognigy;
|
|
727
|
-
const { aiAgent, llmProviderReferenceId, name: jobName, description: jobDescription, instructions: jobInstructions, outputImmediately, toolChoice, useStrict, memoryType, selectedProfileFields, memoryContextInjection, knowledgeSearchBehavior, knowledgeSearchTags, knowledgeSearchTagsFilterOp, knowledgeSearchAiAgentKnowledge, knowledgeSearchJobKnowledge, knowledgeSearchJobStore, knowledgeSearchGenerateSearchPrompt, knowledgeSearchTopK, timeoutInMs, maxTokens, temperature, logErrorToSystem, storeErrorInInput, errorHandling, errorHandlingGotoTarget, errorMessage, debugConfig, debugLogTokenCount, debugResult, storeLocation, contextKey, inputKey, streamStoreCopyInInput, streamStopTokens, processImages, transcriptImageHandling, } = config;
|
|
795
|
+
const { aiAgent, llmProviderReferenceId, name: jobName, description: jobDescription, instructions: jobInstructions, outputImmediately, toolChoice, useStrict, memoryType, selectedProfileFields, memoryContextInjection, knowledgeSearchBehavior, knowledgeSearchTags, knowledgeSearchTagsFilterOp, knowledgeSearchAiAgentKnowledge, knowledgeSearchJobKnowledge, knowledgeSearchJobStore, knowledgeSearchGenerateSearchPrompt, knowledgeSearchTopK, timeoutInMs, maxTokens, temperature, logErrorToSystem, storeErrorInInput, errorHandling, errorHandlingGotoTarget, errorMessage, debugConfig, debugLogTokenCount, debugResult, storeLocation, contextKey, inputKey, streamStoreCopyInInput, streamStopTokens, processImages, transcriptImageHandling, sessionParams } = config;
|
|
728
796
|
try {
|
|
729
797
|
if (!aiAgent) {
|
|
730
798
|
throw new Error("Could not resolve AI Agent reference in AI Agent Node");
|
|
731
799
|
}
|
|
732
|
-
|
|
800
|
+
// Determine if the job should inherit voice settings from the AI Agent
|
|
801
|
+
if (config.voiceSetting === "inheritFromAiAgent") {
|
|
802
|
+
if (aiAgent.enableVoiceConfigs && ((_a = aiAgent.voiceConfigs) === null || _a === void 0 ? void 0 : _a.ttsVendor) && aiAgent.voiceConfigs.ttsVendor !== "none") {
|
|
803
|
+
// Inherit voice configurations from the AI Agent if valid
|
|
804
|
+
Object.assign(config, {
|
|
805
|
+
ttsVendor: aiAgent.voiceConfigs.ttsVendor,
|
|
806
|
+
ttsLanguage: aiAgent.voiceConfigs.ttsLanguage,
|
|
807
|
+
ttsModel: aiAgent.voiceConfigs.ttsModel,
|
|
808
|
+
ttsVoice: aiAgent.voiceConfigs.ttsVoice,
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
else {
|
|
812
|
+
// Reset voice settings if AI Agent lacks configurations
|
|
813
|
+
Object.assign(config, {
|
|
814
|
+
ttsVendor: "none",
|
|
815
|
+
ttsLanguage: "",
|
|
816
|
+
ttsModel: "",
|
|
817
|
+
ttsVoice: "",
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
// After inheriting or directly setting voice configurations from the AI Agent wizard,
|
|
822
|
+
// we need to apply these settings to the voice gateway
|
|
823
|
+
// Only proceed if we have a valid TTS vendor configured
|
|
824
|
+
if (config.ttsVendor && config.ttsVendor !== "none") {
|
|
825
|
+
try {
|
|
826
|
+
const voiceSettings = voiceConfigParamsToVoiceSettings(config, api);
|
|
827
|
+
const payload = setSessionConfig.handleVGInput(voiceSettings, sessionParams || {}, api);
|
|
828
|
+
if (payload && Object.keys(payload).length > 0) {
|
|
829
|
+
api.say(null, {
|
|
830
|
+
_cognigy: payload,
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
logFullConfigToDebugMode(cognigy, voiceSettings);
|
|
834
|
+
}
|
|
835
|
+
catch (error) {
|
|
836
|
+
throw new Error(`[VG2] Error on AI Agent Job node. Error message: ${error.message}`);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
const _13 = profile, { profileId, accepted_gdpr, prevent_data_collection, privacy_policy } = _13, cleanedProfile = __rest(_13, ["profileId", "accepted_gdpr", "prevent_data_collection", "privacy_policy"]);
|
|
733
840
|
const userMemory = getUserMemory(memoryType, selectedProfileFields, aiAgent, cleanedProfile);
|
|
734
841
|
/**
|
|
735
842
|
* ----- Knowledge Search Section -----
|
|
736
843
|
*/
|
|
737
844
|
let knowledgeSearchResponseData;
|
|
738
845
|
const sessionState = yield api.loadSessionState();
|
|
739
|
-
const lastToolCall = (
|
|
846
|
+
const lastToolCall = (_b = sessionState.lastToolCall) === null || _b === void 0 ? void 0 : _b.toolCall;
|
|
740
847
|
if (knowledgeSearchBehavior === "always" ||
|
|
741
|
-
(knowledgeSearchBehavior === "onDemand" && ((
|
|
848
|
+
(knowledgeSearchBehavior === "onDemand" && ((_c = lastToolCall === null || lastToolCall === void 0 ? void 0 : lastToolCall.function) === null || _c === void 0 ? void 0 : _c.name) === "retrieve_knowledge")) {
|
|
742
849
|
const knowledgeStoreIds = [];
|
|
743
850
|
if (knowledgeSearchAiAgentKnowledge && aiAgent.knowledgeReferenceId) {
|
|
744
851
|
knowledgeStoreIds.push(aiAgent.knowledgeReferenceId);
|
|
@@ -746,8 +853,8 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
746
853
|
if (knowledgeSearchJobKnowledge && knowledgeSearchJobStore) {
|
|
747
854
|
knowledgeStoreIds.push(knowledgeSearchJobStore);
|
|
748
855
|
}
|
|
749
|
-
if (knowledgeStoreIds.length > 0 && (input.text || ((
|
|
750
|
-
let query = ((
|
|
856
|
+
if (knowledgeStoreIds.length > 0 && (input.text || ((_e = (_d = lastToolCall === null || lastToolCall === void 0 ? void 0 : lastToolCall.function) === null || _d === void 0 ? void 0 : _d.arguments) === null || _e === void 0 ? void 0 : _e.generated_prompt))) {
|
|
857
|
+
let query = ((_g = (_f = lastToolCall === null || lastToolCall === void 0 ? void 0 : lastToolCall.function) === null || _f === void 0 ? void 0 : _f.arguments) === null || _g === void 0 ? void 0 : _g.generated_prompt) || input.text;
|
|
751
858
|
if (knowledgeSearchBehavior === "always" && knowledgeSearchGenerateSearchPrompt) {
|
|
752
859
|
const generatedSearchPrompt = yield generateSearchPrompt({ api, userMemory, llmProviderReferenceId, debugLogTokenCount, memoryContextInjection });
|
|
753
860
|
if (generatedSearchPrompt === null || generatedSearchPrompt === void 0 ? void 0 : generatedSearchPrompt.generated_prompt) {
|
|
@@ -763,10 +870,10 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
763
870
|
knowledgeStoreIds,
|
|
764
871
|
};
|
|
765
872
|
if (knowledgeSearchBehavior === "onDemand") {
|
|
766
|
-
const generated_buffer_phrase = (
|
|
873
|
+
const generated_buffer_phrase = (_j = (_h = lastToolCall === null || lastToolCall === void 0 ? void 0 : lastToolCall.function) === null || _h === void 0 ? void 0 : _h.arguments) === null || _j === void 0 ? void 0 : _j.generated_buffer_phrase;
|
|
767
874
|
if (generated_buffer_phrase) {
|
|
768
875
|
// output the generated buffer phrase. Don't add it to the transcript, else the LLM will repeat it next time.
|
|
769
|
-
yield ((
|
|
876
|
+
yield ((_k = api.output) === null || _k === void 0 ? void 0 : _k.call(api, generated_buffer_phrase, {
|
|
770
877
|
_cognigy: {
|
|
771
878
|
_preventTranscript: true
|
|
772
879
|
}
|
|
@@ -796,7 +903,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
796
903
|
if (query) {
|
|
797
904
|
messageLines.push(`\n<b>UI__DEBUG_MODE__AI_AGENT_JOB__KNOWLEDGE_SEARCH__SEARCH_PROMPT</b> ${query}`);
|
|
798
905
|
}
|
|
799
|
-
if ((
|
|
906
|
+
if ((_l = knowledgeSearchResponseData === null || knowledgeSearchResponseData === void 0 ? void 0 : knowledgeSearchResponseData.topK) === null || _l === void 0 ? void 0 : _l.length) {
|
|
800
907
|
knowledgeSearchResponseData === null || knowledgeSearchResponseData === void 0 ? void 0 : knowledgeSearchResponseData.topK.forEach((result, index) => {
|
|
801
908
|
var _a;
|
|
802
909
|
messageLines.push(`\nTop ${index + 1}:`);
|
|
@@ -808,7 +915,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
808
915
|
else {
|
|
809
916
|
messageLines.push("UI__DEBUG_MODE__AI_AGENT_JOB__KNOWLEDGE_SEARCH__NO_RESULTS");
|
|
810
917
|
}
|
|
811
|
-
(
|
|
918
|
+
(_m = api.logDebugMessage) === null || _m === void 0 ? void 0 : _m.call(api, messageLines.join("\n"), "UI__DEBUG_MODE__AI_AGENT_JOB__KNOWLEDGE_SEARCH__HEADER");
|
|
812
919
|
}
|
|
813
920
|
// Knowledge Search "onDemand" responds to a tool call
|
|
814
921
|
if (knowledgeSearchBehavior === "onDemand") {
|
|
@@ -837,7 +944,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
837
944
|
yield api.addTranscriptStep(toolAnswer);
|
|
838
945
|
}
|
|
839
946
|
}
|
|
840
|
-
if (((
|
|
947
|
+
if (((_o = lastToolCall === null || lastToolCall === void 0 ? void 0 : lastToolCall.function) === null || _o === void 0 ? void 0 : _o.name) === "retrieve_knowledge") {
|
|
841
948
|
// remove the retrieve_knowledge toolCall from session state to avoid infinite loops
|
|
842
949
|
api.updateSessionStateValues({
|
|
843
950
|
lastToolCall: undefined
|
|
@@ -845,26 +952,35 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
845
952
|
}
|
|
846
953
|
}
|
|
847
954
|
// ----- End of Knowledge Search Section ----- //
|
|
955
|
+
const isOnDemandKnowledgeStoreConfigured = knowledgeSearchBehavior === "onDemand" && ((knowledgeSearchAiAgentKnowledge && aiAgent.knowledgeReferenceId) || (knowledgeSearchJobKnowledge && knowledgeSearchJobStore));
|
|
848
956
|
// create the system Message from the AI Agent resource and this Node's config storage
|
|
849
|
-
const systemMessage = createSystemMessage(aiAgent, input, jobName, jobDescription, jobInstructions, userMemory, memoryContextInjection,
|
|
957
|
+
const systemMessage = createSystemMessage(aiAgent, input, jobName, jobDescription, jobInstructions, userMemory, memoryContextInjection, isOnDemandKnowledgeStoreConfigured ? "onDemand" : "none");
|
|
850
958
|
// Create Tools JSON
|
|
851
959
|
const tools = [];
|
|
852
960
|
const toolIds = [];
|
|
853
961
|
childConfigs.forEach(child => {
|
|
962
|
+
if (child.type === "aiAgentJobDefault") {
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
;
|
|
854
966
|
const toolId = child.config.toolId;
|
|
855
|
-
if (!
|
|
856
|
-
throw new Error(`Tool ID
|
|
967
|
+
if (!toolId) {
|
|
968
|
+
throw new Error(`Tool ID is missing in Tool Node configuration.`);
|
|
969
|
+
}
|
|
970
|
+
const parsedToolId = api.parseCognigyScriptText(toolId);
|
|
971
|
+
if (!validateToolId(parsedToolId)) {
|
|
972
|
+
throw new Error(`Tool ID ${parsedToolId} is not valid. Please use only alphanumeric characters, dashes and underscores.`);
|
|
857
973
|
}
|
|
858
|
-
if (toolIds.includes(
|
|
859
|
-
throw new Error(`Tool ID ${
|
|
974
|
+
if (toolIds.includes(parsedToolId)) {
|
|
975
|
+
throw new Error(`Tool ID ${parsedToolId} is not unique. Please ensure each tool has a unique id.`);
|
|
860
976
|
}
|
|
861
|
-
toolIds.push(
|
|
977
|
+
toolIds.push(parsedToolId);
|
|
862
978
|
if (child.type === "aiAgentJobTool" && (!child.config.condition || !!api.parseCognigyScriptCondition(child.config.condition))) {
|
|
863
979
|
const tool = {
|
|
864
980
|
type: "function",
|
|
865
981
|
function: {
|
|
866
|
-
name:
|
|
867
|
-
description: child.config.description,
|
|
982
|
+
name: parsedToolId,
|
|
983
|
+
description: api.parseCognigyScriptText(child.config.description),
|
|
868
984
|
}
|
|
869
985
|
};
|
|
870
986
|
if (useStrict) {
|
|
@@ -883,10 +999,10 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
883
999
|
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__AI_AGENT_NAME__LABEL</b> ${aiAgent.name}`);
|
|
884
1000
|
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__JOB_NAME__LABEL</b> ${jobName}`);
|
|
885
1001
|
// Safety settings
|
|
886
|
-
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__SAFETY_SETTINGS_AVOID_HARMFUL_CONTENT</b> ${(
|
|
887
|
-
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__SAFETY_SETTINGS_AVOID_UNGROUNDED_CONTENT</b> ${(
|
|
888
|
-
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__SAFETY_SETTINGS_AVOID_COPYRIGHT_INFRINGEMENTS</b> ${(
|
|
889
|
-
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__SAFETY_SETTINGS_PREVENT_JAILBREAK_AND_MANIPULATION</b> ${(
|
|
1002
|
+
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__SAFETY_SETTINGS_AVOID_HARMFUL_CONTENT</b> ${(_p = aiAgent === null || aiAgent === void 0 ? void 0 : aiAgent.safetySettings) === null || _p === void 0 ? void 0 : _p.avoidHarmfulContent}`);
|
|
1003
|
+
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__SAFETY_SETTINGS_AVOID_UNGROUNDED_CONTENT</b> ${(_q = aiAgent === null || aiAgent === void 0 ? void 0 : aiAgent.safetySettings) === null || _q === void 0 ? void 0 : _q.avoidUngroundedContent}`);
|
|
1004
|
+
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__SAFETY_SETTINGS_AVOID_COPYRIGHT_INFRINGEMENTS</b> ${(_r = aiAgent === null || aiAgent === void 0 ? void 0 : aiAgent.safetySettings) === null || _r === void 0 ? void 0 : _r.avoidCopyrightInfringements}`);
|
|
1005
|
+
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__SAFETY_SETTINGS_PREVENT_JAILBREAK_AND_MANIPULATION</b> ${(_s = aiAgent === null || aiAgent === void 0 ? void 0 : aiAgent.safetySettings) === null || _s === void 0 ? void 0 : _s.preventJailbreakAndManipulation}`);
|
|
890
1006
|
// Tools
|
|
891
1007
|
if (tools.length > 0) {
|
|
892
1008
|
messageLines.push("<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__TOOLS__LABEL</b>");
|
|
@@ -929,11 +1045,22 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
929
1045
|
knowledgeSearchTags.forEach(tag => messageLines.push(`- ${tag}`));
|
|
930
1046
|
}
|
|
931
1047
|
}
|
|
932
|
-
|
|
1048
|
+
// Add voice configuration debug info
|
|
1049
|
+
if (config.voiceSetting === "inheritFromAiAgent") {
|
|
1050
|
+
messageLines.push("\n<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__VOICE_SETTING__INHERIT</b>");
|
|
1051
|
+
}
|
|
1052
|
+
else {
|
|
1053
|
+
messageLines.push("\n<b>UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__VOICE_SETTING__JOB_VOICE</b>");
|
|
1054
|
+
}
|
|
1055
|
+
messageLines.push(`UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__VOICE_SETTING__TTS_VENDOR ${config.ttsVendor || 'UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__VOICE_SETTING__NOT_SET'}`);
|
|
1056
|
+
messageLines.push(`UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__VOICE_SETTING__TTS_LANGUAGE ${config.ttsLanguage || 'UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__VOICE_SETTING__NOT_SET'}`);
|
|
1057
|
+
messageLines.push(`UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__VOICE_SETTING__TTS_MODEL ${config.ttsModel || 'UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__VOICE_SETTING__NOT_SET'}`);
|
|
1058
|
+
messageLines.push(`UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__VOICE_SETTING__TTS_VOICE ${config.ttsVoice || 'UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__VOICE_SETTING__NOT_SET'}`);
|
|
1059
|
+
(_t = api.logDebugMessage) === null || _t === void 0 ? void 0 : _t.call(api, messageLines.join("\n"), "UI__DEBUG_MODE__AI_AGENT_JOB__CONFIGURATION__HEADER");
|
|
933
1060
|
}
|
|
934
1061
|
// keep this after the debug message since the "retrieve_knowledge" tool is implicit
|
|
935
1062
|
// we only add this tool if at least one knowledge source is enabled
|
|
936
|
-
if (
|
|
1063
|
+
if (isOnDemandKnowledgeStoreConfigured) {
|
|
937
1064
|
const knowledgeTool = {
|
|
938
1065
|
type: "function",
|
|
939
1066
|
function: {
|
|
@@ -973,23 +1100,26 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
973
1100
|
transcript.length > 0 &&
|
|
974
1101
|
transcript[transcript.length - 1].role === TranscriptRole.USER) {
|
|
975
1102
|
const userInput = transcript[transcript.length - 1];
|
|
976
|
-
const enhancedInput = `## Knowledge Source Context\nAdditional Context from the knowledge source: \n${JSON.stringify(knowledgeSearchResponseData)}\n\n\n${((
|
|
1103
|
+
const enhancedInput = `## Knowledge Source Context\nAdditional Context from the knowledge source: \n${JSON.stringify(knowledgeSearchResponseData)}\n\n\n${((_u = userInput === null || userInput === void 0 ? void 0 : userInput.payload) === null || _u === void 0 ? void 0 : _u.text) || input.text}`;
|
|
977
1104
|
transcript[transcript.length - 1].payload.text = enhancedInput;
|
|
978
1105
|
}
|
|
1106
|
+
const isStreamingChannel = input.channel === "webchat3" || input.channel === "adminconsole";
|
|
1107
|
+
const _messageId = randomUUID();
|
|
979
1108
|
const llmPromptOptions = Object.assign(Object.assign({ prompt: "", chat: systemMessage,
|
|
980
1109
|
// Temp fix to override the transcript if needed
|
|
981
|
-
transcript: ((
|
|
1110
|
+
transcript: ((_v = context === null || context === void 0 ? void 0 : context._cognigy) === null || _v === void 0 ? void 0 : _v.transcript) ? [...context._cognigy.transcript] : transcript, detailedResults: true, timeoutInMs: timeoutInMs !== null && timeoutInMs !== void 0 ? timeoutInMs : 8000, maxTokens: maxTokens !== null && maxTokens !== void 0 ? maxTokens : 4000, temperature: temperature !== null && temperature !== void 0 ? temperature : 0.7, topP: 1, frequencyPenalty: 0, presencePenalty: 0, responseFormat: "text", stream: storeLocation === "stream", streamOnDataHandler: (text) => {
|
|
982
1111
|
var _a;
|
|
983
|
-
text = text.trim();
|
|
1112
|
+
text = isStreamingChannel ? text : text.trim();
|
|
984
1113
|
if (text) {
|
|
985
1114
|
// if we got text, we output it, but prevent it from being added to the transcript
|
|
986
1115
|
(_a = api.output) === null || _a === void 0 ? void 0 : _a.call(api, text, {
|
|
987
1116
|
_cognigy: {
|
|
988
|
-
_preventTranscript: true
|
|
1117
|
+
_preventTranscript: true,
|
|
1118
|
+
_messageId,
|
|
989
1119
|
}
|
|
990
1120
|
});
|
|
991
1121
|
}
|
|
992
|
-
}, streamStopTokens: streamStopTokens || [".", "!", "?", "\\n"] }, (tools.length > 0 && { tools })), (tools.length > 0 && { toolChoice: toolChoice }));
|
|
1122
|
+
}, streamStopTokens: streamStopTokens || [".", "!", "?", "\\n"], preventNewLineRemoval: isStreamingChannel ? true : false }, (tools.length > 0 && { tools })), (tools.length > 0 && { toolChoice: toolChoice }));
|
|
993
1123
|
// llmProviderReferenceId `default` value is not a responseFormat, rather it is LLM Model default selection.
|
|
994
1124
|
if (llmProviderReferenceId && llmProviderReferenceId !== "default") {
|
|
995
1125
|
llmPromptOptions["llmProviderReferenceId"] = llmProviderReferenceId;
|
|
@@ -1001,22 +1131,25 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1001
1131
|
};
|
|
1002
1132
|
}
|
|
1003
1133
|
// Set understood to true so that an AI Agent interaction doesn't look false in our analytics
|
|
1004
|
-
(
|
|
1134
|
+
(_w = api.setAnalyticsData) === null || _w === void 0 ? void 0 : _w.call(api, "understood", "true");
|
|
1005
1135
|
input.understood = true;
|
|
1006
|
-
const fullLlmResult = yield ((
|
|
1136
|
+
const fullLlmResult = yield ((_x = api.runGenerativeAIPrompt) === null || _x === void 0 ? void 0 : _x.call(api, llmPromptOptions, "aiAgent"));
|
|
1007
1137
|
const { messages } = fullLlmResult, llmResult = __rest(fullLlmResult, ["messages"]);
|
|
1008
1138
|
const llmProvider = llmResult === null || llmResult === void 0 ? void 0 : llmResult.provider;
|
|
1009
1139
|
const tokenUsage = fullLlmResult.tokenUsage;
|
|
1010
1140
|
// Send optional debug message with token usage
|
|
1011
1141
|
if (debugLogTokenCount && tokenUsage) {
|
|
1012
|
-
(
|
|
1142
|
+
(_y = api.logDebugMessage) === null || _y === void 0 ? void 0 : _y.call(api, tokenUsage, "UI__DEBUG_MODE__AI_AGENT_JOB__TOKEN_USAGE__HEADER");
|
|
1013
1143
|
}
|
|
1014
1144
|
// Identify if the result is a tool call
|
|
1015
1145
|
// If response is a tool call, set next node for Tools
|
|
1016
1146
|
if (llmResult.finishReason === "tool_calls" && llmResult.toolCalls.length > 0) {
|
|
1017
1147
|
const mainToolCall = llmResult.toolCalls[0];
|
|
1018
1148
|
// Find the child node with the toolId of the tool call
|
|
1019
|
-
const toolChild = childConfigs.find(child => { var _a; return child.type === "aiAgentJobTool" && ((_a = child.config) === null || _a === void 0 ? void 0 : _a.toolId) === mainToolCall.function.name; });
|
|
1149
|
+
const toolChild = childConfigs.find(child => { var _a, _b; return child.type === "aiAgentJobTool" && ((_a = child.config) === null || _a === void 0 ? void 0 : _a.toolId) && api.parseCognigyScriptText((_b = child.config) === null || _b === void 0 ? void 0 : _b.toolId) === mainToolCall.function.name; });
|
|
1150
|
+
if (toolChild === undefined) {
|
|
1151
|
+
(_z = api.logDebugError) === null || _z === void 0 ? void 0 : _z.call(api, `UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__ERROR__BODY <b>${mainToolCall.function.name}</b>`, "UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__ERROR__HEADER");
|
|
1152
|
+
}
|
|
1020
1153
|
// Add last tool call to session state for loading it from Tool Answer Node
|
|
1021
1154
|
api.updateSessionStateValues({
|
|
1022
1155
|
lastToolCall: {
|
|
@@ -1030,13 +1163,13 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1030
1163
|
});
|
|
1031
1164
|
// if there are any parameters/arguments, add them to the input slots
|
|
1032
1165
|
if (mainToolCall.function.arguments) {
|
|
1033
|
-
input.aiAgent = Object.assign(Object.assign({}, input.aiAgent), { toolArgs: Object.assign(Object.assign({}, (
|
|
1166
|
+
input.aiAgent = Object.assign(Object.assign({}, input.aiAgent), { toolArgs: Object.assign(Object.assign({}, (_1 = (_0 = input.aiAgent) === null || _0 === void 0 ? void 0 : _0.toolArgs) !== null && _1 !== void 0 ? _1 : {}), mainToolCall.function.arguments) });
|
|
1034
1167
|
}
|
|
1035
1168
|
// Debug Message for Tool Calls, configured in the Tool Node
|
|
1036
|
-
if (toolChild === null || toolChild === void 0 ? void 0 : toolChild.config.debugMessage) {
|
|
1037
|
-
const messageLines = [`<b>UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__HEADER:</b> ${toolChild.config.toolId}`];
|
|
1169
|
+
if ((_2 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _2 === void 0 ? void 0 : _2.debugMessage) {
|
|
1170
|
+
const messageLines = [`<b>UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__HEADER:</b> ${api.parseCognigyScriptText(toolChild.config.toolId)}`];
|
|
1038
1171
|
// Arguments / Parameters Slots
|
|
1039
|
-
const slots = ((
|
|
1172
|
+
const slots = ((_3 = mainToolCall === null || mainToolCall === void 0 ? void 0 : mainToolCall.function) === null || _3 === void 0 ? void 0 : _3.arguments) && Object.keys(mainToolCall.function.arguments);
|
|
1040
1173
|
const hasSlots = slots && slots.length > 0;
|
|
1041
1174
|
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__SLOTS</b>${hasSlots ? "" : " -"}`);
|
|
1042
1175
|
if (hasSlots) {
|
|
@@ -1051,7 +1184,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1051
1184
|
messageLines.push(`- ${slot}: ${slotValueAsString}`);
|
|
1052
1185
|
});
|
|
1053
1186
|
}
|
|
1054
|
-
(
|
|
1187
|
+
(_4 = api.logDebugMessage) === null || _4 === void 0 ? void 0 : _4.call(api, messageLines.join("\n"), "UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__HEADER");
|
|
1055
1188
|
}
|
|
1056
1189
|
if (toolChild) {
|
|
1057
1190
|
api.setNextNode(toolChild.id);
|
|
@@ -1076,7 +1209,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1076
1209
|
}
|
|
1077
1210
|
// Optionally output the result immediately
|
|
1078
1211
|
if (llmResult.result && outputImmediately && !llmPromptOptions.stream) {
|
|
1079
|
-
yield ((
|
|
1212
|
+
yield ((_5 = api.output) === null || _5 === void 0 ? void 0 : _5.call(api, llmResult.result, {}));
|
|
1080
1213
|
}
|
|
1081
1214
|
// If we are streaming and we got a result, also store it into the transcript, since streamed chunks are not stored there
|
|
1082
1215
|
if (llmResult.result && llmPromptOptions.stream) {
|
|
@@ -1093,7 +1226,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1093
1226
|
}
|
|
1094
1227
|
// Add response to Cognigy Input/Context for further usage
|
|
1095
1228
|
if (storeLocation === "context") {
|
|
1096
|
-
(
|
|
1229
|
+
(_6 = api.addToContext) === null || _6 === void 0 ? void 0 : _6.call(api, contextKey, llmResult, "simple");
|
|
1097
1230
|
}
|
|
1098
1231
|
else if (storeLocation === "input") {
|
|
1099
1232
|
api.addToInput(inputKey, llmResult);
|
|
@@ -1106,14 +1239,14 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1106
1239
|
const errorDetails = {
|
|
1107
1240
|
name: (error === null || error === void 0 ? void 0 : error.name) || "Error",
|
|
1108
1241
|
code: (error === null || error === void 0 ? void 0 : error.code) || (error === null || error === void 0 ? void 0 : error.httpStatusCode),
|
|
1109
|
-
message: (error === null || error === void 0 ? void 0 : error.message) || ((
|
|
1242
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || ((_7 = error.originalErrorDetails) === null || _7 === void 0 ? void 0 : _7.message),
|
|
1110
1243
|
};
|
|
1111
|
-
(
|
|
1244
|
+
(_8 = api.emitEvent) === null || _8 === void 0 ? void 0 : _8.call(api, "nodeError", { nodeId, flowId: flowReferenceId, errorMessage: error });
|
|
1112
1245
|
if (logErrorToSystem) {
|
|
1113
|
-
(
|
|
1246
|
+
(_9 = api.log) === null || _9 === void 0 ? void 0 : _9.call(api, "error", JSON.stringify(errorDetails));
|
|
1114
1247
|
}
|
|
1115
1248
|
if (errorHandling !== "stop") {
|
|
1116
|
-
(
|
|
1249
|
+
(_10 = api.logDebugError) === null || _10 === void 0 ? void 0 : _10.call(api, errorDetails.message + (errorDetails.code ? ` (error code: ${errorDetails.code})` : ""), errorDetails.name);
|
|
1117
1250
|
}
|
|
1118
1251
|
if (storeErrorInInput) {
|
|
1119
1252
|
input.aiAgent = input.aiAgent || {};
|
|
@@ -1122,7 +1255,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1122
1255
|
if (errorHandling === "continue") {
|
|
1123
1256
|
// output the timeout message
|
|
1124
1257
|
if (errorMessage) {
|
|
1125
|
-
yield ((
|
|
1258
|
+
yield ((_11 = api.output) === null || _11 === void 0 ? void 0 : _11.call(api, errorMessage, null));
|
|
1126
1259
|
}
|
|
1127
1260
|
// Set default node as next node
|
|
1128
1261
|
const defaultChild = childConfigs.find(child => child.type === "aiAgentJobDefault");
|
|
@@ -1134,7 +1267,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1134
1267
|
if (!errorHandlingGotoTarget) {
|
|
1135
1268
|
throw new Error("GoTo Target is required");
|
|
1136
1269
|
}
|
|
1137
|
-
if (!((
|
|
1270
|
+
if (!((_12 = api.checkThink) === null || _12 === void 0 ? void 0 : _12.call(api, nodeId))) {
|
|
1138
1271
|
api.resetNextNodes();
|
|
1139
1272
|
yield api.executeFlow({
|
|
1140
1273
|
flowNode: {
|
|
@@ -17,6 +17,26 @@ export const CHECK_AGENT_AVAILABILITY = createNodeDescriptor({
|
|
|
17
17
|
},
|
|
18
18
|
tags: ["service"],
|
|
19
19
|
fields: [
|
|
20
|
+
{
|
|
21
|
+
key: "checkAgentAvailabilityProvider",
|
|
22
|
+
label: "UI__NODE_EDITOR__SERVICE__HANDOVER_TO_AGENT__FIELDS__HANDOVER_PROVIDER__LABEL",
|
|
23
|
+
type: "checkAgentAvailabilityProvider",
|
|
24
|
+
description: "UI__NODE_EDITOR__SERVICE__HANDOVER_TO_AGENT__FIELDS__HANDOVER_PROVIDER__DESCRIPTION",
|
|
25
|
+
defaultValue: "legacyEndpoint",
|
|
26
|
+
params: {
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
key: "checkAgentAvailabilityConfig",
|
|
32
|
+
label: "UI__NODE_EDITOR__SERVICE__HANDOVER_TO_AGENT__FIELDS__HANDOVER_PROVIDER__LABEL",
|
|
33
|
+
type: "json",
|
|
34
|
+
description: "UI__NODE_EDITOR__SERVICE__HANDOVER_TO_AGENT__FIELDS__HANDOVER_PROVIDER__DESCRIPTION",
|
|
35
|
+
defaultValue: {},
|
|
36
|
+
params: {
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
20
40
|
{
|
|
21
41
|
key: "chatwootInboxId",
|
|
22
42
|
type: "cognigyText",
|
|
@@ -151,7 +171,20 @@ export const CHECK_AGENT_AVAILABILITY = createNodeDescriptor({
|
|
|
151
171
|
defaultCollapsed: true,
|
|
152
172
|
fields: [
|
|
153
173
|
"chatwootInboxId",
|
|
154
|
-
]
|
|
174
|
+
],
|
|
175
|
+
condition: {
|
|
176
|
+
or: [
|
|
177
|
+
{
|
|
178
|
+
key: "checkAgentAvailabilityProvider",
|
|
179
|
+
value: "legacyEndpoint"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
key: "checkAgentAvailabilityProvider",
|
|
183
|
+
// @ts-ignore
|
|
184
|
+
value: null
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
}
|
|
155
188
|
},
|
|
156
189
|
{
|
|
157
190
|
key: "liveAgentSettings",
|
|
@@ -161,7 +194,20 @@ export const CHECK_AGENT_AVAILABILITY = createNodeDescriptor({
|
|
|
161
194
|
COGNIGY_LIVE_AGENT_DESCRIPTOR_FIELDS.LIVE_AGENT_INBOX_ID,
|
|
162
195
|
COGNIGY_LIVE_AGENT_DESCRIPTOR_FIELDS.LIVE_AGENT_SKILLS,
|
|
163
196
|
COGNIGY_LIVE_AGENT_DESCRIPTOR_FIELDS.LIVE_AGENT_LANGUAGES,
|
|
164
|
-
]
|
|
197
|
+
],
|
|
198
|
+
condition: {
|
|
199
|
+
or: [
|
|
200
|
+
{
|
|
201
|
+
key: "checkAgentAvailabilityProvider",
|
|
202
|
+
value: "legacyEndpoint"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
key: "checkAgentAvailabilityProvider",
|
|
206
|
+
// @ts-ignore
|
|
207
|
+
value: null
|
|
208
|
+
}
|
|
209
|
+
]
|
|
210
|
+
}
|
|
165
211
|
},
|
|
166
212
|
{
|
|
167
213
|
key: "genesysCloudSettings",
|
|
@@ -171,7 +217,20 @@ export const CHECK_AGENT_AVAILABILITY = createNodeDescriptor({
|
|
|
171
217
|
"genesysCloudSkills",
|
|
172
218
|
"genesysCloudProfileSkills",
|
|
173
219
|
"genesysCloudLanguageSkills"
|
|
174
|
-
]
|
|
220
|
+
],
|
|
221
|
+
condition: {
|
|
222
|
+
or: [
|
|
223
|
+
{
|
|
224
|
+
key: "checkAgentAvailabilityProvider",
|
|
225
|
+
value: "legacyEndpoint"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
key: "checkAgentAvailabilityProvider",
|
|
229
|
+
// @ts-ignore
|
|
230
|
+
value: null
|
|
231
|
+
}
|
|
232
|
+
]
|
|
233
|
+
}
|
|
175
234
|
},
|
|
176
235
|
{
|
|
177
236
|
key: "storage",
|
|
@@ -195,6 +254,7 @@ export const CHECK_AGENT_AVAILABILITY = createNodeDescriptor({
|
|
|
195
254
|
}
|
|
196
255
|
],
|
|
197
256
|
form: [
|
|
257
|
+
{ type: "field", key: "checkAgentAvailabilityProvider" },
|
|
198
258
|
{ type: "section", key: "genesysCloudSettings" },
|
|
199
259
|
// only render this field if "live agent" is enabled
|
|
200
260
|
process.env.FEATURE_USE_COGNIGY_LIVE_AGENT === "true" && {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const LIVE_AGENT_CONNECTION = {
|
|
2
|
+
type: "live_agent",
|
|
3
|
+
label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__LIVE_AGENT_CONNECTION_AUTHENTICATION__LABEL",
|
|
4
|
+
fields: [
|
|
5
|
+
{ fieldName: "apiKey", label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__LIVE_AGENT__API_KEY__LABEL" }
|
|
6
|
+
]
|
|
7
|
+
};
|
|
8
|
+
export const RINGCENTRAL_ENGAGE_CONNECTION = {
|
|
9
|
+
type: "ringcentral_engage",
|
|
10
|
+
label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__RINGCENTRAL_ENGAGE_CONNECTION_AUTHENTICATION__LABEL",
|
|
11
|
+
fields: [
|
|
12
|
+
{ fieldName: "webhookSecret", label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__RINGCENTRAL_ENGAGE__WEBHOOK_SECRET__LABEL" },
|
|
13
|
+
{ fieldName: "realtimeAccessToken", label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__RINGCENTRAL_ENGAGE__REALTIME_ACCESS_TOKEN__LABEL" },
|
|
14
|
+
{ fieldName: "apiAccessToken", label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__RINGCENTRAL_ENGAGE__API_ACCESS_TOKEN__LABEL" }
|
|
15
|
+
]
|
|
16
|
+
};
|
|
17
|
+
export const CHATWOOT_CONNECTION = {
|
|
18
|
+
type: "chatwoot",
|
|
19
|
+
label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__CHATWOOT_CONNECTION_AUTHENTICATION__LABEL",
|
|
20
|
+
fields: [
|
|
21
|
+
{ fieldName: "apiKey", label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__CHATWOOT__API_KEY__LABEL" }
|
|
22
|
+
]
|
|
23
|
+
};
|
|
24
|
+
export const EIGHT_BY_EIGHT_CONNECTION = {
|
|
25
|
+
type: "eight_by_eight",
|
|
26
|
+
label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__EIGHTBYEIGHT_CONNECTION_AUTHENTICATION__LABEL",
|
|
27
|
+
fields: [
|
|
28
|
+
{ fieldName: "apiAccessToken", label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__EIGHTBYEIGHT__API_ACCESS_TOKEN__LABEL" }
|
|
29
|
+
]
|
|
30
|
+
};
|
|
31
|
+
export const GENESYS_CLOUD_CONNECTION = {
|
|
32
|
+
type: "genesys_cloud",
|
|
33
|
+
label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__GENESYS_CLOUD_CONNECTION_AUTHENTICATION__LABEL",
|
|
34
|
+
fields: [
|
|
35
|
+
{ fieldName: "clientId", label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__GENESYS_CLOUD__CLIENT_ID__LABEL" },
|
|
36
|
+
{ fieldName: "clientSecret", label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__GENESYS_CLOUD__CLIENT_SECRET__LABEL" },
|
|
37
|
+
]
|
|
38
|
+
};
|
|
39
|
+
export const GENESYS_CLOUD_CONNECTION_OM = {
|
|
40
|
+
type: "genesys_cloud_om",
|
|
41
|
+
label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__GENESYS_CLOUD_CONNECTION_AUTHENTICATION__LABEL",
|
|
42
|
+
fields: [
|
|
43
|
+
{ fieldName: "clientId", label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__GENESYS_CLOUD__CLIENT_ID__LABEL" },
|
|
44
|
+
{ fieldName: "clientSecret", label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__GENESYS_CLOUD__CLIENT_SECRET__LABEL" },
|
|
45
|
+
{ fieldName: "webhookSecret", label: "UI__HANDOVER_PROVIDER_EDITOR__HANDOVER_FORM__GENESYS_CLOUD__WEBHOOK_SECRET__LABEL" }
|
|
46
|
+
]
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=handoverConnections.js.map
|