wingbot 3.71.1 → 3.71.3

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.71.1",
3
+ "version": "3.71.3",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
@@ -51,8 +51,7 @@
51
51
  "mocha": "^10.2.0",
52
52
  "nyc": "^15.1.0",
53
53
  "rimraf": "^5.0.5",
54
- "sinon": "^17.0.1",
55
- "tsd-jsdoc": "^2.5.0"
54
+ "sinon": "^17.0.1"
56
55
  },
57
56
  "dependencies": {
58
57
  "@amplitude/ua-parser-js": "^0.7.33",
package/src/LLM.js CHANGED
@@ -150,7 +150,7 @@ class LLM {
150
150
 
151
151
  const prompt = session.toArray();
152
152
  const result = await this._provider.requestChat(prompt, opts);
153
-
153
+ this._logPrompt(prompt, result);
154
154
  return result;
155
155
  }
156
156
 
package/src/LLMSession.js CHANGED
@@ -221,9 +221,7 @@ class LLMSession {
221
221
  */
222
222
  messagesToSend (dontMarkAsSent = false) {
223
223
  if (!this._generatedIndex) {
224
- // eslint-disable-next-line no-console
225
- console.log('LLMSession', this.toString());
226
- throw new Error('LLMSession: no message to send');
224
+ return [];
227
225
  }
228
226
 
229
227
  let messages = this._chat.splice(this._generatedIndex);
package/src/Processor.js CHANGED
@@ -405,13 +405,18 @@ class Processor extends EventEmitter {
405
405
  return { status: 304 };
406
406
  }
407
407
 
408
- const llm = new LLM({
408
+ const llmOptions = {
409
409
  provider: new LLMMockProvider(),
410
- ...(typeof messageSender.logPrompt === 'function'
411
- ? { logger: messageSender }
412
- : {}),
413
410
  ...this.options.llm
414
- });
411
+ };
412
+
413
+ if (typeof messageSender.logPrompt === 'function') {
414
+ Object.assign(llmOptions, {
415
+ logger: messageSender
416
+ });
417
+ }
418
+
419
+ const llm = new LLM(llmOptions);
415
420
 
416
421
  const result = await this
417
422
  ._dispatch(message, pageId, messageSender, responderData, preloadPromise, llm);
@@ -419,7 +419,7 @@ function message (params, context = {}) {
419
419
  if (params.type === 'prompt') {
420
420
  const session = await res.llmSessionWithHistory(params.llmContextType);
421
421
 
422
- const response = await session.systemPrompt(text)
422
+ await session.systemPrompt(text)
423
423
  .debug()
424
424
  .generate();
425
425
 
@@ -427,7 +427,16 @@ function message (params, context = {}) {
427
427
  // // no response?
428
428
  // }
429
429
 
430
- text = response.content;
430
+ const messages = session.messagesToSend();
431
+
432
+ const lastMessageI = messages.length - 1;
433
+ messages.forEach((m, i) => {
434
+ if (lastMessageI === i) {
435
+ text = m.content;
436
+ } else {
437
+ res.text(m.content);
438
+ }
439
+ });
431
440
  }
432
441
 
433
442
  res.text(text, sendReplies, voiceControl);