@resolveio/server-lib 22.3.209 → 22.3.210
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/methods/ai-terminal.js
CHANGED
|
@@ -7545,6 +7545,17 @@ function scoreAssistantLikelyFilterCandidate(message, intent, likelyFilterText,
|
|
|
7545
7545
|
score += 6;
|
|
7546
7546
|
}
|
|
7547
7547
|
}
|
|
7548
|
+
if (__spreadArray([], __read(candidateTerms), false).some(function (term) { return ['division', 'divisions'].includes(term); })) {
|
|
7549
|
+
if (/\bdivisions?\b/i.test(messageText)) {
|
|
7550
|
+
score += 8;
|
|
7551
|
+
}
|
|
7552
|
+
if (new RegExp("\\b".concat(escapeRegexValue(likelyFilterText), "\\b"), 'i').test(messageText)) {
|
|
7553
|
+
score += 3;
|
|
7554
|
+
}
|
|
7555
|
+
if (/\b[a-z0-9&.' -]+\s+divisions?\b/i.test(likelyFilterText)) {
|
|
7556
|
+
score += 8;
|
|
7557
|
+
}
|
|
7558
|
+
}
|
|
7548
7559
|
if (__spreadArray([], __read(candidateTerms), false).some(function (term) { return ['location', 'locations', 'yard', 'yards', 'warehouse', 'warehouses'].includes(term); })) {
|
|
7549
7560
|
if (/\b(location|locations|yard|yards|warehouse|warehouses|site|sites)\b/i.test(messageText)) {
|
|
7550
7561
|
score += 4;
|
|
@@ -10162,6 +10173,27 @@ function buildAssistantFieldFilterCondition(value, operator, type) {
|
|
|
10162
10173
|
}
|
|
10163
10174
|
return { $regex: escaped, $options: 'i' };
|
|
10164
10175
|
}
|
|
10176
|
+
function normalizeAssistantFieldAwareFilterValue(value, candidate) {
|
|
10177
|
+
if (candidate.type && candidate.type !== 'string') {
|
|
10178
|
+
return value;
|
|
10179
|
+
}
|
|
10180
|
+
var candidateTerms = __spreadArray(__spreadArray([
|
|
10181
|
+
candidate.id
|
|
10182
|
+
], __read((candidate.terms || [])), false), __read((candidate.fields || [])), false).map(function (term) { return cleanAssistantRequestedDimensionText(term); })
|
|
10183
|
+
.filter(Boolean);
|
|
10184
|
+
var isDivisionCandidate = candidateTerms.some(function (term) { return term === 'division' || term === 'divisions' || term.endsWith(' division'); });
|
|
10185
|
+
if (!isDivisionCandidate) {
|
|
10186
|
+
return value;
|
|
10187
|
+
}
|
|
10188
|
+
var text = normalizeOptionalString(value);
|
|
10189
|
+
if (!text) {
|
|
10190
|
+
return value;
|
|
10191
|
+
}
|
|
10192
|
+
var normalized = normalizeOptionalString(text
|
|
10193
|
+
.replace(/\bdivision(?:s)?\b/gi, ' ')
|
|
10194
|
+
.replace(/\s+/g, ' '));
|
|
10195
|
+
return normalized || value;
|
|
10196
|
+
}
|
|
10165
10197
|
function buildAssistantContractFilterClause(spec, candidate, options) {
|
|
10166
10198
|
var operator = normalizeAssistantContractFilterOperator(spec.operator);
|
|
10167
10199
|
if (candidate.type === 'number' && spec.values.length === 1) {
|
|
@@ -10196,7 +10228,8 @@ function buildAssistantContractFilterClause(spec, candidate, options) {
|
|
|
10196
10228
|
fields.forEach(function (field) {
|
|
10197
10229
|
spec.values.forEach(function (value) {
|
|
10198
10230
|
var _a;
|
|
10199
|
-
var
|
|
10231
|
+
var normalizedValue = normalizeAssistantFieldAwareFilterValue(value, candidate);
|
|
10232
|
+
var condition = buildAssistantFieldFilterCondition(normalizedValue, operator === 'in' ? 'eq' : operator, candidate.type);
|
|
10200
10233
|
if (condition !== undefined) {
|
|
10201
10234
|
clauses.push((_a = {}, _a[field] = condition, _a));
|
|
10202
10235
|
}
|