wingbot 3.72.1 → 3.73.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/.babelrc +0 -0
- package/.github/workflows/deploy.yml +0 -0
- package/.github/workflows/pullRequest.yml +0 -0
- 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 +0 -0
- package/src/AiMatching.js +0 -0
- package/src/BatchConversationTester.js +0 -0
- package/src/BotApp.js +0 -0
- package/src/BuildRouter.js +0 -0
- package/src/CallbackAuditLog.js +0 -0
- package/src/ChatGpt.js +0 -0
- package/src/ConversationTester.js +0 -0
- package/src/LLM.js +26 -4
- package/src/LLMMockProvider.js +0 -0
- package/src/LLMSession.js +5 -3
- package/src/MockAiModel.js +0 -0
- package/src/OrchestratorClient.js +0 -0
- package/src/Plugins.js +0 -0
- package/src/Processor.js +1 -0
- package/src/ReducerWrapper.js +0 -0
- package/src/Request.js +0 -0
- package/src/Responder.js +0 -0
- package/src/ReturnSender.js +0 -0
- package/src/Router.js +0 -0
- package/src/RouterWrap.js +0 -0
- package/src/SecurityMiddleware.js +0 -0
- package/src/Tester.js +0 -0
- 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 -3
- 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 +1 -1
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +22 -0
- package/src/testTools/ResponseAssert.js +0 -0
- package/src/testTools/asserts.js +0 -0
- 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 +0 -0
- 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 +0 -0
- package/src/utils/getUpdate.js +0 -0
- 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 +0 -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/.babelrc
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/index.js
CHANGED
|
File without changes
|
package/jsconfig.json
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/plugins/index.js
CHANGED
|
File without changes
|
package/plugins/plugins.json
CHANGED
|
File without changes
|
package/src/Ai.js
CHANGED
|
File without changes
|
package/src/AiMatching.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/BotApp.js
CHANGED
|
File without changes
|
package/src/BuildRouter.js
CHANGED
|
File without changes
|
package/src/CallbackAuditLog.js
CHANGED
|
File without changes
|
package/src/ChatGpt.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/LLM.js
CHANGED
|
@@ -82,6 +82,11 @@ const Ai = require('./Ai');
|
|
|
82
82
|
* @prop {string} [model]
|
|
83
83
|
*/
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @typedef {object} LLMLogOptions
|
|
87
|
+
* @prop {VectorSearchResult} [vectorSearchResult]
|
|
88
|
+
*/
|
|
89
|
+
|
|
85
90
|
/**
|
|
86
91
|
* @typedef {object} LLMChatProvider
|
|
87
92
|
* @prop {LLMChatProviderPrompt} requestChat
|
|
@@ -110,6 +115,7 @@ const Ai = require('./Ai');
|
|
|
110
115
|
* @typedef {object} PromptInfo
|
|
111
116
|
* @prop {LLMMessage[]} prompt
|
|
112
117
|
* @prop {LLMMessage} result
|
|
118
|
+
* @prop {VectorSearchResult} [vectorSearchResult]
|
|
113
119
|
*/
|
|
114
120
|
|
|
115
121
|
/**
|
|
@@ -122,6 +128,20 @@ const Ai = require('./Ai');
|
|
|
122
128
|
* @prop {LogPrompt} logPrompt
|
|
123
129
|
*/
|
|
124
130
|
|
|
131
|
+
/**
|
|
132
|
+
* @typedef {object} VectorSearchDocument
|
|
133
|
+
* @property {string} id
|
|
134
|
+
* @property {string} name
|
|
135
|
+
* @property {string} text
|
|
136
|
+
* @property {number} cosineDistance
|
|
137
|
+
* @property {boolean} excludedByCosineDistanceThreshold
|
|
138
|
+
*/
|
|
139
|
+
/**
|
|
140
|
+
* @typedef {object} VectorSearchResult
|
|
141
|
+
* @property {number} maximalCosineDistanceThreshold
|
|
142
|
+
* @property {number} nearestNeighbourCount
|
|
143
|
+
* @property {VectorSearchDocument[]} resultDocuments
|
|
144
|
+
*/
|
|
125
145
|
/**
|
|
126
146
|
* @class LLM
|
|
127
147
|
*/
|
|
@@ -222,9 +242,10 @@ class LLM {
|
|
|
222
242
|
*
|
|
223
243
|
* @param {LLMSession} session
|
|
224
244
|
* @param {LLMProviderOptions} [options={}]
|
|
245
|
+
* @param {LLMLogOptions} [logOptions]
|
|
225
246
|
* @returns {Promise<LLMMessage>}
|
|
226
247
|
*/
|
|
227
|
-
async generate (session, options = {}) {
|
|
248
|
+
async generate (session, options = {}, logOptions = {}) {
|
|
228
249
|
/** @type {LLMProviderOptions} */
|
|
229
250
|
const opts = {
|
|
230
251
|
...(this._configuration.model && { model: this._configuration.model }),
|
|
@@ -233,7 +254,7 @@ class LLM {
|
|
|
233
254
|
|
|
234
255
|
const prompt = session.toArray(true);
|
|
235
256
|
const result = await this._provider.requestChat(prompt, opts);
|
|
236
|
-
this.
|
|
257
|
+
this.logPrompt(prompt, result, logOptions.vectorSearchResult);
|
|
237
258
|
return result;
|
|
238
259
|
}
|
|
239
260
|
|
|
@@ -241,11 +262,12 @@ class LLM {
|
|
|
241
262
|
*
|
|
242
263
|
* @param {LLMMessage[]} prompt
|
|
243
264
|
* @param {LLMMessage} result
|
|
265
|
+
* @param {VectorSearchResult} [vectorSearchResult]
|
|
244
266
|
*/
|
|
245
|
-
|
|
267
|
+
logPrompt (prompt, result, vectorSearchResult) {
|
|
246
268
|
this._lastResult = result;
|
|
247
269
|
this._configuration.logger.logPrompt({
|
|
248
|
-
prompt, result
|
|
270
|
+
prompt, result, vectorSearchResult
|
|
249
271
|
});
|
|
250
272
|
}
|
|
251
273
|
|
package/src/LLMMockProvider.js
CHANGED
|
File without changes
|
package/src/LLMSession.js
CHANGED
|
@@ -7,6 +7,7 @@ const LLM = require('./LLM');
|
|
|
7
7
|
|
|
8
8
|
/** @typedef {import('./Responder').QuickReply} QuickReply */
|
|
9
9
|
/** @typedef {import('./LLM').LLMProviderOptions} LLMProviderOptions */
|
|
10
|
+
/** @typedef {import('./LLM').LLMLogOptions} LLMLogOptions */
|
|
10
11
|
|
|
11
12
|
/** @typedef {'user'|'assistant'} LLMChatRole */
|
|
12
13
|
/** @typedef {'system'} LLMSystemRole */
|
|
@@ -272,11 +273,12 @@ class LLMSession {
|
|
|
272
273
|
|
|
273
274
|
/**
|
|
274
275
|
*
|
|
275
|
-
* @param {LLMProviderOptions} [
|
|
276
|
+
* @param {LLMProviderOptions} [providerOptions={}]
|
|
277
|
+
* @param {LLMLogOptions} [logOptions]
|
|
276
278
|
* @returns {Promise<LLMMessage<any>>}
|
|
277
279
|
*/
|
|
278
|
-
async generate (
|
|
279
|
-
const result = await this._llm.generate(this,
|
|
280
|
+
async generate (providerOptions = {}, logOptions = {}) {
|
|
281
|
+
const result = await this._llm.generate(this, providerOptions, logOptions);
|
|
280
282
|
|
|
281
283
|
this._generatedIndex = this._chat.length;
|
|
282
284
|
this._chat.push(result);
|
package/src/MockAiModel.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/Plugins.js
CHANGED
|
File without changes
|
package/src/Processor.js
CHANGED
package/src/ReducerWrapper.js
CHANGED
|
File without changes
|
package/src/Request.js
CHANGED
|
File without changes
|
package/src/Responder.js
CHANGED
|
File without changes
|
package/src/ReturnSender.js
CHANGED
|
File without changes
|
package/src/Router.js
CHANGED
|
File without changes
|
package/src/RouterWrap.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/Tester.js
CHANGED
|
File without changes
|
package/src/analytics/GA4.js
CHANGED
|
File without changes
|
package/src/analytics/consts.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/features.js
CHANGED
|
File without changes
|
package/src/flags.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/fuzzy/fuzzyUtils.js
CHANGED
|
File without changes
|
package/src/fuzzy/index.js
CHANGED
|
File without changes
|
package/src/fuzzy/levenshtein.js
CHANGED
|
File without changes
|
package/src/fuzzy/normalize.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/graphApi/GraphApi.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/graphApi/index.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/graphApi/schema.gql
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/resolvers/bounce.js
CHANGED
|
File without changes
|
package/src/resolvers/button.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/resolvers/hbs.js
CHANGED
|
File without changes
|
package/src/resolvers/include.js
CHANGED
|
File without changes
|
package/src/resolvers/index.js
CHANGED
|
File without changes
|
package/src/resolvers/media.js
CHANGED
|
File without changes
|
package/src/resolvers/message.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/resolvers/path.js
CHANGED
|
File without changes
|
package/src/resolvers/plugin.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/resolvers/skip.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/resolvers/utils.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -59,6 +59,18 @@ class PromptAssert {
|
|
|
59
59
|
return this;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Check if vector search documents contain selected string
|
|
64
|
+
*
|
|
65
|
+
* @param {string} search
|
|
66
|
+
* @returns {this}
|
|
67
|
+
*/
|
|
68
|
+
vectorSearchContains (search) {
|
|
69
|
+
const documents = this._flatVectorSearchDocuments();
|
|
70
|
+
this._promptContains(search, documents, false, 'in vector search documents');
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
62
74
|
/**
|
|
63
75
|
*
|
|
64
76
|
* @param {(value: LLMMessage, index: number, array: LLMMessage[]) => unknown} filter
|
|
@@ -79,6 +91,16 @@ class PromptAssert {
|
|
|
79
91
|
.map((prompt) => prompt.result);
|
|
80
92
|
}
|
|
81
93
|
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @returns {LLMMessage[]}
|
|
97
|
+
*/
|
|
98
|
+
_flatVectorSearchDocuments () {
|
|
99
|
+
return this._prompts
|
|
100
|
+
.flatMap((prompt) => prompt.vectorSearchResult?.resultDocuments || [])
|
|
101
|
+
.map((doc) => ({ role: 'system', content: doc.text }));
|
|
102
|
+
}
|
|
103
|
+
|
|
82
104
|
_promptContains (search, messages, notContains = false, addMessage = 'No LLM message found') {
|
|
83
105
|
if (messages.length === 0) {
|
|
84
106
|
PromptAssert.debug(this._prompts, true);
|
|
File without changes
|
package/src/testTools/asserts.js
CHANGED
|
File without changes
|
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
|
|
File without changes
|
package/src/utils/customFn.js
CHANGED
|
File without changes
|
package/src/utils/datetime.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/utils/getUpdate.js
CHANGED
|
File without changes
|
|
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
|
File without changes
|
|
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
|