@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
|
@@ -53,7 +53,7 @@ export function AuthenticationAPI(instance) {
|
|
|
53
53
|
}),
|
|
54
54
|
exchangeOneTimeTokenForRefreshToken: (_a, options) => {
|
|
55
55
|
var { loginToken } = _a, args = __rest(_a, ["loginToken"]);
|
|
56
|
-
return GenericAPIFn(`/auth/exchangetoken?${stringifyQuery({ loginToken })}`, "GET", self)(args, Object.assign({ withAuthentication: false }, options));
|
|
56
|
+
return GenericAPIFn(`/auth/exchangetoken?${stringifyQuery({ loginToken })}`, "GET", self)(args, Object.assign({ withAuthentication: false, withCredentials: true }, options));
|
|
57
57
|
},
|
|
58
58
|
generateManagementUIAuthToken: (args, options) => GenericAPIFn("/new/management/auth/token", "POST", self)(args, options)
|
|
59
59
|
};
|
|
@@ -2,7 +2,6 @@ import { __awaiter } from "tslib";
|
|
|
2
2
|
/* Custom Modules */
|
|
3
3
|
import { OAuth2Error } from "./OAuth2Error";
|
|
4
4
|
import { HttpStatusCode } from "../../shared/helper/HttpStatusCode";
|
|
5
|
-
import { UnauthorizedError } from "../../shared/errors";
|
|
6
5
|
import { OAuth2Errors } from "./IOAuth2ErrorResponse";
|
|
7
6
|
const expiryBuffer = 8;
|
|
8
7
|
export const OAuth2Authentication = function (credentials, self) {
|
|
@@ -27,7 +26,8 @@ export const OAuth2Authentication = function (credentials, self) {
|
|
|
27
26
|
};
|
|
28
27
|
return yield request(formFields, {
|
|
29
28
|
maxRetries: Infinity,
|
|
30
|
-
retryDelay: () => 3000
|
|
29
|
+
retryDelay: () => 3000,
|
|
30
|
+
withCredentials: true
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
33
|
const request = (formFields, options) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -82,6 +82,8 @@ export const OAuth2Authentication = function (credentials, self) {
|
|
|
82
82
|
OAuth2Authentication.prototype.login = (parameters) => __awaiter(this, void 0, void 0, function* () {
|
|
83
83
|
const { clientId, clientSecret } = self.credentials;
|
|
84
84
|
switch (parameters.type) {
|
|
85
|
+
// Password Grant is deprecated in OAuth2, but still supported
|
|
86
|
+
// for api and e2e tests
|
|
85
87
|
case "password":
|
|
86
88
|
{
|
|
87
89
|
const { username, password, rememberMe, organisationId } = parameters;
|
|
@@ -113,17 +115,19 @@ export const OAuth2Authentication = function (credentials, self) {
|
|
|
113
115
|
break;
|
|
114
116
|
case "authorizationCode":
|
|
115
117
|
{
|
|
116
|
-
const { code, redirectUri, codeVerifier } = parameters;
|
|
118
|
+
const { code, redirectUri, codeVerifier, rememberMe } = parameters;
|
|
117
119
|
const formFields = {
|
|
118
120
|
grant_type: "authorization_code",
|
|
119
121
|
client_id: clientId,
|
|
120
122
|
client_secret: clientSecret,
|
|
121
123
|
code,
|
|
122
124
|
redirect_uri: redirectUri,
|
|
125
|
+
rememberMe,
|
|
123
126
|
code_verifier: codeVerifier
|
|
124
127
|
};
|
|
125
128
|
self.tokenData = yield request(formFields, {
|
|
126
|
-
maxRetries: 0
|
|
129
|
+
maxRetries: 0,
|
|
130
|
+
withCredentials: true
|
|
127
131
|
});
|
|
128
132
|
}
|
|
129
133
|
break;
|
|
@@ -175,9 +179,6 @@ export const OAuth2Authentication = function (credentials, self) {
|
|
|
175
179
|
*/
|
|
176
180
|
if (isAccessTokenExpired(self.tokenData)) {
|
|
177
181
|
const credentials = self.credentials;
|
|
178
|
-
if (!self.tokenData.refresh_token) {
|
|
179
|
-
throw new UnauthorizedError("No RefreshToken provided.");
|
|
180
|
-
}
|
|
181
182
|
if (self.refreshTokenSingleton === null) {
|
|
182
183
|
self.refreshTokenSingleton = new Promise((resolve, reject) => {
|
|
183
184
|
refreshTokenGrant({
|
|
@@ -217,8 +218,7 @@ export const OAuth2Authentication = function (credentials, self) {
|
|
|
217
218
|
});
|
|
218
219
|
OAuth2Authentication.prototype.logout = () => __awaiter(this, void 0, void 0, function* () {
|
|
219
220
|
if ((self === null || self === void 0 ? void 0 : self.credentials.type) ===
|
|
220
|
-
"OAuth2"
|
|
221
|
-
self.tokenData.refresh_token) {
|
|
221
|
+
"OAuth2") {
|
|
222
222
|
const httpAdapter = self.getHttpAdapter();
|
|
223
223
|
const requestData = {
|
|
224
224
|
method: "POST",
|
|
@@ -227,6 +227,7 @@ export const OAuth2Authentication = function (credentials, self) {
|
|
|
227
227
|
token: self.tokenData.refresh_token
|
|
228
228
|
},
|
|
229
229
|
maxRetries: 3,
|
|
230
|
+
withCredentials: true,
|
|
230
231
|
retryDelay: () => 0
|
|
231
232
|
};
|
|
232
233
|
// reset tokenData to avoid multiple revoke calls
|
|
@@ -86,7 +86,7 @@ export class AxiosAdapter {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
convertRequest(request, client) {
|
|
89
|
-
var _a;
|
|
89
|
+
var _a, _b;
|
|
90
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
91
|
const baseUrl = (_a = request.baseUrl) !== null && _a !== void 0 ? _a : this.config.baseUrl;
|
|
92
92
|
const axiosRequest = {
|
|
@@ -94,6 +94,7 @@ export class AxiosAdapter {
|
|
|
94
94
|
headers: request.headers,
|
|
95
95
|
method: request.method || "GET",
|
|
96
96
|
url: `${baseUrl}${request.url}`,
|
|
97
|
+
withCredentials: (_b = request.withCredentials) !== null && _b !== void 0 ? _b : false,
|
|
97
98
|
validateStatus: (status) => !isRetryableStatus(status)
|
|
98
99
|
};
|
|
99
100
|
if (typeof request.onProgress === "function") {
|
|
@@ -2,7 +2,7 @@ import { __awaiter } from "tslib";
|
|
|
2
2
|
/* Custom modules */
|
|
3
3
|
import { createNodeDescriptor } from "../../createNodeDescriptor";
|
|
4
4
|
import { GO_TO } from "../logic";
|
|
5
|
-
import { randomUUID } from
|
|
5
|
+
import { v4 as randomUUID } from "uuid";
|
|
6
6
|
import { createLastConverationString, createLastConversationChatObject, createLastUserInputString, writeLLMDebugLogs } from "../nlu/generativeSlotFiller/prompt";
|
|
7
7
|
import { InternalServerError } from "../../../errors";
|
|
8
8
|
import { TranscriptEntryType, TranscriptRole } from "../../../interfaces/transcripts/transcripts";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __awaiter, __rest } from "tslib";
|
|
2
2
|
/* Custom modules */
|
|
3
3
|
import { createNodeDescriptor } from "../../../createNodeDescriptor";
|
|
4
|
-
import { randomUUID } from 'crypto';
|
|
5
4
|
import { setSessionConfig } from "../../voice/mappers/setSessionConfig.mapper";
|
|
6
5
|
import { voiceConfigParamsToVoiceSettings } from "../../voice/mappers/setSessionConfig.mapper";
|
|
7
6
|
import { logFullConfigToDebugMode } from "../../../../helper/logFullConfigToDebugMode";
|
|
@@ -9,6 +8,7 @@ import { createSystemMessage, getCognigyBrandMessage } from "./helpers/createSys
|
|
|
9
8
|
import { generateSearchPrompt } from "./helpers/generateSearchPrompt";
|
|
10
9
|
import { getUserMemory } from "./helpers/getUserMemory";
|
|
11
10
|
import { createToolDefinitions } from "./helpers/createToolDefinitions";
|
|
11
|
+
import { v4 as randomUUID } from "uuid";
|
|
12
12
|
import { TranscriptEntryType, TranscriptRole } from "../../../../interfaces/transcripts/transcripts";
|
|
13
13
|
export const AI_AGENT_TOOLS_WHITELIST = ["aiAgentJobDefault", "aiAgentJobTool", "aiAgentJobMCPTool"];
|
|
14
14
|
export const AI_AGENT_JOB = createNodeDescriptor({
|
|
@@ -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";
|
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|