wingbot 3.68.15 → 3.68.16
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
|
@@ -97,14 +97,20 @@ class CachedModel extends CustomEntityDetectionModel {
|
|
|
97
97
|
.filter((e) => this._entityDetectors.has(e.entity)
|
|
98
98
|
&& this._entityDetectors.get(e.entity).clearOverlaps);
|
|
99
99
|
|
|
100
|
+
if (this._options.verbose) this._log.log(`#NLP: ${text} [before]`, { before, intents, entities });
|
|
101
|
+
|
|
100
102
|
[intents, entities] = this._attachEntities(intents, entities, before, expectedEntities);
|
|
101
103
|
|
|
102
104
|
const after = local.entities
|
|
103
105
|
.filter((e) => !this._entityDetectors.has(e.entity)
|
|
104
106
|
|| !this._entityDetectors.get(e.entity).clearOverlaps);
|
|
105
107
|
|
|
108
|
+
if (this._options.verbose) this._log.log(`#NLP: ${text} [after]`, { after, intents, entities });
|
|
109
|
+
|
|
106
110
|
[intents, entities] = this._attachEntities(intents, entities, after);
|
|
107
111
|
|
|
112
|
+
if (this._options.verbose) this._log.log(`#NLP: ${text} [attached]`, { intents, entities, expectedEntities });
|
|
113
|
+
|
|
108
114
|
return {
|
|
109
115
|
text: local.text,
|
|
110
116
|
intents,
|
|
@@ -94,6 +94,7 @@ class CustomEntityDetectionModel {
|
|
|
94
94
|
/**
|
|
95
95
|
* @param {object} options
|
|
96
96
|
* @param {string} [options.prefix]
|
|
97
|
+
* @param {boolean} [options.verbose]
|
|
97
98
|
* @param {{ warn: Function, error: Function, log: Function }} [log]
|
|
98
99
|
*/
|
|
99
100
|
constructor (options, log = console) {
|
|
@@ -43,6 +43,7 @@ class WingbotModel extends CachedModel {
|
|
|
43
43
|
* @param {string} options.model
|
|
44
44
|
* @param {number} [options.cacheSize]
|
|
45
45
|
* @param {number} [options.matches]
|
|
46
|
+
* @param {boolean} [options.verbose]
|
|
46
47
|
* @param {Function} [options.fetch]
|
|
47
48
|
* @param {{ warn: Function, log: Function, error: Function }} [log]
|
|
48
49
|
*/
|
|
@@ -101,6 +102,8 @@ class WingbotModel extends CachedModel {
|
|
|
101
102
|
`matches=${encodeURIComponent(this._matches)}`
|
|
102
103
|
];
|
|
103
104
|
|
|
105
|
+
if (this._options.verbose) this._log.log(`#NLP: "${text}" [query]`, { matches: this._matches, localEntities: entities });
|
|
106
|
+
|
|
104
107
|
if (entities) {
|
|
105
108
|
const buf = await this._brotli(Buffer.from(JSON.stringify({ entities })));
|
|
106
109
|
qs.push(`meta=${encodeURIComponent(buf.toString('base64url'))}`);
|
|
@@ -120,6 +123,8 @@ class WingbotModel extends CachedModel {
|
|
|
120
123
|
|
|
121
124
|
const response = await res.json();
|
|
122
125
|
|
|
126
|
+
if (this._options.verbose) this._log.log(`#NLP: ${text} [response]`, { response });
|
|
127
|
+
|
|
123
128
|
if (res.status >= 300) {
|
|
124
129
|
this._log.warn(`AI query failed: ${response.message || res.statusText}`);
|
|
125
130
|
return { intents: [], entities: [] };
|