@cognigy/rest-api-client 2025.18.0 → 2025.18.1
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 +7 -0
- package/build/authentication/AuthenticationAPI.js +1 -1
- package/build/authentication/OAuth2/OAuth2Authentication.js +10 -9
- package/build/connector/AxiosAdapter.js +2 -1
- package/build/shared/charts/descriptors/service/GPTPrompt.js +2 -2
- package/build/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +2 -2
- package/build/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +2 -2
- package/build/shared/generativeAI/utils/generativeAIPrompts.js +17 -446
- package/build/shared/generativeAI/utils/prompts/flowGeneration.js +168 -0
- package/build/shared/generativeAI/utils/prompts/generateNodeOutput.js +39 -0
- package/build/shared/generativeAI/utils/prompts/intentSentenceGeneration.js +15 -0
- package/build/shared/generativeAI/utils/prompts/lexiconGeneration.js +22 -0
- package/build/shared/interfaces/generativeAI/IGenerativeAIModels.js +4 -0
- package/build/shared/interfaces/messageAPI/endpoints.js +3 -2
- package/build/shared/interfaces/resources/INodeDescriptorSet.js +87 -77
- package/build/test.js +39 -0
- package/dist/esm/authentication/AuthenticationAPI.js +1 -1
- package/dist/esm/authentication/OAuth2/OAuth2Authentication.js +10 -9
- package/dist/esm/connector/AxiosAdapter.js +2 -1
- package/dist/esm/shared/charts/descriptors/service/GPTPrompt.js +1 -1
- package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +1 -1
- package/dist/esm/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +1 -1
- package/dist/esm/shared/generativeAI/utils/generativeAIPrompts.js +16 -445
- package/dist/esm/shared/generativeAI/utils/prompts/flowGeneration.js +165 -0
- package/dist/esm/shared/generativeAI/utils/prompts/generateNodeOutput.js +36 -0
- package/dist/esm/shared/generativeAI/utils/prompts/intentSentenceGeneration.js +12 -0
- package/dist/esm/shared/generativeAI/utils/prompts/lexiconGeneration.js +19 -0
- package/dist/esm/shared/interfaces/generativeAI/IGenerativeAIModels.js +4 -0
- package/dist/esm/shared/interfaces/messageAPI/endpoints.js +3 -2
- package/dist/esm/shared/interfaces/resources/INodeDescriptorSet.js +88 -78
- package/dist/esm/shared/interfaces/restAPI/management/authentication/ICreateJWTToken.js +1 -0
- package/dist/esm/test.js +39 -0
- package/package.json +1 -1
- package/types/index.d.ts +20 -2
package/CHANGELOG.md
CHANGED
|
@@ -66,7 +66,7 @@ function AuthenticationAPI(instance) {
|
|
|
66
66
|
},
|
|
67
67
|
exchangeOneTimeTokenForRefreshToken: (_a, options) => {
|
|
68
68
|
var { loginToken } = _a, args = __rest(_a, ["loginToken"]);
|
|
69
|
-
return (0, GenericAPIFn_1.GenericAPIFn)(`/auth/exchangetoken?${(0, rest_1.stringifyQuery)({ loginToken })}`, "GET", self)(args, Object.assign({ withAuthentication: false }, options));
|
|
69
|
+
return (0, GenericAPIFn_1.GenericAPIFn)(`/auth/exchangetoken?${(0, rest_1.stringifyQuery)({ loginToken })}`, "GET", self)(args, Object.assign({ withAuthentication: false, withCredentials: true }, options));
|
|
70
70
|
},
|
|
71
71
|
generateManagementUIAuthToken: (args, options) => (0, GenericAPIFn_1.GenericAPIFn)("/new/management/auth/token", "POST", self)(args, options)
|
|
72
72
|
};
|
|
@@ -4,7 +4,6 @@ exports.OAuth2Authentication = void 0;
|
|
|
4
4
|
/* Custom Modules */
|
|
5
5
|
const OAuth2Error_1 = require("./OAuth2Error");
|
|
6
6
|
const HttpStatusCode_1 = require("../../shared/helper/HttpStatusCode");
|
|
7
|
-
const errors_1 = require("../../shared/errors");
|
|
8
7
|
const IOAuth2ErrorResponse_1 = require("./IOAuth2ErrorResponse");
|
|
9
8
|
const expiryBuffer = 8;
|
|
10
9
|
exports.OAuth2Authentication = function (credentials, self) {
|
|
@@ -29,7 +28,8 @@ exports.OAuth2Authentication = function (credentials, self) {
|
|
|
29
28
|
};
|
|
30
29
|
return await request(formFields, {
|
|
31
30
|
maxRetries: Infinity,
|
|
32
|
-
retryDelay: () => 3000
|
|
31
|
+
retryDelay: () => 3000,
|
|
32
|
+
withCredentials: true
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
const request = async (formFields, options) => {
|
|
@@ -84,6 +84,8 @@ exports.OAuth2Authentication = function (credentials, self) {
|
|
|
84
84
|
OAuth2Authentication.prototype.login = async (parameters) => {
|
|
85
85
|
const { clientId, clientSecret } = self.credentials;
|
|
86
86
|
switch (parameters.type) {
|
|
87
|
+
// Password Grant is deprecated in OAuth2, but still supported
|
|
88
|
+
// for api and e2e tests
|
|
87
89
|
case "password":
|
|
88
90
|
{
|
|
89
91
|
const { username, password, rememberMe, organisationId } = parameters;
|
|
@@ -115,17 +117,19 @@ exports.OAuth2Authentication = function (credentials, self) {
|
|
|
115
117
|
break;
|
|
116
118
|
case "authorizationCode":
|
|
117
119
|
{
|
|
118
|
-
const { code, redirectUri, codeVerifier } = parameters;
|
|
120
|
+
const { code, redirectUri, codeVerifier, rememberMe } = parameters;
|
|
119
121
|
const formFields = {
|
|
120
122
|
grant_type: "authorization_code",
|
|
121
123
|
client_id: clientId,
|
|
122
124
|
client_secret: clientSecret,
|
|
123
125
|
code,
|
|
124
126
|
redirect_uri: redirectUri,
|
|
127
|
+
rememberMe,
|
|
125
128
|
code_verifier: codeVerifier
|
|
126
129
|
};
|
|
127
130
|
self.tokenData = await request(formFields, {
|
|
128
|
-
maxRetries: 0
|
|
131
|
+
maxRetries: 0,
|
|
132
|
+
withCredentials: true
|
|
129
133
|
});
|
|
130
134
|
}
|
|
131
135
|
break;
|
|
@@ -177,9 +181,6 @@ exports.OAuth2Authentication = function (credentials, self) {
|
|
|
177
181
|
*/
|
|
178
182
|
if (isAccessTokenExpired(self.tokenData)) {
|
|
179
183
|
const credentials = self.credentials;
|
|
180
|
-
if (!self.tokenData.refresh_token) {
|
|
181
|
-
throw new errors_1.UnauthorizedError("No RefreshToken provided.");
|
|
182
|
-
}
|
|
183
184
|
if (self.refreshTokenSingleton === null) {
|
|
184
185
|
self.refreshTokenSingleton = new Promise((resolve, reject) => {
|
|
185
186
|
refreshTokenGrant({
|
|
@@ -219,8 +220,7 @@ exports.OAuth2Authentication = function (credentials, self) {
|
|
|
219
220
|
};
|
|
220
221
|
OAuth2Authentication.prototype.logout = async () => {
|
|
221
222
|
if ((self === null || self === void 0 ? void 0 : self.credentials.type) ===
|
|
222
|
-
"OAuth2"
|
|
223
|
-
self.tokenData.refresh_token) {
|
|
223
|
+
"OAuth2") {
|
|
224
224
|
const httpAdapter = self.getHttpAdapter();
|
|
225
225
|
const requestData = {
|
|
226
226
|
method: "POST",
|
|
@@ -229,6 +229,7 @@ exports.OAuth2Authentication = function (credentials, self) {
|
|
|
229
229
|
token: self.tokenData.refresh_token
|
|
230
230
|
},
|
|
231
231
|
maxRetries: 3,
|
|
232
|
+
withCredentials: true,
|
|
232
233
|
retryDelay: () => 0
|
|
233
234
|
};
|
|
234
235
|
// reset tokenData to avoid multiple revoke calls
|
|
@@ -76,13 +76,14 @@ class AxiosAdapter {
|
|
|
76
76
|
return this.request(Object.assign(Object.assign({}, request), { method: "HEAD" }), client);
|
|
77
77
|
}
|
|
78
78
|
async convertRequest(request, client) {
|
|
79
|
-
var _a;
|
|
79
|
+
var _a, _b;
|
|
80
80
|
const baseUrl = (_a = request.baseUrl) !== null && _a !== void 0 ? _a : this.config.baseUrl;
|
|
81
81
|
const axiosRequest = {
|
|
82
82
|
data: request.data,
|
|
83
83
|
headers: request.headers,
|
|
84
84
|
method: request.method || "GET",
|
|
85
85
|
url: `${baseUrl}${request.url}`,
|
|
86
|
+
withCredentials: (_b = request.withCredentials) !== null && _b !== void 0 ? _b : false,
|
|
86
87
|
validateStatus: (status) => !(0, isRetryableStatus_1.isRetryableStatus)(status)
|
|
87
88
|
};
|
|
88
89
|
if (typeof request.onProgress === "function") {
|
|
@@ -4,7 +4,7 @@ exports.GPT_PROMPT = void 0;
|
|
|
4
4
|
/* Custom modules */
|
|
5
5
|
const createNodeDescriptor_1 = require("../../createNodeDescriptor");
|
|
6
6
|
const logic_1 = require("../logic");
|
|
7
|
-
const
|
|
7
|
+
const uuid_1 = require("uuid");
|
|
8
8
|
const prompt_1 = require("../nlu/generativeSlotFiller/prompt");
|
|
9
9
|
const errors_1 = require("../../../errors");
|
|
10
10
|
const transcripts_1 = require("../../../interfaces/transcripts/transcripts");
|
|
@@ -660,7 +660,7 @@ exports.GPT_PROMPT = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
660
660
|
};
|
|
661
661
|
try {
|
|
662
662
|
const isStreamingChannel = input.channel === "webchat3" || input.channel === "adminconsole";
|
|
663
|
-
const _messageId = (0,
|
|
663
|
+
const _messageId = (0, uuid_1.v4)();
|
|
664
664
|
const data = {
|
|
665
665
|
prompt,
|
|
666
666
|
temperature,
|
|
@@ -14,7 +14,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.AI_AGENT_JOB = exports.AI_AGENT_TOOLS_WHITELIST = void 0;
|
|
15
15
|
/* Custom modules */
|
|
16
16
|
const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
|
|
17
|
-
const crypto_1 = require("crypto");
|
|
18
17
|
const setSessionConfig_mapper_1 = require("../../voice/mappers/setSessionConfig.mapper");
|
|
19
18
|
const setSessionConfig_mapper_2 = require("../../voice/mappers/setSessionConfig.mapper");
|
|
20
19
|
const logFullConfigToDebugMode_1 = require("../../../../helper/logFullConfigToDebugMode");
|
|
@@ -22,6 +21,7 @@ const createSystemMessage_1 = require("./helpers/createSystemMessage");
|
|
|
22
21
|
const generateSearchPrompt_1 = require("./helpers/generateSearchPrompt");
|
|
23
22
|
const getUserMemory_1 = require("./helpers/getUserMemory");
|
|
24
23
|
const createToolDefinitions_1 = require("./helpers/createToolDefinitions");
|
|
24
|
+
const uuid_1 = require("uuid");
|
|
25
25
|
const transcripts_1 = require("../../../../interfaces/transcripts/transcripts");
|
|
26
26
|
exports.AI_AGENT_TOOLS_WHITELIST = ["aiAgentJobDefault", "aiAgentJobTool", "aiAgentJobMCPTool"];
|
|
27
27
|
exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
@@ -1163,7 +1163,7 @@ exports.AI_AGENT_JOB = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
1163
1163
|
transcript[transcript.length - 1].payload.text = enhancedInput;
|
|
1164
1164
|
}
|
|
1165
1165
|
const isStreamingChannel = input.channel === "webchat3" || input.channel === "adminconsole";
|
|
1166
|
-
const _messageId = (0,
|
|
1166
|
+
const _messageId = (0, uuid_1.v4)();
|
|
1167
1167
|
const llmPromptOptions = Object.assign(Object.assign({ prompt: "", chat: systemMessage,
|
|
1168
1168
|
// Temp fix to override the transcript if needed
|
|
1169
1169
|
transcript: ((_0 = context === null || context === void 0 ? void 0 : context._cognigy) === null || _0 === void 0 ? void 0 : _0.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) => {
|
|
@@ -15,8 +15,8 @@ exports.LLM_PROMPT_V2 = void 0;
|
|
|
15
15
|
/* Custom modules */
|
|
16
16
|
const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
|
|
17
17
|
const logic_1 = require("../../logic");
|
|
18
|
-
const crypto_1 = require("crypto");
|
|
19
18
|
const createToolDefinitions_1 = require("../aiAgent/helpers/createToolDefinitions");
|
|
19
|
+
const uuid_1 = require("uuid");
|
|
20
20
|
const prompt_1 = require("../../nlu/generativeSlotFiller/prompt");
|
|
21
21
|
const errors_1 = require("../../../../errors");
|
|
22
22
|
const transcripts_1 = require("../../../../interfaces/transcripts/transcripts");
|
|
@@ -736,7 +736,7 @@ exports.LLM_PROMPT_V2 = (0, createNodeDescriptor_1.createNodeDescriptor)({
|
|
|
736
736
|
};
|
|
737
737
|
try {
|
|
738
738
|
const isStreamingChannel = input.channel === "webchat3" || input.channel === "adminconsole";
|
|
739
|
-
const _messageId = (0,
|
|
739
|
+
const _messageId = (0, uuid_1.v4)();
|
|
740
740
|
// Start measuring LLM latency and time to first output if debug flag is enabled
|
|
741
741
|
let firstOutputTime = null;
|
|
742
742
|
/**
|
|
@@ -1,267 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generativeAIPrompts =
|
|
3
|
+
exports.generativeAIPrompts = void 0;
|
|
4
4
|
/** Prompts **/
|
|
5
5
|
const contextAwareUserQueryRephrasing_1 = require("./prompts/contextAwareUserQueryRephrasing");
|
|
6
6
|
const rephraseSentences_1 = require("./prompts/rephraseSentences");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@@text
|
|
12
|
-
|
|
13
|
-
Write the bot in @@lng. Consider the following list of constraints:
|
|
14
|
-
|
|
15
|
-
# Instructions:
|
|
16
|
-
|
|
17
|
-
## Do only use flow nodes of the following list. Do not use other nodes.
|
|
18
|
-
|
|
19
|
-
## The configurable parameters are listed in brackets:
|
|
20
|
-
- say "Say stuff and output something using {{Node.js Code}}"
|
|
21
|
-
- question (output: "context.variable", validation: "text|yesNo|number|email|url", options: "Option 1|Option 2|Option 3") "Ask question with {{Node.js Code}} support?"
|
|
22
|
-
- backendCall (output: "context.variable") "Call external API"
|
|
23
|
-
- code "Node.js Code"
|
|
24
|
-
- switch "Node.js Code"
|
|
25
|
-
- case
|
|
26
|
-
- default
|
|
27
|
-
- if "Node.js Code"
|
|
28
|
-
- then
|
|
29
|
-
- else
|
|
30
|
-
|
|
31
|
-
# Examples:
|
|
32
|
-
|
|
33
|
-
## Example flow in English:
|
|
34
|
-
|
|
35
|
-
- question (output: "context.email", validation: "email") "What is your email address?"
|
|
36
|
-
- question (output: "context.url", validation: "url") "And what is the URL?"
|
|
37
|
-
- 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);"
|
|
38
|
-
- if "context.areDomainsSame === true"
|
|
39
|
-
- then
|
|
40
|
-
- say "The domains are the same."
|
|
41
|
-
- else
|
|
42
|
-
- say "The domains are not the same."
|
|
43
|
-
|
|
44
|
-
## Example flow in German:
|
|
45
|
-
|
|
46
|
-
- say "Hallo, ich bin ein Faktenprüfer. Ich entlarve Mythen durch Fakten."
|
|
47
|
-
- question (output: "context.color", validation: "text", options: "rot|grün|blau") "Welche Farbe hat der Himmel?"
|
|
48
|
-
- switch "context.color"
|
|
49
|
-
- case "blau"
|
|
50
|
-
- say "Du hast recht, das ist eine Tatsache."
|
|
51
|
-
- case "rot"
|
|
52
|
-
- say "Ja tatsächlich, manchmal ist der Himmel sogar rot."
|
|
53
|
-
- default
|
|
54
|
-
- say "Nein, der Himmel ist tagsüber normalerweise blau."
|
|
55
|
-
|
|
56
|
-
## Example flow in Spanish:
|
|
57
|
-
|
|
58
|
-
- say "Hola, puedo conectarlo con nuestro equipo de soporte."
|
|
59
|
-
- question (output: "context.wantsSupport", validation: "yesNo") "¿Te gustaría contactar el soporte?"
|
|
60
|
-
- if "context.wantsSupport === true"
|
|
61
|
-
- then
|
|
62
|
-
- backendCall (output: "context.contactDetails") "call API to retrieve contact details of support"
|
|
63
|
-
- say "Aquí tienes. Por favor vea los detalles de contacto de nuestro soporte: {{context.contactDetails}}"
|
|
64
|
-
- else
|
|
65
|
-
- backendCall (output: "context.success") "call API to log decision"
|
|
66
|
-
|
|
67
|
-
# Additional information:
|
|
68
|
-
|
|
69
|
-
## Say nodes and question nodes execute Node.js in double curly braces, for example:
|
|
70
|
-
|
|
71
|
-
- say "This is a {{context.variable.toLowerCase()}}"
|
|
72
|
-
- question (output: "context.result", validation: "text") "Do you like {{"banana".toUpperCase()}}?"
|
|
73
|
-
|
|
74
|
-
## When using the option parameter then use human-readable text and more than one option.
|
|
75
|
-
## Only use a switch node when considering multiple options.
|
|
76
|
-
## When using a switch node then always use a default node as last resort.
|
|
77
|
-
## Do not use a backendCall if a Code Node can solve it.
|
|
78
|
-
## Dot not use "for" nodes to simulate a for-loop.
|
|
79
|
-
## Use a smallest amount of flow nodes possible.
|
|
80
|
-
|
|
81
|
-
## Return just a list of nodes following the required format and instructions, and nothing else.`;
|
|
82
|
-
exports.flowGenerationPromptWithDescriptionForGpt4oAndMini = `Create a new bot called "@@name" with the following description:
|
|
83
|
-
"@@text" Write the bot in @@lng. Consider the following list of constraints:
|
|
84
|
-
|
|
85
|
-
# Instructions:
|
|
86
|
-
|
|
87
|
-
## Do only use flow nodes of the following list. Do not use other nodes.
|
|
88
|
-
|
|
89
|
-
## The configurable parameters are listed in brackets:
|
|
90
|
-
- say "Say stuff and output something using {{Node.js Code}}"
|
|
91
|
-
- question (output: "context.variable", validation: "text|yesNo|number|email|url", options: "Option 1|Option 2|Option 3") "Ask question with {{Node.js Code}} support?"
|
|
92
|
-
- backendCall (output: "context.variable") "Call external API"
|
|
93
|
-
- code "Node.js Code"
|
|
94
|
-
- switch "Node.js Code"
|
|
95
|
-
- case
|
|
96
|
-
- default
|
|
97
|
-
- if "Node.js Code"
|
|
98
|
-
- then
|
|
99
|
-
- else
|
|
100
|
-
|
|
101
|
-
# Examples:
|
|
102
|
-
|
|
103
|
-
## Example flow in English:
|
|
104
|
-
|
|
105
|
-
- question (output: "context.email", validation: "email") "What is your email address?"
|
|
106
|
-
- question (output: "context.url", validation: "url") "And what is the URL?"
|
|
107
|
-
- 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);"
|
|
108
|
-
- if "context.areDomainsSame === true"
|
|
109
|
-
- then
|
|
110
|
-
- say "The domains are the same."
|
|
111
|
-
- else
|
|
112
|
-
- say "The domains are not the same."
|
|
113
|
-
|
|
114
|
-
## Example flow in German:
|
|
115
|
-
|
|
116
|
-
- say "Hallo, ich bin ein Faktenprüfer. Ich entlarve Mythen durch Fakten."
|
|
117
|
-
- question (output: "context.color", validation: "text", options: "rot|grün|blau") "Welche Farbe hat der Himmel?"
|
|
118
|
-
- switch "context.color"
|
|
119
|
-
- case "blau"
|
|
120
|
-
- say "Du hast recht, das ist eine Tatsache."
|
|
121
|
-
- case "rot"
|
|
122
|
-
- say "Ja tatsächlich, manchmal ist der Himmel sogar rot."
|
|
123
|
-
- default
|
|
124
|
-
- say "Nein, der Himmel ist tagsüber normalerweise blau."
|
|
125
|
-
|
|
126
|
-
## Example flow in Spanish:
|
|
127
|
-
|
|
128
|
-
- say "Hola, puedo conectarlo con nuestro equipo de soporte."
|
|
129
|
-
- question (output: "context.wantsSupport", validation: "yesNo") "¿Te gustaría contactar el soporte?"
|
|
130
|
-
- if "context.wantsSupport === true"
|
|
131
|
-
- then
|
|
132
|
-
- backendCall (output: "context.contactDetails") "call API to retrieve contact details of support"
|
|
133
|
-
- say "Aquí tienes. Por favor vea los detalles de contacto de nuestro soporte: {{context.contactDetails}}"
|
|
134
|
-
- else
|
|
135
|
-
- backendCall (output: "context.success") "call API to log decision"
|
|
136
|
-
|
|
137
|
-
# Additional information:
|
|
138
|
-
|
|
139
|
-
## Say nodes and question nodes execute Node.js in double curly braces, for example:
|
|
140
|
-
- say "This is a {{context.variable.toLowerCase()}}"
|
|
141
|
-
- question (output: "context.result", validation: "text") "Do you like {{"banana".toUpperCase()}}?"
|
|
142
|
-
|
|
143
|
-
## When using the option parameter then use human-readable text and more than one option.
|
|
144
|
-
## Only use a switch node when considering multiple options.
|
|
145
|
-
## When using a switch node then always use a default node as last resort.
|
|
146
|
-
## Do not use a backendCall if a Code Node can solve it.
|
|
147
|
-
## Dot not use "for" nodes to simulate a for-loop.
|
|
148
|
-
## Use a smallest amount of flow nodes possible.
|
|
149
|
-
|
|
150
|
-
## Return just a list of nodes following the required format and instructions, and nothing else.`;
|
|
151
|
-
exports.flowGenerationPromptWithTranscriptForGpt35Turbo = `Create a new bot called "@@name" with the following transcript between the bot and a user: "@@text"
|
|
152
|
-
Write the bot in @@lng. Consider the following list of constraints:
|
|
153
|
-
1. Do only use flow nodes of the following list. Do not use other nodes. The configurable parameters are listed in brackets:
|
|
154
|
-
- say "Say stuff and output something using {{Node.js Code}}"
|
|
155
|
-
- question (output: "context.variable", validation: "text|yesNo|number|email|url", options: "Option 1|Option 2|Option 3") "Ask question with {{Node.js Code}} support?"
|
|
156
|
-
- backendCall (output: "context.variable") "Call external API"
|
|
157
|
-
- code "Node.js Code"
|
|
158
|
-
- switch "Node.js Code"
|
|
159
|
-
- case
|
|
160
|
-
- default
|
|
161
|
-
- if "Node.js Code"
|
|
162
|
-
- then
|
|
163
|
-
- else
|
|
164
|
-
2. Example flow in English:
|
|
165
|
-
- question (output: "context.email", validation: "email") "What is your email address?"
|
|
166
|
-
- question (output: "context.url", validation: "url") "And what is the URL?"
|
|
167
|
-
- 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);"
|
|
168
|
-
- if "context.areDomainsSame === true"
|
|
169
|
-
- then
|
|
170
|
-
- say "The domains are the same."
|
|
171
|
-
- else
|
|
172
|
-
- say "The domains are not the same."
|
|
173
|
-
3. Example flow in German:
|
|
174
|
-
- say "Hallo, ich bin ein Faktenprüfer. Ich entlarve Mythen durch Fakten."
|
|
175
|
-
- question (output: "context.color", validation: "text", options: "rot|grün|blau") "Welche Farbe hat der Himmel?"
|
|
176
|
-
- switch "context.color"
|
|
177
|
-
- case "blau"
|
|
178
|
-
- say "Du hast recht, das ist eine Tatsache."
|
|
179
|
-
- case "rot"
|
|
180
|
-
- say "Ja tatsächlich, manchmal ist der Himmel sogar rot."
|
|
181
|
-
- default
|
|
182
|
-
- say "Nein, der Himmel ist tagsüber normalerweise blau."
|
|
183
|
-
4. Example flow in Spanish:
|
|
184
|
-
- say "Hola, puedo conectarlo con nuestro equipo de soporte."
|
|
185
|
-
- question (output: "context.wantsSupport", validation: "yesNo") "¿Te gustaría contactar el soporte?"
|
|
186
|
-
- if "context.wantsSupport === true"
|
|
187
|
-
- then
|
|
188
|
-
- backendCall (output: "context.contactDetails") "call API to retrieve contact details of support"
|
|
189
|
-
- say "Aquí tienes. Por favor vea los detalles de contacto de nuestro soporte: {{context.contactDetails}}"
|
|
190
|
-
- else
|
|
191
|
-
- backendCall (output: "context.success") "call API to log decision"
|
|
192
|
-
5. Say nodes and question nodes execute Node.js in double curly braces, for example:
|
|
193
|
-
- say "This is a {{context.variable.toLowerCase()}}"
|
|
194
|
-
- question (output: "context.result", validation: "text") "Do you like {{"banana".toUpperCase()}}?"
|
|
195
|
-
6. When using the option parameter then use human-readable text and more than one option.
|
|
196
|
-
7. Only use a switch node when considering multiple options.
|
|
197
|
-
8. When using a switch node then always use a default node as last resort.
|
|
198
|
-
9. Do not use a backendCall if a Code Node can solve it.
|
|
199
|
-
10. Dot not use "for" nodes to simulate a for-loop.
|
|
200
|
-
11. Use a smallest amount of flow nodes possible.
|
|
201
|
-
12. Lets think step by step.
|
|
202
|
-
`;
|
|
203
|
-
exports.flowGenerationPromptWithDescriptionForGpt35Turbo = `Create a new bot called "@@name" with the following description:
|
|
204
|
-
"@@text" Write the bot in @@lng. Consider the following list of constraints:
|
|
205
|
-
1. Do only use flow nodes of the following list. Do not use other nodes. The configurable parameters are listed in brackets:
|
|
206
|
-
- say "Say stuff and output something using {{Node.js Code}}"
|
|
207
|
-
- question (output: "context.variable", validation: "text|yesNo|number|email|url", options: "Option 1|Option 2|Option 3") "Ask question with {{Node.js Code}} support?"
|
|
208
|
-
- backendCall (output: "context.variable") "Call external API"
|
|
209
|
-
- code "Node.js Code"
|
|
210
|
-
- switch "Node.js Code"
|
|
211
|
-
- case
|
|
212
|
-
- default
|
|
213
|
-
- if "Node.js Code"
|
|
214
|
-
- then
|
|
215
|
-
- else
|
|
216
|
-
2. Example flow in English:
|
|
217
|
-
- question (output: "context.email", validation: "email") "What is your email address?"
|
|
218
|
-
- question (output: "context.url", validation: "url") "And what is the URL?"
|
|
219
|
-
- 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);"
|
|
220
|
-
- if "context.areDomainsSame === true"
|
|
221
|
-
- then
|
|
222
|
-
- say "The domains are the same."
|
|
223
|
-
- else
|
|
224
|
-
- say "The domains are not the same."
|
|
225
|
-
3. Example flow in German:
|
|
226
|
-
- say "Hallo, ich bin ein Faktenprüfer. Ich entlarve Mythen durch Fakten."
|
|
227
|
-
- question (output: "context.color", validation: "text", options: "rot|grün|blau") "Welche Farbe hat der Himmel?"
|
|
228
|
-
- switch "context.color"
|
|
229
|
-
- case "blau"
|
|
230
|
-
- say "Du hast recht, das ist eine Tatsache."
|
|
231
|
-
- case "rot"
|
|
232
|
-
- say "Ja tatsächlich, manchmal ist der Himmel sogar rot."
|
|
233
|
-
- default
|
|
234
|
-
- say "Nein, der Himmel ist tagsüber normalerweise blau."
|
|
235
|
-
4. Example flow in Spanish:
|
|
236
|
-
- say "Hola, puedo conectarlo con nuestro equipo de soporte."
|
|
237
|
-
- question (output: "context.wantsSupport", validation: "yesNo") "¿Te gustaría contactar el soporte?"
|
|
238
|
-
- if "context.wantsSupport === true"
|
|
239
|
-
- then
|
|
240
|
-
- backendCall (output: "context.contactDetails") "call API to retrieve contact details of support"
|
|
241
|
-
- say "Aquí tienes. Por favor vea los detalles de contacto de nuestro soporte: {{context.contactDetails}}"
|
|
242
|
-
- else
|
|
243
|
-
- backendCall (output: "context.success") "call API to log decision"
|
|
244
|
-
5. Say nodes and question nodes execute Node.js in double curly braces, for example:
|
|
245
|
-
- say "This is a {{context.variable.toLowerCase()}}"
|
|
246
|
-
- question (output: "context.result", validation: "text") "Do you like {{"banana".toUpperCase()}}?"
|
|
247
|
-
6. When using the option parameter then use human-readable text and more than one option.
|
|
248
|
-
7. Only use a switch node when considering multiple options.
|
|
249
|
-
8. When using a switch node then always use a default node as last resort.
|
|
250
|
-
9. Do not use a backendCall if a Code Node can solve it.
|
|
251
|
-
10. Dot not use "for" nodes to simulate a for-loop.
|
|
252
|
-
11. Use a smallest amount of flow nodes possible.
|
|
253
|
-
12. The output must start with a valid node from the list above.
|
|
254
|
-
13. Lets think step by step.
|
|
255
|
-
14. Return just a list of nodes listed in constrain 1, and nothing else.`;
|
|
256
|
-
exports.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>`;
|
|
257
|
-
exports.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.`;
|
|
258
|
-
exports.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.`;
|
|
259
|
-
exports.LEXICON_GENERATION_PROMPT_UNIVERSAL = 'For the NLU model lexicon with the title "@@name" and the description "@@description",' +
|
|
260
|
-
' generate @@lexiconEntries varied words in "@@lng".@@synonymInstructions' +
|
|
261
|
-
'\n\nRespond with a valid JSON with the format following the example: `@@example`';
|
|
262
|
-
exports.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.";
|
|
263
|
-
exports.LEXICON_GENERATION_RESPONSE_EXAMPLE = '[{"word": "test","synonyms": ["trial","attempt"]},{"word": "demo","synonyms": ["proof of concept"]}]';
|
|
264
|
-
exports.LEXICON_GENERATION_RESPONSE_EXAMPLE_NO_SYNONYMS = '[{"word": "test"},{"word": "demo"}]';
|
|
7
|
+
const flowGeneration_1 = require("./prompts/flowGeneration");
|
|
8
|
+
const intentSentenceGeneration_1 = require("./prompts/intentSentenceGeneration");
|
|
9
|
+
const lexiconGeneration_1 = require("./prompts/lexiconGeneration");
|
|
10
|
+
const generateNodeOutput_1 = require("./prompts/generateNodeOutput");
|
|
265
11
|
exports.generativeAIPrompts = {
|
|
266
12
|
"default": {
|
|
267
13
|
answerExtraction: {
|
|
@@ -273,6 +19,17 @@ exports.generativeAIPrompts = {
|
|
|
273
19
|
question: rephraseSentences_1.rephraseQuestionPrompt,
|
|
274
20
|
questionReprompt: rephraseSentences_1.rephraseQuestionRepromptPrompt
|
|
275
21
|
},
|
|
22
|
+
intentSentenceGeneration: intentSentenceGeneration_1.intentSentenceGenerationPrompt,
|
|
23
|
+
generateNodeOutput: {
|
|
24
|
+
text: generateNodeOutput_1.generateNodeOutputTextPrompt,
|
|
25
|
+
adaptiveCard: generateNodeOutput_1.generateNodeOutputCreateAdaptiveCardPrompt,
|
|
26
|
+
editAdaptiveCard: generateNodeOutput_1.generateNodeOutputModifyAdaptiveCardPrompt,
|
|
27
|
+
},
|
|
28
|
+
lexiconGeneration: lexiconGeneration_1.lexiconGenerationPrompt,
|
|
29
|
+
flowGeneration: {
|
|
30
|
+
description: flowGeneration_1.flowGenerationWithDescriptionPrompt,
|
|
31
|
+
transcript: flowGeneration_1.flowGenerationWithTranscriptPrompt
|
|
32
|
+
}
|
|
276
33
|
},
|
|
277
34
|
"claude-3-haiku-20240307": {
|
|
278
35
|
answerExtraction: {
|
|
@@ -288,192 +45,6 @@ exports.generativeAIPrompts = {
|
|
|
288
45
|
answerExtraction: {
|
|
289
46
|
contextAwareUserQueryRephrasing: contextAwareUserQueryRephrasing_1.alternativeContextAwareUserQueryRephrasingChatPrompt
|
|
290
47
|
},
|
|
291
|
-
}
|
|
292
|
-
"gpt-4o-mini": {
|
|
293
|
-
intentSentenceGeneration: {
|
|
294
|
-
messages: [
|
|
295
|
-
{
|
|
296
|
-
role: "user",
|
|
297
|
-
content: exports.SENTENCE_GENERATION_PROMPT_UNIVERSAL,
|
|
298
|
-
},
|
|
299
|
-
],
|
|
300
|
-
},
|
|
301
|
-
generateNodeOutput: {
|
|
302
|
-
text: {
|
|
303
|
-
messages: [
|
|
304
|
-
{
|
|
305
|
-
role: "user",
|
|
306
|
-
content: 'Create @@noOfSentencesToGenerate unique sentences based on the description: "@@description" in @@language and return them as a pipe-separated string.',
|
|
307
|
-
},
|
|
308
|
-
],
|
|
309
|
-
},
|
|
310
|
-
adaptiveCard: {
|
|
311
|
-
messages: [
|
|
312
|
-
{
|
|
313
|
-
role: "user",
|
|
314
|
-
content: exports.GENERATE_ADAPTIVE_CARD_PROMPT_UNIVERSAL,
|
|
315
|
-
},
|
|
316
|
-
],
|
|
317
|
-
},
|
|
318
|
-
editAdaptiveCard: {
|
|
319
|
-
messages: [
|
|
320
|
-
{
|
|
321
|
-
role: "user",
|
|
322
|
-
content: exports.MODIFY_ADAPTIVE_CARD_PROMPT_UNIVERSAL,
|
|
323
|
-
},
|
|
324
|
-
],
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
lexiconGeneration: {
|
|
328
|
-
messages: [
|
|
329
|
-
{
|
|
330
|
-
role: "user",
|
|
331
|
-
content: exports.LEXICON_GENERATION_PROMPT_UNIVERSAL,
|
|
332
|
-
},
|
|
333
|
-
],
|
|
334
|
-
},
|
|
335
|
-
flowGeneration: {
|
|
336
|
-
description: {
|
|
337
|
-
messages: [
|
|
338
|
-
{
|
|
339
|
-
role: "user",
|
|
340
|
-
content: exports.flowGenerationPromptWithDescriptionForGpt4oAndMini,
|
|
341
|
-
},
|
|
342
|
-
],
|
|
343
|
-
},
|
|
344
|
-
transcript: {
|
|
345
|
-
messages: [
|
|
346
|
-
{
|
|
347
|
-
role: "user",
|
|
348
|
-
content: exports.flowGenerationPromptWithTranscriptForGpt4oAndMini,
|
|
349
|
-
},
|
|
350
|
-
],
|
|
351
|
-
},
|
|
352
|
-
}
|
|
353
|
-
},
|
|
354
|
-
"gpt-4o": {
|
|
355
|
-
intentSentenceGeneration: {
|
|
356
|
-
messages: [
|
|
357
|
-
{
|
|
358
|
-
role: "user",
|
|
359
|
-
content: exports.SENTENCE_GENERATION_PROMPT_UNIVERSAL,
|
|
360
|
-
},
|
|
361
|
-
],
|
|
362
|
-
},
|
|
363
|
-
generateNodeOutput: {
|
|
364
|
-
text: {
|
|
365
|
-
messages: [
|
|
366
|
-
{
|
|
367
|
-
role: "user",
|
|
368
|
-
content: 'Create @@noOfSentencesToGenerate unique sentences based on the description: "@@description" in @@language and return them as a pipe-separated string.',
|
|
369
|
-
},
|
|
370
|
-
],
|
|
371
|
-
},
|
|
372
|
-
adaptiveCard: {
|
|
373
|
-
messages: [
|
|
374
|
-
{
|
|
375
|
-
role: "user",
|
|
376
|
-
content: exports.GENERATE_ADAPTIVE_CARD_PROMPT_UNIVERSAL,
|
|
377
|
-
},
|
|
378
|
-
],
|
|
379
|
-
},
|
|
380
|
-
editAdaptiveCard: {
|
|
381
|
-
messages: [
|
|
382
|
-
{
|
|
383
|
-
role: "user",
|
|
384
|
-
content: exports.MODIFY_ADAPTIVE_CARD_PROMPT_UNIVERSAL,
|
|
385
|
-
},
|
|
386
|
-
],
|
|
387
|
-
},
|
|
388
|
-
},
|
|
389
|
-
lexiconGeneration: {
|
|
390
|
-
messages: [
|
|
391
|
-
{
|
|
392
|
-
role: "user",
|
|
393
|
-
content: exports.LEXICON_GENERATION_PROMPT_UNIVERSAL,
|
|
394
|
-
},
|
|
395
|
-
],
|
|
396
|
-
},
|
|
397
|
-
flowGeneration: {
|
|
398
|
-
description: {
|
|
399
|
-
messages: [
|
|
400
|
-
{
|
|
401
|
-
role: "user",
|
|
402
|
-
content: exports.flowGenerationPromptWithDescriptionForGpt4oAndMini,
|
|
403
|
-
},
|
|
404
|
-
],
|
|
405
|
-
},
|
|
406
|
-
transcript: {
|
|
407
|
-
messages: [
|
|
408
|
-
{
|
|
409
|
-
role: "user",
|
|
410
|
-
content: exports.flowGenerationPromptWithTranscriptForGpt4oAndMini,
|
|
411
|
-
},
|
|
412
|
-
],
|
|
413
|
-
},
|
|
414
|
-
}
|
|
415
|
-
},
|
|
416
|
-
"gpt-3.5-turbo": {
|
|
417
|
-
intentSentenceGeneration: {
|
|
418
|
-
messages: [
|
|
419
|
-
{
|
|
420
|
-
role: "user",
|
|
421
|
-
content: exports.SENTENCE_GENERATION_PROMPT_UNIVERSAL,
|
|
422
|
-
},
|
|
423
|
-
],
|
|
424
|
-
},
|
|
425
|
-
generateNodeOutput: {
|
|
426
|
-
text: {
|
|
427
|
-
messages: [
|
|
428
|
-
{
|
|
429
|
-
role: "user",
|
|
430
|
-
content: 'Create @@noOfSentencesToGenerate unique sentences based on the description: "@@description" in @@language and return them as a pipe-separated string.',
|
|
431
|
-
},
|
|
432
|
-
],
|
|
433
|
-
},
|
|
434
|
-
adaptiveCard: {
|
|
435
|
-
messages: [
|
|
436
|
-
{
|
|
437
|
-
role: "user",
|
|
438
|
-
content: exports.GENERATE_ADAPTIVE_CARD_PROMPT_UNIVERSAL,
|
|
439
|
-
},
|
|
440
|
-
],
|
|
441
|
-
},
|
|
442
|
-
editAdaptiveCard: {
|
|
443
|
-
messages: [
|
|
444
|
-
{
|
|
445
|
-
role: "user",
|
|
446
|
-
content: exports.MODIFY_ADAPTIVE_CARD_PROMPT_UNIVERSAL,
|
|
447
|
-
},
|
|
448
|
-
],
|
|
449
|
-
},
|
|
450
|
-
},
|
|
451
|
-
lexiconGeneration: {
|
|
452
|
-
messages: [
|
|
453
|
-
{
|
|
454
|
-
role: "user",
|
|
455
|
-
content: exports.LEXICON_GENERATION_PROMPT_UNIVERSAL,
|
|
456
|
-
},
|
|
457
|
-
],
|
|
458
|
-
},
|
|
459
|
-
flowGeneration: {
|
|
460
|
-
description: {
|
|
461
|
-
messages: [
|
|
462
|
-
{
|
|
463
|
-
role: "user",
|
|
464
|
-
content: exports.flowGenerationPromptWithDescriptionForGpt35Turbo,
|
|
465
|
-
},
|
|
466
|
-
],
|
|
467
|
-
},
|
|
468
|
-
transcript: {
|
|
469
|
-
messages: [
|
|
470
|
-
{
|
|
471
|
-
role: "user",
|
|
472
|
-
content: exports.flowGenerationPromptWithTranscriptForGpt35Turbo,
|
|
473
|
-
},
|
|
474
|
-
],
|
|
475
|
-
},
|
|
476
|
-
}
|
|
477
|
-
},
|
|
48
|
+
}
|
|
478
49
|
};
|
|
479
50
|
//# sourceMappingURL=generativeAIPrompts.js.map
|