Post-F: защитить VAT follow-up от stale period carryover

This commit is contained in:
2026-04-24 00:14:50 +03:00
parent da8b328d98
commit d7d6be18ff
2 changed files with 22 additions and 5 deletions
@@ -1,4 +1,4 @@
import type {
import type {
AddressFilterSet,
AddressIntent,
AddressIntentResolution,
@@ -21,6 +21,7 @@ import {
hasInventorySaleCue,
hasInventorySupplierCue
} from "../inventoryLifecycleCueHelpers";
import { repairAddressMojibakeText } from "../addressTextRepair";
import { normalizeOrganizationScopeSearchText, organizationsLikelySameEntity } from "../assistantOrganizationMatcher";
import { applyAddressLlmSemanticHintsToExtraction } from "./semanticHintOverlay";
import type { AddressLlmSemanticHints } from "../../types/addressQuery";
@@ -88,6 +89,12 @@ function toNonEmptyString(value: unknown): string | null {
return normalized.length > 0 ? normalized : null;
}
function textWithRepairedVariant(text: string): string {
const source = String(text ?? "");
const repaired = repairAddressMojibakeText(source);
return repaired && repaired !== source ? `${source} ${repaired}` : source;
}
function hasAllTimeHint(text: string): boolean {
const normalized = String(text ?? "");
return /(?:за\s+вс[её]\s+время|за\s+весь\s+период|за\s+весь\s+срок|за\s+всю\s+истори(?:ю|и)|за\s+любой\s+период|за\s+любой\s+срок|for\s+all\s+time|all\s+time|for\s+entire\s+period|entire\s+period|for\s+any\s+period|any\s+period|for\s+full\s+history|full\s+history)/iu.test(
@@ -117,7 +124,7 @@ function hasExplicitPeriodLiteral(text: string): boolean {
function hasExplicitCurrentDateHint(text: string): boolean {
return /(?:на\s+текущ(?:ую|ая|ий|ее|ей|ем|его)\s+дат(?:у|а|е|ой|ою)|на\s+сегодняшн(?:юю|ий|ей|ем|его)\s+дат(?:у|а|е|ой|ою)|на\s+сегодня|сегодня|на\s+текущ(?:ий|ую)\s+момент|today|as\s+of\s+today|current\s+date|as\s+of\s+current\s+date)/iu.test(
String(text ?? "")
textWithRepairedVariant(String(text ?? ""))
);
}
@@ -126,7 +133,9 @@ function hasOpenItemsHint(text: string): boolean {
}
function hasVatCue(text: string): boolean {
return /(?:^|[\s,.;:!?()\-])(?:ндс|vat)(?=$|[\s,.;:!?()\-])/iu.test(String(text ?? ""));
return /(?:^|[\s,.;:!?()\-])(?:ндс[а-яё]*|vat)(?=$|[\s,.;:!?()\-])/iu.test(
textWithRepairedVariant(String(text ?? ""))
);
}
function hasVatForecastCue(text: string): boolean {
@@ -1327,6 +1336,7 @@ function mergeFollowupFilters(
previousHasPeriod &&
hasFollowupSignal &&
!hasExplicitPeriodInMessage &&
!hasExplicitCurrentDateInMessage &&
!inventoryLifecycleHistoryIntent &&
!vatRelativeMonthFollowup &&
!shouldSuppressGenericPeriodCarryover