wingbot 3.73.4 → 3.73.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.73.4",
3
+ "version": "3.73.5",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
@@ -127,6 +127,13 @@ const DUMMY_ROUTE = { id: 0, path: null, resolvers: [] };
127
127
  * @returns {string}
128
128
  */
129
129
 
130
+ /**
131
+ * @typedef {object} ILogger
132
+ * @prop {Function} log
133
+ * @prop {Function} warn
134
+ * @prop {Function} error
135
+ */
136
+
130
137
  /**
131
138
  * @template {BaseConfiguration} [C=object]
132
139
  * @typedef {object} BuildRouterContext
@@ -135,6 +142,8 @@ const DUMMY_ROUTE = { id: 0, path: null, resolvers: [] };
135
142
  * @prop {boolean} [allowForbiddenSnippetWords] - disable security rule
136
143
  * @prop {Middleware} [defaultPlugin] - to be able to test configurations without plugins
137
144
  * @prop {RouteConfig[]} [routeConfigs] - list of disabled routes
145
+ * @prop {boolean|keyof ILogger} [canaryLogs]
146
+ * @prop {ILogger} [log]
138
147
  * @prop {C} [configuration] - context data
139
148
  */
140
149
 
package/src/LLM.js CHANGED
@@ -103,6 +103,7 @@ const Ai = require('./Ai');
103
103
  * @prop {boolean} [transcriptAnonymize]
104
104
  * @prop {Persona|string|null} [persona]
105
105
  * @prop {LLMLogger} [logger]
106
+ * @prop {boolean} [disableLLM]
106
107
  */
107
108
 
108
109
  /**
@@ -219,6 +220,14 @@ class LLM {
219
220
  return this._configuration;
220
221
  }
221
222
 
223
+ /**
224
+ *
225
+ * @param {Partial<LLMConfiguration>} override
226
+ */
227
+ setSessionConfig (override) {
228
+ Object.assign(this._configuration, override);
229
+ }
230
+
222
231
  /**
223
232
  *
224
233
  * @param {Transcript[]} chat
@@ -21,6 +21,7 @@ const {
21
21
  } = require('../features');
22
22
  const { vars, VAR_TYPES } = require('../utils/stateVariables');
23
23
  const LLM = require('../LLM');
24
+ const canaryLog = require('../utils/canaryLog');
24
25
 
25
26
  /** @typedef {import('../Responder').VoiceControl} VoiceControl */
26
27
  /** @typedef {import('../BuildRouter').LinksMap} LinksMap */
@@ -445,7 +446,7 @@ function message (params, context = {}) {
445
446
  };
446
447
  }
447
448
 
448
- if (params.type === 'prompt') {
449
+ if (params.type === 'prompt' && !res.llm.configuration.disableLLM) {
449
450
  res.typingOn()
450
451
  .wait(1000);
451
452
  const session = await res.llmSessionWithHistory(params.llmContextType);
@@ -456,6 +457,10 @@ function message (params, context = {}) {
456
457
  const evaluation = await res.llmEvaluate(session, params.llmContextType);
457
458
 
458
459
  if (evaluation.discard) {
460
+ canaryLog(context.log, context.canaryLogs, 'LLM discarded', {
461
+ evaluation,
462
+ session
463
+ });
459
464
  if (isLastMessage && !req.actionData()._resolverTag) {
460
465
  res.finalMessageSent = true;
461
466
  }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @author David Menger
3
+ */
4
+ 'use strict';
5
+
6
+ /**
7
+ * @typedef {object} ILogger
8
+ * @prop {Function} log
9
+ * @prop {Function} warn
10
+ * @prop {Function} error
11
+ */
12
+
13
+ /**
14
+ *
15
+ * @param {ILogger} logger
16
+ * @param {boolean|keyof ILogger} setting
17
+ * @param {string} message
18
+ * @param {...*} args
19
+ * @returns {void}
20
+ */
21
+ function canaryLog (logger, setting, message, ...args) {
22
+ if (setting) {
23
+ const key = typeof setting === 'boolean'
24
+ ? 'error'
25
+ : setting;
26
+ (logger || console)[key](`#CANARY: ${message}`, ...args);
27
+ }
28
+ }
29
+
30
+ module.exports = canaryLog;