@cognigy/rest-api-client 2025.18.0 → 2025.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/authentication/AuthenticationAPI.js +1 -1
  3. package/build/authentication/OAuth2/OAuth2Authentication.js +12 -9
  4. package/build/connector/AxiosAdapter.js +6 -2
  5. package/build/shared/charts/descriptors/service/GPTPrompt.js +2 -2
  6. package/build/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +2 -2
  7. package/build/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +2 -2
  8. package/build/shared/charts/descriptors/voice/mappers/transfer.mapper.js +20 -6
  9. package/build/shared/charts/descriptors/voicegateway2/nodes/transfer.js +39 -3
  10. package/build/shared/generativeAI/utils/generativeAIPrompts.js +17 -446
  11. package/build/shared/generativeAI/utils/prompts/flowGeneration.js +168 -0
  12. package/build/shared/generativeAI/utils/prompts/generateNodeOutput.js +39 -0
  13. package/build/shared/generativeAI/utils/prompts/intentSentenceGeneration.js +15 -0
  14. package/build/shared/generativeAI/utils/prompts/lexiconGeneration.js +22 -0
  15. package/build/shared/interfaces/generativeAI/IGenerativeAIModels.js +4 -0
  16. package/build/shared/interfaces/handover.js +3 -1
  17. package/build/shared/interfaces/messageAPI/endpoints.js +5 -2
  18. package/build/shared/interfaces/resources/INodeDescriptorSet.js +87 -77
  19. package/dist/esm/authentication/AuthenticationAPI.js +1 -1
  20. package/dist/esm/authentication/OAuth2/OAuth2Authentication.js +12 -9
  21. package/dist/esm/connector/AxiosAdapter.js +6 -2
  22. package/dist/esm/shared/charts/descriptors/service/GPTPrompt.js +1 -1
  23. package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +1 -1
  24. package/dist/esm/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +1 -1
  25. package/dist/esm/shared/charts/descriptors/voice/mappers/transfer.mapper.js +20 -6
  26. package/dist/esm/shared/charts/descriptors/voicegateway2/nodes/transfer.js +39 -3
  27. package/dist/esm/shared/generativeAI/utils/generativeAIPrompts.js +16 -445
  28. package/dist/esm/shared/generativeAI/utils/prompts/flowGeneration.js +165 -0
  29. package/dist/esm/shared/generativeAI/utils/prompts/generateNodeOutput.js +36 -0
  30. package/dist/esm/shared/generativeAI/utils/prompts/intentSentenceGeneration.js +12 -0
  31. package/dist/esm/shared/generativeAI/utils/prompts/lexiconGeneration.js +19 -0
  32. package/dist/esm/shared/interfaces/generativeAI/IGenerativeAIModels.js +4 -0
  33. package/dist/esm/shared/interfaces/handover.js +3 -1
  34. package/dist/esm/shared/interfaces/messageAPI/endpoints.js +5 -2
  35. package/dist/esm/shared/interfaces/resources/INodeDescriptorSet.js +88 -78
  36. package/package.json +1 -1
  37. package/types/index.d.ts +1045 -1016
@@ -2,8 +2,8 @@ import { __awaiter, __rest } from "tslib";
2
2
  /* Custom modules */
3
3
  import { createNodeDescriptor } from "../../../createNodeDescriptor";
4
4
  import { GO_TO } from "../../logic";
5
- import { randomUUID } from 'crypto';
6
5
  import { createToolDefinitions } from "../aiAgent/helpers/createToolDefinitions";
6
+ import { v4 as randomUUID } from "uuid";
7
7
  import { createLastConverationString, createLastUserInputString, writeLLMDebugLogs } from "../../nlu/generativeSlotFiller/prompt";
8
8
  import { InternalServerError } from "../../../../errors";
9
9
  import { TranscriptEntryType, TranscriptRole } from "../../../../interfaces/transcripts/transcripts";
@@ -2,7 +2,7 @@
2
2
  import { cleanTarget } from "../../../descriptors/voicegateway2/utils/helper";
3
3
  import { isValidUrl, isValidPhoneNumber } from "../utils/helper";
4
4
  export const transfer = {
5
- handleInput(endpointType, params, isGenericNode = false, recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, anchorMedia) {
5
+ handleInput(endpointType, params, isGenericNode = false, recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, mediaPath, anchorMedia) {
6
6
  try {
7
7
  switch (endpointType) {
8
8
  case "bandwidth":
@@ -21,14 +21,14 @@ export const transfer = {
21
21
  return this.handleAudioCodesInput(prepareTransferParams(params), endpointType);
22
22
  case "voiceGateway2":
23
23
  default:
24
- return this.handleVGInput(prepareTransferParams(params), recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, anchorMedia);
24
+ return this.handleVGInput(prepareTransferParams(params), recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, mediaPath, anchorMedia);
25
25
  }
26
26
  }
27
27
  catch (error) {
28
28
  throw Error(error.message);
29
29
  }
30
30
  },
31
- handleVGInput(transferParam, recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, anchorMedia) {
31
+ handleVGInput(transferParam, recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, mediaPath, anchorMedia) {
32
32
  const { transferType, transferTarget, transferReason, referredBy, useTransferSipHeaders, transferSipHeaders, dialMusic, dialTranscriptionWebhook, dialCallerId, amdEnabled, amdRedirectOnMachineDetected, amdRedirectText, dialTimeout, timeLimit, sttLabel } = transferParam;
33
33
  const payload = {
34
34
  _voiceGateway2: {
@@ -52,6 +52,19 @@ export const transfer = {
52
52
  if (timeLimit && timeLimit > 0) {
53
53
  dialVerb.timeLimit = timeLimit;
54
54
  }
55
+ if (process.env.FEATURE_DISABLE_VG_MEDIA_PATH === "true") {
56
+ if (typeof anchorMedia === "boolean") {
57
+ dialVerb.anchorMedia = anchorMedia;
58
+ }
59
+ }
60
+ else {
61
+ if (mediaPath) {
62
+ dialVerb.mediaPath = mediaPath;
63
+ }
64
+ else if (typeof anchorMedia === "boolean") {
65
+ dialVerb.mediaPath = anchorMedia ? "fullMedia" : "partialMedia";
66
+ }
67
+ }
55
68
  if (amdEnabled) {
56
69
  dialVerb.amd = {
57
70
  actionHook: "amd"
@@ -72,6 +85,9 @@ export const transfer = {
72
85
  };
73
86
  /* By default we set the target to phone */
74
87
  dialVerb.target = [phoneTarget];
88
+ if (process.env.FEATURE_DISABLE_VG_MEDIA_PATH === "true") {
89
+ delete dialVerb.mediaPath;
90
+ }
75
91
  /* If targets includes an @ we set the target to sip */
76
92
  if (transferTarget === null || transferTarget === void 0 ? void 0 : transferTarget.includes("@")) {
77
93
  dialVerb.target = [sipTarget];
@@ -134,12 +150,10 @@ export const transfer = {
134
150
  }
135
151
  dialVerb.callerId = dialCallerId;
136
152
  }
137
- if (anchorMedia) {
138
- dialVerb.anchorMedia = anchorMedia;
139
- }
140
153
  payload._voiceGateway2.json["dial"] = dialVerb;
141
154
  break;
142
155
  case "refer":
156
+ mediaPath = undefined;
143
157
  default:
144
158
  const referVerb = {
145
159
  "referTo": cleanTarget(transferTarget, false),
@@ -79,6 +79,33 @@ export const transferNode = createNodeDescriptor({
79
79
  value: "dial"
80
80
  }
81
81
  },
82
+ {
83
+ key: "mediaPath",
84
+ label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__MEDIA_PATH__LABEL",
85
+ type: "select",
86
+ description: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__MEDIA_PATH__DESCRIPTION",
87
+ defaultValue: "partialMedia",
88
+ params: {
89
+ options: [
90
+ {
91
+ label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__MEDIA_PATH__OPTIONS__FULL_MEDIA__LABEL",
92
+ value: "fullMedia"
93
+ },
94
+ {
95
+ label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__MEDIA_PATH__OPTIONS__PARTIAL_MEDIA__LABEL",
96
+ value: "partialMedia"
97
+ },
98
+ {
99
+ label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__MEDIA_PATH__OPTIONS__NO_MEDIA__LABEL",
100
+ value: "noMedia"
101
+ }
102
+ ]
103
+ },
104
+ condition: {
105
+ key: "transferType",
106
+ value: "dial"
107
+ }
108
+ },
82
109
  {
83
110
  key: "useTransferSipHeaders",
84
111
  label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__USE_TRANSFER_SIP_HEADERS__LABEL",
@@ -460,7 +487,7 @@ export const transferNode = createNodeDescriptor({
460
487
  defaultCollapsed: true,
461
488
  fields: [
462
489
  "referredBy",
463
- "anchorMedia",
490
+ process.env.FEATURE_DISABLE_VG_MEDIA_PATH === "true" ? "anchorMedia" : "mediaPath",
464
491
  "useTransferSipHeaders",
465
492
  "transferSipHeaders",
466
493
  "enableAnsweringMachineDetection"
@@ -524,7 +551,7 @@ export const transferNode = createNodeDescriptor({
524
551
  summary: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__SUMMARY",
525
552
  function: ({ cognigy, config, }) => __awaiter(void 0, void 0, void 0, function* () {
526
553
  const { api, input } = cognigy;
527
- const { transferType, transferTarget, referredBy, anchorMedia, useTransferSipHeaders, transferSipHeaders = {}, transferReason, dialMusic, dialTranscriptionWebhook, dialCallerId, recognitionChannel, sttVendor, sttLanguage, sttDisablePunctuation, dialTimeout, enableTimeLimit, timeLimit, amdEnabled, amdRedirectOnMachineDetected, amdRedirectText, sttLabel, googleModel, sttDeepgramModel, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, agentAssistEnabled, agentAssistHeadersKey = customHeaderDefaultValue } = config;
554
+ const { transferType, transferTarget, referredBy, mediaPath, useTransferSipHeaders, transferSipHeaders = {}, transferReason, dialMusic, dialTranscriptionWebhook, dialCallerId, recognitionChannel, sttVendor, sttLanguage, sttDisablePunctuation, dialTimeout, enableTimeLimit, timeLimit, amdEnabled, amdRedirectOnMachineDetected, amdRedirectText, sttLabel, googleModel, sttDeepgramModel, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, agentAssistEnabled, agentAssistHeadersKey = customHeaderDefaultValue, anchorMedia } = config;
528
555
  const transferParams = {
529
556
  transferType,
530
557
  transferReason,
@@ -542,6 +569,7 @@ export const transferNode = createNodeDescriptor({
542
569
  timeLimit,
543
570
  sttLabel,
544
571
  };
572
+ let media = mediaPath;
545
573
  try {
546
574
  if (input.channel === "adminconsole") {
547
575
  let textWarningAdminChannel = "Transferring a call is not supported in the Interaction Panel, please use the VoiceGateway endpoint.";
@@ -554,6 +582,14 @@ export const transferNode = createNodeDescriptor({
554
582
  if (!enableTimeLimit) {
555
583
  delete transferParams.timeLimit;
556
584
  }
585
+ if (transferType === "dial" && typeof anchorMedia === "boolean" && (mediaPath === null || mediaPath === undefined) && process.env.FEATURE_DISABLE_VG_MEDIA_PATH === "false") {
586
+ if (anchorMedia) {
587
+ media = "fullMedia";
588
+ }
589
+ else {
590
+ media = "partialMedia";
591
+ }
592
+ }
557
593
  if (agentAssistEnabled && dialTranscriptionWebhook) {
558
594
  try {
559
595
  const agentAssistConfigId = api.getAgentAssistConfigId();
@@ -589,7 +625,7 @@ export const transferNode = createNodeDescriptor({
589
625
  transferParams.useTransferSipHeaders = false;
590
626
  api.log("error", "Invalid JSON in Transfer SIP Headers");
591
627
  }
592
- const payload = transfer.handleInput("voiceGateway2", transferParams, false, recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, anchorMedia);
628
+ const payload = transfer.handleInput("voiceGateway2", transferParams, false, recognitionChannel, sttVendor, sttLanguage, googleModel, sttDeepgramModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, media, anchorMedia);
593
629
  yield api.say(null, {
594
630
  _cognigy: payload,
595
631
  });
@@ -1,264 +1,10 @@
1
1
  /** Prompts **/
2
2
  import { contextAwareUserQueryRephrasingChatPrompt, alternativeContextAwareUserQueryRephrasingChatPrompt, } from "./prompts/contextAwareUserQueryRephrasing";
3
3
  import { rephraseMultipleSentencesPrompt, rephraseSingleSentencePrompt, rephraseQuestionPrompt, rephraseQuestionRepromptPrompt } from "./prompts/rephraseSentences";
4
- export const flowGenerationPromptWithTranscriptForGpt4oAndMini = `Create a new bot called "@@name" based on the following transcript example between the bot and a user:
5
-
6
- # Transcript:
7
-
8
- @@text
9
-
10
- Write the bot in @@lng. Consider the following list of constraints:
11
-
12
- # Instructions:
13
-
14
- ## Do only use flow nodes of the following list. Do not use other nodes.
15
-
16
- ## The configurable parameters are listed in brackets:
17
- - say "Say stuff and output something using {{Node.js Code}}"
18
- - question (output: "context.variable", validation: "text|yesNo|number|email|url", options: "Option 1|Option 2|Option 3") "Ask question with {{Node.js Code}} support?"
19
- - backendCall (output: "context.variable") "Call external API"
20
- - code "Node.js Code"
21
- - switch "Node.js Code"
22
- - case
23
- - default
24
- - if "Node.js Code"
25
- - then
26
- - else
27
-
28
- # Examples:
29
-
30
- ## Example flow in English:
31
-
32
- - question (output: "context.email", validation: "email") "What is your email address?"
33
- - question (output: "context.url", validation: "url") "And what is the URL?"
34
- - code "function areDomainsSame(email, url) { let emailSplit = email.split('@'); let urlSplit = url.split('.'); if (emailSplit[1] === urlSplit[1]) { return true; } return false;} context.areDomainsSame = areDomainsSame(context.email, context.url);"
35
- - if "context.areDomainsSame === true"
36
- - then
37
- - say "The domains are the same."
38
- - else
39
- - say "The domains are not the same."
40
-
41
- ## Example flow in German:
42
-
43
- - say "Hallo, ich bin ein Faktenprüfer. Ich entlarve Mythen durch Fakten."
44
- - question (output: "context.color", validation: "text", options: "rot|grün|blau") "Welche Farbe hat der Himmel?"
45
- - switch "context.color"
46
- - case "blau"
47
- - say "Du hast recht, das ist eine Tatsache."
48
- - case "rot"
49
- - say "Ja tatsächlich, manchmal ist der Himmel sogar rot."
50
- - default
51
- - say "Nein, der Himmel ist tagsüber normalerweise blau."
52
-
53
- ## Example flow in Spanish:
54
-
55
- - say "Hola, puedo conectarlo con nuestro equipo de soporte."
56
- - question (output: "context.wantsSupport", validation: "yesNo") "¿Te gustaría contactar el soporte?"
57
- - if "context.wantsSupport === true"
58
- - then
59
- - backendCall (output: "context.contactDetails") "call API to retrieve contact details of support"
60
- - say "Aquí tienes. Por favor vea los detalles de contacto de nuestro soporte: {{context.contactDetails}}"
61
- - else
62
- - backendCall (output: "context.success") "call API to log decision"
63
-
64
- # Additional information:
65
-
66
- ## Say nodes and question nodes execute Node.js in double curly braces, for example:
67
-
68
- - say "This is a {{context.variable.toLowerCase()}}"
69
- - question (output: "context.result", validation: "text") "Do you like {{"banana".toUpperCase()}}?"
70
-
71
- ## When using the option parameter then use human-readable text and more than one option.
72
- ## Only use a switch node when considering multiple options.
73
- ## When using a switch node then always use a default node as last resort.
74
- ## Do not use a backendCall if a Code Node can solve it.
75
- ## Dot not use "for" nodes to simulate a for-loop.
76
- ## Use a smallest amount of flow nodes possible.
77
-
78
- ## Return just a list of nodes following the required format and instructions, and nothing else.`;
79
- export const flowGenerationPromptWithDescriptionForGpt4oAndMini = `Create a new bot called "@@name" with the following description:
80
- "@@text" Write the bot in @@lng. Consider the following list of constraints:
81
-
82
- # Instructions:
83
-
84
- ## Do only use flow nodes of the following list. Do not use other nodes.
85
-
86
- ## The configurable parameters are listed in brackets:
87
- - say "Say stuff and output something using {{Node.js Code}}"
88
- - question (output: "context.variable", validation: "text|yesNo|number|email|url", options: "Option 1|Option 2|Option 3") "Ask question with {{Node.js Code}} support?"
89
- - backendCall (output: "context.variable") "Call external API"
90
- - code "Node.js Code"
91
- - switch "Node.js Code"
92
- - case
93
- - default
94
- - if "Node.js Code"
95
- - then
96
- - else
97
-
98
- # Examples:
99
-
100
- ## Example flow in English:
101
-
102
- - question (output: "context.email", validation: "email") "What is your email address?"
103
- - question (output: "context.url", validation: "url") "And what is the URL?"
104
- - code "function areDomainsSame(email, url) { let emailSplit = email.split('@'); let urlSplit = url.split('.'); if (emailSplit[1] === urlSplit[1]) { return true; } return false;} context.areDomainsSame = areDomainsSame(context.email, context.url);"
105
- - if "context.areDomainsSame === true"
106
- - then
107
- - say "The domains are the same."
108
- - else
109
- - say "The domains are not the same."
110
-
111
- ## Example flow in German:
112
-
113
- - say "Hallo, ich bin ein Faktenprüfer. Ich entlarve Mythen durch Fakten."
114
- - question (output: "context.color", validation: "text", options: "rot|grün|blau") "Welche Farbe hat der Himmel?"
115
- - switch "context.color"
116
- - case "blau"
117
- - say "Du hast recht, das ist eine Tatsache."
118
- - case "rot"
119
- - say "Ja tatsächlich, manchmal ist der Himmel sogar rot."
120
- - default
121
- - say "Nein, der Himmel ist tagsüber normalerweise blau."
122
-
123
- ## Example flow in Spanish:
124
-
125
- - say "Hola, puedo conectarlo con nuestro equipo de soporte."
126
- - question (output: "context.wantsSupport", validation: "yesNo") "¿Te gustaría contactar el soporte?"
127
- - if "context.wantsSupport === true"
128
- - then
129
- - backendCall (output: "context.contactDetails") "call API to retrieve contact details of support"
130
- - say "Aquí tienes. Por favor vea los detalles de contacto de nuestro soporte: {{context.contactDetails}}"
131
- - else
132
- - backendCall (output: "context.success") "call API to log decision"
133
-
134
- # Additional information:
135
-
136
- ## Say nodes and question nodes execute Node.js in double curly braces, for example:
137
- - say "This is a {{context.variable.toLowerCase()}}"
138
- - question (output: "context.result", validation: "text") "Do you like {{"banana".toUpperCase()}}?"
139
-
140
- ## When using the option parameter then use human-readable text and more than one option.
141
- ## Only use a switch node when considering multiple options.
142
- ## When using a switch node then always use a default node as last resort.
143
- ## Do not use a backendCall if a Code Node can solve it.
144
- ## Dot not use "for" nodes to simulate a for-loop.
145
- ## Use a smallest amount of flow nodes possible.
146
-
147
- ## Return just a list of nodes following the required format and instructions, and nothing else.`;
148
- export const flowGenerationPromptWithTranscriptForGpt35Turbo = `Create a new bot called "@@name" with the following transcript between the bot and a user: "@@text"
149
- Write the bot in @@lng. Consider the following list of constraints:
150
- 1. Do only use flow nodes of the following list. Do not use other nodes. The configurable parameters are listed in brackets:
151
- - say "Say stuff and output something using {{Node.js Code}}"
152
- - question (output: "context.variable", validation: "text|yesNo|number|email|url", options: "Option 1|Option 2|Option 3") "Ask question with {{Node.js Code}} support?"
153
- - backendCall (output: "context.variable") "Call external API"
154
- - code "Node.js Code"
155
- - switch "Node.js Code"
156
- - case
157
- - default
158
- - if "Node.js Code"
159
- - then
160
- - else
161
- 2. Example flow in English:
162
- - question (output: "context.email", validation: "email") "What is your email address?"
163
- - question (output: "context.url", validation: "url") "And what is the URL?"
164
- - code "function areDomainsSame(email, url) { let emailSplit = email.split('@'); let urlSplit = url.split('.'); if (emailSplit[1] === urlSplit[1]) { return true; } return false;} context.areDomainsSame = areDomainsSame(context.email, context.url);"
165
- - if "context.areDomainsSame === true"
166
- - then
167
- - say "The domains are the same."
168
- - else
169
- - say "The domains are not the same."
170
- 3. Example flow in German:
171
- - say "Hallo, ich bin ein Faktenprüfer. Ich entlarve Mythen durch Fakten."
172
- - question (output: "context.color", validation: "text", options: "rot|grün|blau") "Welche Farbe hat der Himmel?"
173
- - switch "context.color"
174
- - case "blau"
175
- - say "Du hast recht, das ist eine Tatsache."
176
- - case "rot"
177
- - say "Ja tatsächlich, manchmal ist der Himmel sogar rot."
178
- - default
179
- - say "Nein, der Himmel ist tagsüber normalerweise blau."
180
- 4. Example flow in Spanish:
181
- - say "Hola, puedo conectarlo con nuestro equipo de soporte."
182
- - question (output: "context.wantsSupport", validation: "yesNo") "¿Te gustaría contactar el soporte?"
183
- - if "context.wantsSupport === true"
184
- - then
185
- - backendCall (output: "context.contactDetails") "call API to retrieve contact details of support"
186
- - say "Aquí tienes. Por favor vea los detalles de contacto de nuestro soporte: {{context.contactDetails}}"
187
- - else
188
- - backendCall (output: "context.success") "call API to log decision"
189
- 5. Say nodes and question nodes execute Node.js in double curly braces, for example:
190
- - say "This is a {{context.variable.toLowerCase()}}"
191
- - question (output: "context.result", validation: "text") "Do you like {{"banana".toUpperCase()}}?"
192
- 6. When using the option parameter then use human-readable text and more than one option.
193
- 7. Only use a switch node when considering multiple options.
194
- 8. When using a switch node then always use a default node as last resort.
195
- 9. Do not use a backendCall if a Code Node can solve it.
196
- 10. Dot not use "for" nodes to simulate a for-loop.
197
- 11. Use a smallest amount of flow nodes possible.
198
- 12. Lets think step by step.
199
- `;
200
- export const flowGenerationPromptWithDescriptionForGpt35Turbo = `Create a new bot called "@@name" with the following description:
201
- "@@text" Write the bot in @@lng. Consider the following list of constraints:
202
- 1. Do only use flow nodes of the following list. Do not use other nodes. The configurable parameters are listed in brackets:
203
- - say "Say stuff and output something using {{Node.js Code}}"
204
- - question (output: "context.variable", validation: "text|yesNo|number|email|url", options: "Option 1|Option 2|Option 3") "Ask question with {{Node.js Code}} support?"
205
- - backendCall (output: "context.variable") "Call external API"
206
- - code "Node.js Code"
207
- - switch "Node.js Code"
208
- - case
209
- - default
210
- - if "Node.js Code"
211
- - then
212
- - else
213
- 2. Example flow in English:
214
- - question (output: "context.email", validation: "email") "What is your email address?"
215
- - question (output: "context.url", validation: "url") "And what is the URL?"
216
- - code "function areDomainsSame(email, url) { let emailSplit = email.split('@'); let urlSplit = url.split('.'); if (emailSplit[1] === urlSplit[1]) { return true; } return false;} context.areDomainsSame = areDomainsSame(context.email, context.url);"
217
- - if "context.areDomainsSame === true"
218
- - then
219
- - say "The domains are the same."
220
- - else
221
- - say "The domains are not the same."
222
- 3. Example flow in German:
223
- - say "Hallo, ich bin ein Faktenprüfer. Ich entlarve Mythen durch Fakten."
224
- - question (output: "context.color", validation: "text", options: "rot|grün|blau") "Welche Farbe hat der Himmel?"
225
- - switch "context.color"
226
- - case "blau"
227
- - say "Du hast recht, das ist eine Tatsache."
228
- - case "rot"
229
- - say "Ja tatsächlich, manchmal ist der Himmel sogar rot."
230
- - default
231
- - say "Nein, der Himmel ist tagsüber normalerweise blau."
232
- 4. Example flow in Spanish:
233
- - say "Hola, puedo conectarlo con nuestro equipo de soporte."
234
- - question (output: "context.wantsSupport", validation: "yesNo") "¿Te gustaría contactar el soporte?"
235
- - if "context.wantsSupport === true"
236
- - then
237
- - backendCall (output: "context.contactDetails") "call API to retrieve contact details of support"
238
- - say "Aquí tienes. Por favor vea los detalles de contacto de nuestro soporte: {{context.contactDetails}}"
239
- - else
240
- - backendCall (output: "context.success") "call API to log decision"
241
- 5. Say nodes and question nodes execute Node.js in double curly braces, for example:
242
- - say "This is a {{context.variable.toLowerCase()}}"
243
- - question (output: "context.result", validation: "text") "Do you like {{"banana".toUpperCase()}}?"
244
- 6. When using the option parameter then use human-readable text and more than one option.
245
- 7. Only use a switch node when considering multiple options.
246
- 8. When using a switch node then always use a default node as last resort.
247
- 9. Do not use a backendCall if a Code Node can solve it.
248
- 10. Dot not use "for" nodes to simulate a for-loop.
249
- 11. Use a smallest amount of flow nodes possible.
250
- 12. The output must start with a valid node from the list above.
251
- 13. Lets think step by step.
252
- 14. Return just a list of nodes listed in constrain 1, and nothing else.`;
253
- export const SENTENCE_GENERATION_PROMPT_UNIVERSAL = `For NLU model intent '@@name'<description> with the description '@@description'</description>. Create @@noOfSentencesToGenerate varied sentences other than the given examples<language> in @@language</language>. Return nothing but a JSON array of strings.\n<default-reply>Also, consider framing the sentences like a user question that a human would answer: @@defaultReply.\n</default-reply><example-sentences>Examples: @@exampleSentences \n</example-sentences>`;
254
- export const GENERATE_ADAPTIVE_CARD_PROMPT_UNIVERSAL = `Create an adaptiveCard based on the description: "@@description" in @@language. Return nothing but the Adaptive Card JSON object. Your Adaptive Card should accurately reflect the requirements described in the description, while still adhering to the Adaptive Card JSON specification.`;
255
- export const MODIFY_ADAPTIVE_CARD_PROMPT_UNIVERSAL = `Please modify the @@lastOutput Adaptive Card JSON based on the provided instruction "@@description". Return nothing but the Adaptive Card JSON object. The language of the Adaptive Card text should be @@language. Your modified Adaptive Card should accurately reflect the changes described in the description, while still adhering to the Adaptive Card JSON specification.`;
256
- export const LEXICON_GENERATION_PROMPT_UNIVERSAL = 'For the NLU model lexicon with the title "@@name" and the description "@@description",' +
257
- ' generate @@lexiconEntries varied words in "@@lng".@@synonymInstructions' +
258
- '\n\nRespond with a valid JSON with the format following the example: `@@example`';
259
- export const LEXICON_GENERATION_PROMPT_SYNONYM_INSTRUCTIONS = " For each word, also list all known synonyms. The number of synonyms for each word does not have to be the same.";
260
- export const LEXICON_GENERATION_RESPONSE_EXAMPLE = '[{"word": "test","synonyms": ["trial","attempt"]},{"word": "demo","synonyms": ["proof of concept"]}]';
261
- export const LEXICON_GENERATION_RESPONSE_EXAMPLE_NO_SYNONYMS = '[{"word": "test"},{"word": "demo"}]';
4
+ import { flowGenerationWithDescriptionPrompt, flowGenerationWithTranscriptPrompt } from "./prompts/flowGeneration";
5
+ import { intentSentenceGenerationPrompt } from "./prompts/intentSentenceGeneration";
6
+ import { lexiconGenerationPrompt } from "./prompts/lexiconGeneration";
7
+ import { generateNodeOutputCreateAdaptiveCardPrompt, generateNodeOutputModifyAdaptiveCardPrompt, generateNodeOutputTextPrompt } from "./prompts/generateNodeOutput";
262
8
  export const generativeAIPrompts = {
263
9
  "default": {
264
10
  answerExtraction: {
@@ -270,6 +16,17 @@ export const generativeAIPrompts = {
270
16
  question: rephraseQuestionPrompt,
271
17
  questionReprompt: rephraseQuestionRepromptPrompt
272
18
  },
19
+ intentSentenceGeneration: intentSentenceGenerationPrompt,
20
+ generateNodeOutput: {
21
+ text: generateNodeOutputTextPrompt,
22
+ adaptiveCard: generateNodeOutputCreateAdaptiveCardPrompt,
23
+ editAdaptiveCard: generateNodeOutputModifyAdaptiveCardPrompt,
24
+ },
25
+ lexiconGeneration: lexiconGenerationPrompt,
26
+ flowGeneration: {
27
+ description: flowGenerationWithDescriptionPrompt,
28
+ transcript: flowGenerationWithTranscriptPrompt
29
+ }
273
30
  },
274
31
  "claude-3-haiku-20240307": {
275
32
  answerExtraction: {
@@ -285,192 +42,6 @@ export const generativeAIPrompts = {
285
42
  answerExtraction: {
286
43
  contextAwareUserQueryRephrasing: alternativeContextAwareUserQueryRephrasingChatPrompt
287
44
  },
288
- },
289
- "gpt-4o-mini": {
290
- intentSentenceGeneration: {
291
- messages: [
292
- {
293
- role: "user",
294
- content: SENTENCE_GENERATION_PROMPT_UNIVERSAL,
295
- },
296
- ],
297
- },
298
- generateNodeOutput: {
299
- text: {
300
- messages: [
301
- {
302
- role: "user",
303
- content: 'Create @@noOfSentencesToGenerate unique sentences based on the description: "@@description" in @@language and return them as a pipe-separated string.',
304
- },
305
- ],
306
- },
307
- adaptiveCard: {
308
- messages: [
309
- {
310
- role: "user",
311
- content: GENERATE_ADAPTIVE_CARD_PROMPT_UNIVERSAL,
312
- },
313
- ],
314
- },
315
- editAdaptiveCard: {
316
- messages: [
317
- {
318
- role: "user",
319
- content: MODIFY_ADAPTIVE_CARD_PROMPT_UNIVERSAL,
320
- },
321
- ],
322
- },
323
- },
324
- lexiconGeneration: {
325
- messages: [
326
- {
327
- role: "user",
328
- content: LEXICON_GENERATION_PROMPT_UNIVERSAL,
329
- },
330
- ],
331
- },
332
- flowGeneration: {
333
- description: {
334
- messages: [
335
- {
336
- role: "user",
337
- content: flowGenerationPromptWithDescriptionForGpt4oAndMini,
338
- },
339
- ],
340
- },
341
- transcript: {
342
- messages: [
343
- {
344
- role: "user",
345
- content: flowGenerationPromptWithTranscriptForGpt4oAndMini,
346
- },
347
- ],
348
- },
349
- }
350
- },
351
- "gpt-4o": {
352
- intentSentenceGeneration: {
353
- messages: [
354
- {
355
- role: "user",
356
- content: SENTENCE_GENERATION_PROMPT_UNIVERSAL,
357
- },
358
- ],
359
- },
360
- generateNodeOutput: {
361
- text: {
362
- messages: [
363
- {
364
- role: "user",
365
- content: 'Create @@noOfSentencesToGenerate unique sentences based on the description: "@@description" in @@language and return them as a pipe-separated string.',
366
- },
367
- ],
368
- },
369
- adaptiveCard: {
370
- messages: [
371
- {
372
- role: "user",
373
- content: GENERATE_ADAPTIVE_CARD_PROMPT_UNIVERSAL,
374
- },
375
- ],
376
- },
377
- editAdaptiveCard: {
378
- messages: [
379
- {
380
- role: "user",
381
- content: MODIFY_ADAPTIVE_CARD_PROMPT_UNIVERSAL,
382
- },
383
- ],
384
- },
385
- },
386
- lexiconGeneration: {
387
- messages: [
388
- {
389
- role: "user",
390
- content: LEXICON_GENERATION_PROMPT_UNIVERSAL,
391
- },
392
- ],
393
- },
394
- flowGeneration: {
395
- description: {
396
- messages: [
397
- {
398
- role: "user",
399
- content: flowGenerationPromptWithDescriptionForGpt4oAndMini,
400
- },
401
- ],
402
- },
403
- transcript: {
404
- messages: [
405
- {
406
- role: "user",
407
- content: flowGenerationPromptWithTranscriptForGpt4oAndMini,
408
- },
409
- ],
410
- },
411
- }
412
- },
413
- "gpt-3.5-turbo": {
414
- intentSentenceGeneration: {
415
- messages: [
416
- {
417
- role: "user",
418
- content: SENTENCE_GENERATION_PROMPT_UNIVERSAL,
419
- },
420
- ],
421
- },
422
- generateNodeOutput: {
423
- text: {
424
- messages: [
425
- {
426
- role: "user",
427
- content: 'Create @@noOfSentencesToGenerate unique sentences based on the description: "@@description" in @@language and return them as a pipe-separated string.',
428
- },
429
- ],
430
- },
431
- adaptiveCard: {
432
- messages: [
433
- {
434
- role: "user",
435
- content: GENERATE_ADAPTIVE_CARD_PROMPT_UNIVERSAL,
436
- },
437
- ],
438
- },
439
- editAdaptiveCard: {
440
- messages: [
441
- {
442
- role: "user",
443
- content: MODIFY_ADAPTIVE_CARD_PROMPT_UNIVERSAL,
444
- },
445
- ],
446
- },
447
- },
448
- lexiconGeneration: {
449
- messages: [
450
- {
451
- role: "user",
452
- content: LEXICON_GENERATION_PROMPT_UNIVERSAL,
453
- },
454
- ],
455
- },
456
- flowGeneration: {
457
- description: {
458
- messages: [
459
- {
460
- role: "user",
461
- content: flowGenerationPromptWithDescriptionForGpt35Turbo,
462
- },
463
- ],
464
- },
465
- transcript: {
466
- messages: [
467
- {
468
- role: "user",
469
- content: flowGenerationPromptWithTranscriptForGpt35Turbo,
470
- },
471
- ],
472
- },
473
- }
474
- },
45
+ }
475
46
  };
476
47
  //# sourceMappingURL=generativeAIPrompts.js.map