wingbot 3.76.10 → 3.76.12
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/LLMDispatcher.js +3 -1
- package/src/Responder.js +47 -21
- package/src/prompt.js +2 -0
- package/src/resolvers/message.js +4 -0
- package/src/utils/quickReplies.js +7 -6
- package/src/utils/stateData.js +12 -1
- package/.claude/settings.local.json +0 -11
package/package.json
CHANGED
package/src/LLMDispatcher.js
CHANGED
|
@@ -183,7 +183,9 @@ class LLMDispatcher {
|
|
|
183
183
|
|
|
184
184
|
let aiRes;
|
|
185
185
|
let llmRes;
|
|
186
|
-
|
|
186
|
+
|
|
187
|
+
// lets skip llm routing when user uploads an attachment
|
|
188
|
+
if ((!res || bounceAllow) && routing?.router && !this._req.isAttachment()) {
|
|
187
189
|
aiRes = await routing.router.resolve(this._llm, this._req, routing);
|
|
188
190
|
}
|
|
189
191
|
|
package/src/Responder.js
CHANGED
|
@@ -911,6 +911,52 @@ class Responder {
|
|
|
911
911
|
this.routePath = routePath;
|
|
912
912
|
}
|
|
913
913
|
|
|
914
|
+
/**
|
|
915
|
+
*
|
|
916
|
+
* @param {Object.<string,string|QuickReply>|QuickReply[]} [replies] - quick replies
|
|
917
|
+
* @param {object} [messageData]
|
|
918
|
+
* @returns {QuickReply[]}
|
|
919
|
+
*/
|
|
920
|
+
resolveQuickRepliesForAnswer (replies = null, messageData = null) {
|
|
921
|
+
if (!replies && this._quickReplyCollector.length === 0) {
|
|
922
|
+
return [];
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
const {
|
|
926
|
+
quickReplies: qrs, expectedKeywords, disambiguationIntents
|
|
927
|
+
} = makeQuickReplies(
|
|
928
|
+
replies,
|
|
929
|
+
this.path,
|
|
930
|
+
this._t,
|
|
931
|
+
this._quickReplyCollector,
|
|
932
|
+
Ai.ai,
|
|
933
|
+
this.currentAction()
|
|
934
|
+
);
|
|
935
|
+
|
|
936
|
+
if (!messageData) {
|
|
937
|
+
return qrs;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
if (disambiguationIntents.length > 0) {
|
|
941
|
+
this._senderMeta = {
|
|
942
|
+
flag: ResponseFlag.DISAMBIGUATION_OFFERED,
|
|
943
|
+
disambiguationIntents
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
if (qrs.length > 0) {
|
|
948
|
+
this.finalMessageSent = true;
|
|
949
|
+
Object.assign(messageData.message, {
|
|
950
|
+
quick_replies: qrs
|
|
951
|
+
});
|
|
952
|
+
|
|
953
|
+
this._addExpectedIntents(expectedKeywords);
|
|
954
|
+
this._quickReplyCollector = [];
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
return qrs;
|
|
958
|
+
}
|
|
959
|
+
|
|
914
960
|
/**
|
|
915
961
|
* @typedef {object} MessageOptions
|
|
916
962
|
* @prop {boolean} [disableAutoTyping]
|
|
@@ -953,27 +999,7 @@ class Responder {
|
|
|
953
999
|
|
|
954
1000
|
this._textResponses.push(text);
|
|
955
1001
|
|
|
956
|
-
|
|
957
|
-
const qrc = this._quickReplyCollector;
|
|
958
|
-
const {
|
|
959
|
-
quickReplies: qrs, expectedKeywords, disambiguationIntents
|
|
960
|
-
} = makeQuickReplies(replies, this.path, this._t, qrc, Ai.ai, this.currentAction());
|
|
961
|
-
|
|
962
|
-
if (disambiguationIntents.length > 0) {
|
|
963
|
-
this._senderMeta = {
|
|
964
|
-
flag: ResponseFlag.DISAMBIGUATION_OFFERED,
|
|
965
|
-
disambiguationIntents
|
|
966
|
-
};
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
if (qrs.length > 0) {
|
|
970
|
-
this.finalMessageSent = true;
|
|
971
|
-
messageData.message.quick_replies = qrs;
|
|
972
|
-
|
|
973
|
-
this._addExpectedIntents(expectedKeywords);
|
|
974
|
-
this._quickReplyCollector = [];
|
|
975
|
-
}
|
|
976
|
-
}
|
|
1002
|
+
this.resolveQuickRepliesForAnswer(replies, messageData);
|
|
977
1003
|
|
|
978
1004
|
if (this._features.includes(FEATURE_VOICE)
|
|
979
1005
|
&& (voice || this.voiceControl)) {
|
package/src/prompt.js
CHANGED
|
@@ -93,7 +93,9 @@ function prompt (strings, ...args) {
|
|
|
93
93
|
|
|
94
94
|
const renderer = async (req, res = null) => {
|
|
95
95
|
const reqIsRequest = 'action' in req && typeof req.action === 'function';
|
|
96
|
+
const reqIsResponder = typeof req?.send === 'function';
|
|
96
97
|
const data = {
|
|
98
|
+
...(reqIsResponder ? stateData(null, req) : {}),
|
|
97
99
|
...(reqIsRequest ? stateData(req, res) : req),
|
|
98
100
|
...inputData
|
|
99
101
|
};
|
package/src/resolvers/message.js
CHANGED
|
@@ -122,14 +122,15 @@ function makeQuickReplies (replies, path = '', translate = (w) => w, quickReplyC
|
|
|
122
122
|
|
|
123
123
|
let unshift = 0;
|
|
124
124
|
quickReplyCollector.forEach((reply) => {
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
const clear = { ...reply };
|
|
126
|
+
if (clear._justToExisting) {
|
|
127
|
+
delete clear._justToExisting;
|
|
127
128
|
}
|
|
128
|
-
if (
|
|
129
|
-
delete
|
|
130
|
-
iterate.splice(unshift++, 0,
|
|
129
|
+
if (clear._prepend) {
|
|
130
|
+
delete clear._prepend;
|
|
131
|
+
iterate.splice(unshift++, 0, clear);
|
|
131
132
|
} else {
|
|
132
|
-
iterate.push(
|
|
133
|
+
iterate.push(clear);
|
|
133
134
|
}
|
|
134
135
|
});
|
|
135
136
|
|
package/src/utils/stateData.js
CHANGED
|
@@ -56,6 +56,16 @@ module.exports = function stateData (
|
|
|
56
56
|
state: res.options.state
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
let $qrTexts;
|
|
60
|
+
|
|
61
|
+
if (typeof res?.resolveQuickRepliesForAnswer === 'function') {
|
|
62
|
+
$qrTexts = res?.resolveQuickRepliesForAnswer(res.data._qRepliesToSend || [])
|
|
63
|
+
.filter((r) => r.title)
|
|
64
|
+
.map((r) => r.title);
|
|
65
|
+
} else {
|
|
66
|
+
$qrTexts = [];
|
|
67
|
+
}
|
|
68
|
+
|
|
59
69
|
return {
|
|
60
70
|
senderId,
|
|
61
71
|
pageId,
|
|
@@ -73,6 +83,7 @@ module.exports = function stateData (
|
|
|
73
83
|
// yes - res because of circular dependency
|
|
74
84
|
...(res && req && req.actionData()),
|
|
75
85
|
...(res ? res.data : {}),
|
|
76
|
-
$input: $this
|
|
86
|
+
$input: $this,
|
|
87
|
+
$qrTexts
|
|
77
88
|
};
|
|
78
89
|
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"permissions": {
|
|
3
|
-
"allow": [
|
|
4
|
-
"Bash(npx mocha:*)",
|
|
5
|
-
"Bash(npx tsc *)",
|
|
6
|
-
"Bash(npm test *)",
|
|
7
|
-
"Bash(node -e \"const p = require\\('./bot/plugins/BTMLLM'\\); console.log\\('factory type:', typeof p\\); console.log\\('factory name:', p.name\\);\")",
|
|
8
|
-
"Bash(grep -n \"prompt\\\\`\\\\|tagged\\\\|render\\\\|compile\\\\|hbs\" /Users/ondrejveres/Wingbot/wingbot-llm/src/prompt.js)"
|
|
9
|
-
]
|
|
10
|
-
}
|
|
11
|
-
}
|