wingbot 3.71.5 → 3.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +0 -0
- package/.github/workflows/deploy.yml +2 -2
- package/.github/workflows/pullRequest.yml +2 -2
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/index.js +0 -0
- package/jsconfig.json +0 -0
- package/package.json +1 -1
- package/plugins/ai.wingbot.clearMessageSequences/plugin.js +0 -0
- package/plugins/ai.wingbot.conditionIfGoBackPossible/plugin.js +0 -0
- package/plugins/ai.wingbot.disambiguation/plugin.js +0 -0
- package/plugins/ai.wingbot.goBack/plugin.js +0 -0
- package/plugins/ai.wingbot.goToLastBreadcrumb/plugin.js +0 -0
- package/plugins/ai.wingbot.ifImageDetected/plugin.js +0 -0
- package/plugins/ai.wingbot.ifStickerDetected/plugin.js +0 -0
- package/plugins/ai.wingbot.jumpBack/plugin.js +0 -0
- package/plugins/ai.wingbot.jumpTo/plugin.js +0 -0
- package/plugins/ai.wingbot.keepInInteraction/plugin.js +0 -0
- package/plugins/ai.wingbot.keepInInteractionJustOnce/plugin.js +0 -0
- package/plugins/ai.wingbot.keepPreviousHandlers/plugin.js +0 -0
- package/plugins/ai.wingbot.keepPreviousHandlersJustOnce/plugin.js +0 -0
- package/plugins/ai.wingbot.oneTimeNotificationRequest/plugin.js +0 -0
- package/plugins/ai.wingbot.openai/plugin.js +0 -0
- package/plugins/ai.wingbot.passThreadToBot/plugin.js +0 -0
- package/plugins/ai.wingbot.persona/plugin.js +0 -0
- package/plugins/ai.wingbot.putABreadcrumb/plugin.js +0 -0
- package/plugins/ai.wingbot.regexp/plugin.js +0 -0
- package/plugins/ai.wingbot.setState/plugin.js +0 -0
- package/plugins/ai.wingbot.setStateFromInput/plugin.js +0 -0
- package/plugins/ai.wingbot.slotsContinue/plugin.js +0 -0
- package/plugins/ai.wingbot.slotsRegister/plugin.js +0 -0
- package/plugins/ai.wingbot.stopResponding/plugin.js +0 -0
- package/plugins/ai.wingbot.trackingEvent/plugin.js +0 -0
- package/plugins/ai.wingbot.upload/plugin.js +0 -0
- package/plugins/ai.wingbot.waitASecond/plugin.js +0 -0
- package/plugins/index.js +0 -0
- package/plugins/plugins.json +0 -0
- package/src/Ai.js +44 -3
- package/src/AiMatching.js +66 -40
- package/src/BatchConversationTester.js +0 -0
- package/src/BotApp.js +0 -0
- package/src/BotAppSender.js +0 -0
- package/src/BuildRouter.js +2 -0
- package/src/CallbackAuditLog.js +0 -0
- package/src/ChatGpt.js +0 -0
- package/src/ConversationTester.js +0 -0
- package/src/LLM.js +184 -3
- package/src/LLMMockProvider.js +0 -0
- package/src/LLMSession.js +90 -3
- package/src/MockAiModel.js +0 -0
- package/src/OrchestratorClient.js +0 -0
- package/src/Plugins.js +0 -0
- package/src/Processor.js +1 -1
- package/src/ReducerWrapper.js +0 -0
- package/src/Request.js +0 -0
- package/src/Responder.js +142 -11
- package/src/ReturnSender.js +4 -4
- package/src/Router.js +0 -0
- package/src/RouterWrap.js +0 -0
- package/src/SecurityMiddleware.js +0 -0
- package/src/Tester.js +44 -2
- package/src/analytics/GA4.js +0 -0
- package/src/analytics/consts.js +0 -0
- package/src/analytics/onInteractionHandler.js +0 -0
- package/src/defaultResourceMap.js +0 -0
- package/src/features.js +0 -0
- package/src/flags.js +0 -0
- package/src/fuzzy/factoryFuzzySearch.js +0 -0
- package/src/fuzzy/fuzzyUtils.js +0 -0
- package/src/fuzzy/index.js +0 -0
- package/src/fuzzy/levenshtein.js +0 -0
- package/src/fuzzy/normalize.js +0 -0
- package/src/fuzzy/prepareFuzzyIndex.js +0 -0
- package/src/graphApi/GraphApi.js +0 -0
- package/src/graphApi/WingbotApiConnector.js +0 -0
- package/src/graphApi/apiAuthorizer.js +0 -0
- package/src/graphApi/conversationTestApi.js +0 -0
- package/src/graphApi/conversationsApi.js +0 -0
- package/src/graphApi/index.js +0 -0
- package/src/graphApi/postBackApi.js +0 -0
- package/src/graphApi/schema.gql +0 -0
- package/src/graphApi/validateBotApi.js +0 -0
- package/src/notifications/Notifications.js +0 -0
- package/src/notifications/NotificationsStorage.js +0 -0
- package/src/notifications/api/index.js +0 -0
- package/src/notifications/api/notificationsApiFactory.js +0 -0
- package/src/notifications/index.js +0 -0
- package/src/resolvers/bounce.js +0 -0
- package/src/resolvers/button.js +0 -0
- package/src/resolvers/carousel.js +0 -0
- package/src/resolvers/contextMessage.js +21 -4
- package/src/resolvers/expected.js +0 -0
- package/src/resolvers/expectedInput.js +0 -0
- package/src/resolvers/hbs.js +0 -0
- package/src/resolvers/include.js +0 -0
- package/src/resolvers/index.js +0 -0
- package/src/resolvers/media.js +0 -0
- package/src/resolvers/message.js +54 -4
- package/src/resolvers/passThread.js +0 -0
- package/src/resolvers/path.js +0 -0
- package/src/resolvers/plugin.js +0 -0
- package/src/resolvers/postback.js +0 -0
- package/src/resolvers/resolverTags.js +0 -0
- package/src/resolvers/setState.js +0 -0
- package/src/resolvers/skip.js +0 -0
- package/src/resolvers/subscribtions.js +0 -0
- package/src/resolvers/utils.js +14 -5
- package/src/systemEntities/email.js +0 -0
- package/src/systemEntities/index.js +0 -0
- package/src/systemEntities/phone.js +0 -0
- package/src/systemEntities/regexps.js +0 -0
- package/src/templates/BaseTemplate.js +0 -0
- package/src/templates/ButtonTemplate.js +0 -0
- package/src/templates/GenericTemplate.js +0 -0
- package/src/templates/ListTemplate.js +0 -0
- package/src/templates/ReceiptTemplate.js +0 -0
- package/src/testTools/AnyResponseAssert.js +0 -0
- package/src/testTools/PromptAssert.js +184 -0
- package/src/testTools/ResponseAssert.js +0 -0
- package/src/testTools/asserts.js +42 -4
- package/src/testTools/index.js +0 -0
- package/src/tools/MemoryBotConfigStorage.js +0 -0
- package/src/tools/MemoryChatLogStorage.js +0 -0
- package/src/tools/MemoryStateStorage.js +0 -0
- package/src/tools/bufferloader.js +0 -0
- package/src/tools/index.js +0 -0
- package/src/tools/routeToEvents.js +0 -0
- package/src/transcript/extractText.js +0 -0
- package/src/transcript/textBodyFromTranscript.js +0 -0
- package/src/transcript/transcriptFromHistory.js +0 -0
- package/src/utils/ai.js +0 -0
- package/src/utils/compileWithState.js +0 -0
- package/src/utils/customCondition.js +14 -1
- package/src/utils/customFn.js +0 -0
- package/src/utils/datetime.js +0 -0
- package/src/utils/deepMapTools.js +0 -0
- package/src/utils/generateToken.js +0 -0
- package/src/utils/getCondition.js +16 -4
- package/src/utils/getUpdate.js +4 -4
- package/src/utils/headersToAuditMeta.js +0 -0
- package/src/utils/index.js +0 -0
- package/src/utils/pathUtils.js +0 -0
- package/src/utils/quickReplies.js +0 -0
- package/src/utils/slots.js +0 -0
- package/src/utils/stateData.js +2 -0
- package/src/utils/stateVariables.js +0 -0
- package/src/utils/tokenizer.js +0 -0
- package/src/utils/wrapPluginFunction.js +0 -0
- package/src/wingbot/CachedModel.js +0 -0
- package/src/wingbot/CustomEntityDetectionModel.js +0 -0
- package/src/wingbot/WingbotModel.js +0 -0
- package/src/wingbot/index.js +0 -0
package/src/testTools/asserts.js
CHANGED
|
@@ -7,6 +7,9 @@ const assert = require('assert');
|
|
|
7
7
|
const deepExtend = require('deep-extend');
|
|
8
8
|
const { actionMatches, parseActionPayload } = require('../utils');
|
|
9
9
|
|
|
10
|
+
/** @typedef {import('../LLM').PromptInfo} PromptInfo */
|
|
11
|
+
/** @typedef {import('../LLM').LLMMessage} LLMMessage */
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* Format message
|
|
12
15
|
*
|
|
@@ -29,9 +32,21 @@ function m (text, actual = null, expected = null) {
|
|
|
29
32
|
return `${text}${result}`;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
function ex (message, expected, actual) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
function ex (message, expected, actual = null) {
|
|
36
|
+
let actuals;
|
|
37
|
+
if (Array.isArray(actual)) {
|
|
38
|
+
actuals = actual;
|
|
39
|
+
} else {
|
|
40
|
+
actuals = actual === null ? [] : [actual];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const msg = `${message}\n + expected: "${expected}"`;
|
|
44
|
+
|
|
45
|
+
if (actuals.length === 0) {
|
|
46
|
+
return msg;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return `${msg}\n - actual: ${actuals
|
|
35
50
|
.map((a) => `"${a}"`).join('\n ')}`;
|
|
36
51
|
}
|
|
37
52
|
|
|
@@ -144,6 +159,28 @@ function contains (response, search, message = 'Should contain a text') {
|
|
|
144
159
|
return true;
|
|
145
160
|
}
|
|
146
161
|
|
|
162
|
+
/**
|
|
163
|
+
*
|
|
164
|
+
* @param {LLMMessage} llmMsg
|
|
165
|
+
* @param {string} search
|
|
166
|
+
* @param {string|false} message
|
|
167
|
+
*/
|
|
168
|
+
function llmContains (llmMsg, search, message = 'Should contain a text') {
|
|
169
|
+
const text = llmMsg.content;
|
|
170
|
+
|
|
171
|
+
const typeIsText = typeof text === 'string';
|
|
172
|
+
if (message === false && !typeIsText) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
assert.ok(typeIsText, m(message, search, 'not a text message'));
|
|
176
|
+
const match = searchMatchesText(search, text);
|
|
177
|
+
if (message === false) {
|
|
178
|
+
return match;
|
|
179
|
+
}
|
|
180
|
+
assert.ok(match, m(message, text, search));
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
|
|
147
184
|
/**
|
|
148
185
|
* Checks quick response action
|
|
149
186
|
*
|
|
@@ -374,5 +411,6 @@ module.exports = {
|
|
|
374
411
|
quickReplyText,
|
|
375
412
|
getText,
|
|
376
413
|
parseActionPayload,
|
|
377
|
-
ex
|
|
414
|
+
ex,
|
|
415
|
+
llmContains
|
|
378
416
|
};
|
package/src/testTools/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/tools/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/utils/ai.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -175,9 +175,22 @@ const compare = (variable, operator, value = undefined) => {
|
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
+
/** @typedef {'if'|'it'|'c'|'nc'|'mr'|'nmr'|'st'|'gt'|'set'|'get'|'eq'|'neq'} ConditionOperator */
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @typedef {object} EditableConditionRule
|
|
182
|
+
* @prop {string} value
|
|
183
|
+
* @prop {ConditionOperator} operator
|
|
184
|
+
* @prop {string} variable
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @typedef {EditableConditionRule[][]} EditableCondition
|
|
189
|
+
*/
|
|
190
|
+
|
|
178
191
|
/**
|
|
179
192
|
*
|
|
180
|
-
* @param {
|
|
193
|
+
* @param {EditableCondition} condition
|
|
181
194
|
* @param {object} configuration
|
|
182
195
|
* @param {string} description
|
|
183
196
|
*/
|
package/src/utils/customFn.js
CHANGED
|
File without changes
|
package/src/utils/datetime.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -7,11 +7,23 @@ const customCondition = require('./customCondition');
|
|
|
7
7
|
const customFn = require('./customFn');
|
|
8
8
|
|
|
9
9
|
/** @typedef {import('../BuildRouter').BotContext} BotContext */
|
|
10
|
+
/** @typedef {import('./customCondition').EditableCondition} EditableCondition */
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line max-len
|
|
13
|
+
/** @typedef {Pick<BotContext,'configuration'|'allowForbiddenSnippetWords'|'linksMap'|'ai'>} ConditionContext */
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {object} ConditionDefinition
|
|
17
|
+
* @prop {boolean} [hasCondition]
|
|
18
|
+
* @prop {string} [conditionFn]
|
|
19
|
+
* @prop {boolean} [hasEditableCondition]
|
|
20
|
+
* @prop {EditableCondition} [editableCondition]
|
|
21
|
+
*/
|
|
10
22
|
|
|
11
23
|
/**
|
|
12
24
|
*
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
25
|
+
* @param {ConditionDefinition} params
|
|
26
|
+
* @param {ConditionContext} context
|
|
15
27
|
* @param {string} description
|
|
16
28
|
* @returns {Function}
|
|
17
29
|
*/
|
|
@@ -27,7 +39,7 @@ module.exports = function getCondition (params, context, description = '') {
|
|
|
27
39
|
editableCondition = []
|
|
28
40
|
} = params;
|
|
29
41
|
|
|
30
|
-
let condition
|
|
42
|
+
let condition;
|
|
31
43
|
|
|
32
44
|
if (hasCondition) {
|
|
33
45
|
if (hasEditableCondition) {
|
|
@@ -36,7 +48,7 @@ module.exports = function getCondition (params, context, description = '') {
|
|
|
36
48
|
condition = customFn(conditionFn, description, allowForbiddenSnippetWords);
|
|
37
49
|
}
|
|
38
50
|
} else {
|
|
39
|
-
condition =
|
|
51
|
+
condition = () => true;
|
|
40
52
|
}
|
|
41
53
|
return condition;
|
|
42
54
|
};
|
package/src/utils/getUpdate.js
CHANGED
|
@@ -88,7 +88,7 @@ function toArray (previousValue) {
|
|
|
88
88
|
const ENTITY_HBS_REGEXP = /^\s*\{\{\[?@([^@[\]{}\s]+)(\])?\}\}\s*$/;
|
|
89
89
|
const VARIABLE_HBS_REGEXP = /^\s*\{\{\[?([^$@[\]{}\s]+)\]?\}\}\s*$/;
|
|
90
90
|
|
|
91
|
-
function getSetState (setState, req, res = null,
|
|
91
|
+
function getSetState (setState, req, res = null, stateOverride = null, configuration = null) {
|
|
92
92
|
if (!setState) {
|
|
93
93
|
return {};
|
|
94
94
|
}
|
|
@@ -96,7 +96,7 @@ function getSetState (setState, req, res = null, useState = null, configuration
|
|
|
96
96
|
.filter((k) => k !== '_');
|
|
97
97
|
|
|
98
98
|
let obj = {};
|
|
99
|
-
let state = stateData(req, res, configuration,
|
|
99
|
+
let state = stateData(req, res, configuration, stateOverride);
|
|
100
100
|
|
|
101
101
|
keys.forEach((k) => {
|
|
102
102
|
const val = setState[k];
|
|
@@ -166,8 +166,8 @@ function getSetState (setState, req, res = null, useState = null, configuration
|
|
|
166
166
|
if (entity && (!rear || req.entities.some((e) => e.entity === entity))) {
|
|
167
167
|
values = req.entities.filter((e) => e.entity === entity)
|
|
168
168
|
.map((e) => e.value);
|
|
169
|
-
if (values.length === 0 &&
|
|
170
|
-
values = [
|
|
169
|
+
if (values.length === 0 && stateOverride && stateOverride[`@${entity}`]) {
|
|
170
|
+
values = [stateOverride[`@${entity}`]];
|
|
171
171
|
}
|
|
172
172
|
} else if (variable) {
|
|
173
173
|
values = toArray(getValue(variable, state));
|
|
File without changes
|
package/src/utils/index.js
CHANGED
|
File without changes
|
package/src/utils/pathUtils.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/utils/slots.js
CHANGED
|
File without changes
|
package/src/utils/stateData.js
CHANGED
|
@@ -16,6 +16,7 @@ const { dateToISO8601String, zeroHourDate } = require('./datetime');
|
|
|
16
16
|
* @prop {object} [configuration]
|
|
17
17
|
* @prop {Function} text
|
|
18
18
|
* @prop {Function} [actionData]
|
|
19
|
+
* @prop {Function} [isConfidentInput]
|
|
19
20
|
*/
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -68,6 +69,7 @@ module.exports = function stateData (
|
|
|
68
69
|
$today,
|
|
69
70
|
$tomorrow,
|
|
70
71
|
$yesterday,
|
|
72
|
+
$llmResult: res?.llm?.lastResult?.content,
|
|
71
73
|
// yes - res because of circular dependency
|
|
72
74
|
...(res && req && req.actionData()),
|
|
73
75
|
...(res ? res.data : {}),
|
|
File without changes
|
package/src/utils/tokenizer.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/wingbot/index.js
CHANGED
|
File without changes
|