wingbot 3.73.8 → 3.73.10
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 +1 -1
- package/src/BuildRouter.js +1 -1
- package/src/resolvers/message.js +37 -29
- package/src/utils/canaryLog.js +1 -1
package/package.json
CHANGED
package/src/BuildRouter.js
CHANGED
|
@@ -142,7 +142,7 @@ const DUMMY_ROUTE = { id: 0, path: null, resolvers: [] };
|
|
|
142
142
|
* @prop {boolean} [allowForbiddenSnippetWords] - disable security rule
|
|
143
143
|
* @prop {Middleware} [defaultPlugin] - to be able to test configurations without plugins
|
|
144
144
|
* @prop {RouteConfig[]} [routeConfigs] - list of disabled routes
|
|
145
|
-
* @prop {boolean|
|
|
145
|
+
* @prop {boolean|string} [canaryLogs]
|
|
146
146
|
* @prop {ILogger} [log]
|
|
147
147
|
* @prop {C} [configuration] - context data
|
|
148
148
|
*/
|
package/src/resolvers/message.js
CHANGED
|
@@ -449,47 +449,55 @@ function message (params, context = {}) {
|
|
|
449
449
|
if (params.type === 'prompt' && !res.llm.configuration.disableLLM) {
|
|
450
450
|
res.typingOn()
|
|
451
451
|
.wait(1000);
|
|
452
|
-
const session = await res.llmSessionWithHistory(params.llmContextType);
|
|
453
452
|
|
|
454
|
-
|
|
455
|
-
|
|
453
|
+
let session;
|
|
454
|
+
let evaluation;
|
|
455
|
+
let discard;
|
|
456
456
|
|
|
457
|
-
|
|
457
|
+
try {
|
|
458
|
+
session = await res.llmSessionWithHistory(params.llmContextType);
|
|
458
459
|
|
|
459
|
-
|
|
460
|
+
await session.systemPrompt(text)
|
|
461
|
+
.generate();
|
|
462
|
+
|
|
463
|
+
evaluation = await res.llmEvaluate(session, params.llmContextType);
|
|
464
|
+
({ discard } = evaluation);
|
|
465
|
+
} catch (e) {
|
|
466
|
+
(context.log || console).error(`LLM ERR: ${e.message} [${req.senderId}]`, e);
|
|
467
|
+
discard = true;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (discard) {
|
|
460
471
|
canaryLog(context.log, context.canaryLogs, 'LLM discarded', {
|
|
461
472
|
evaluation,
|
|
462
473
|
session
|
|
463
474
|
});
|
|
464
|
-
|
|
465
|
-
res.finalMessageSent = true;
|
|
466
|
-
}
|
|
467
|
-
return ret;
|
|
468
|
-
}
|
|
475
|
+
} else {
|
|
469
476
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
477
|
+
if (evaluation.action) {
|
|
478
|
+
postBack(evaluation.action);
|
|
479
|
+
return Router.END;
|
|
480
|
+
}
|
|
474
481
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
482
|
+
// if (!response.content) {
|
|
483
|
+
// // no response?
|
|
484
|
+
// }
|
|
478
485
|
|
|
479
|
-
|
|
486
|
+
const messages = session.messagesToSend();
|
|
480
487
|
|
|
481
|
-
|
|
488
|
+
res.setFlag(LLM.GPT_FLAG);
|
|
482
489
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
490
|
+
const lastMessageI = messages.length - 1;
|
|
491
|
+
messages.forEach((m, i) => {
|
|
492
|
+
if (lastMessageI === i) {
|
|
493
|
+
text = m.content;
|
|
494
|
+
} else {
|
|
495
|
+
res.text(m.content, null, null, {
|
|
496
|
+
disableAutoTyping: true
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
}
|
|
493
501
|
}
|
|
494
502
|
|
|
495
503
|
res.text(text, sendReplies, voiceControl, {
|