Post-F: укрепить VAT, даты остатков и SVK follow-up
This commit is contained in:
@@ -81,6 +81,15 @@ const COUNTERPARTY_TOKEN_NOISE = new Set([
|
||||
"показать",
|
||||
"скажи",
|
||||
"выведи",
|
||||
"видно",
|
||||
"документам",
|
||||
"документами",
|
||||
"движение",
|
||||
"движения",
|
||||
"движениям",
|
||||
"операциям",
|
||||
"проверить",
|
||||
"проверь",
|
||||
"show",
|
||||
"list",
|
||||
"контра",
|
||||
@@ -108,7 +117,10 @@ function isCounterpartyFillerToken(token: string): boolean {
|
||||
if (/^(?:бл[яе]|блять|нах|нахуй|епт|ёпт|епта)$/iu.test(normalized)) {
|
||||
return true;
|
||||
}
|
||||
if (/^(?:док(?:и|ам|ами|умент(?:ы|ов)?)?|docs?|docy|doci|doki|dokument(?:y|ov|am|a)?)$/iu.test(normalized)) {
|
||||
if (/^(?:док(?:и|ам|ами|умент(?:ы|ов|ам|ами)?)?|docs?|docy|doci|doki|dokument(?:y|ov|am|a)?)$/iu.test(normalized)) {
|
||||
return true;
|
||||
}
|
||||
if (/^(?:движени[еяям]*|операци[яиюеям]*|проверить|проверь|видно)$/iu.test(normalized)) {
|
||||
return true;
|
||||
}
|
||||
if (/^(?:pokazh?|pokazhi|pokaji|pokezh|kakie|kakoi|kakaya|est|za|po|na|s|vse|all|poka)$/iu.test(normalized)) {
|
||||
|
||||
@@ -2147,8 +2147,26 @@ function hasBidirectionalValueFlowComparisonSignal(text: string): boolean {
|
||||
/(?:\u0434\u0435\u043d\u044c\u0433|\u0434\u0435\u043d\u0435\u0433|\u0434\u0435\u043d\u0435\u0436|\u043f\u043e\u0442\u043e\u043a|\u043e\u0431\u043e\u0440\u043e\u0442|money|cash|flow)/iu.test(
|
||||
normalized
|
||||
);
|
||||
const hasNetAmountCue = /(?:сколько|сумм|итог|нетто|сальдо|минус|net|total|sum)/iu.test(normalized);
|
||||
|
||||
return hasIncomingCue && hasOutgoingCue && hasComparisonCue && hasValueFlowCue;
|
||||
return hasIncomingCue && hasOutgoingCue && hasComparisonCue && (hasValueFlowCue || hasNetAmountCue);
|
||||
}
|
||||
|
||||
function hasVatPeriodInspectionBridgeSignal(text: string): boolean {
|
||||
const normalized = String(text ?? "").trim().toLowerCase();
|
||||
if (!/(?:ндс|vat)/iu.test(normalized)) {
|
||||
return false;
|
||||
}
|
||||
const hasPeriodCue =
|
||||
/(?:\b(?:19|20)\d{2}\b|за\s+(?:\d{4}|год|период|квартал|месяц|январ|феврал|март|апрел|ма[йя]|июн|июл|август|сентябр|октябр|ноябр|декабр)|\b[1-4]\s*(?:кв|квартал))/iu.test(
|
||||
normalized
|
||||
);
|
||||
const hasInspectionCue =
|
||||
/(?:что\s+с|позици|основан|не\s+хватает|налогов[а-яё]*\s+вывод|вывод|декларац|книга\s+(?:продаж|покупок)|расшифр|разбор)/iu.test(
|
||||
normalized
|
||||
);
|
||||
const forecastOnlyCue = /(?:прогноз|план|примерн|ориентировочн)/iu.test(normalized) && !hasInspectionCue;
|
||||
return hasPeriodCue && hasInspectionCue && !forecastOnlyCue;
|
||||
}
|
||||
|
||||
function resolveUnicodeAddressIntentBridge(text: string): AddressIntentResolution | null {
|
||||
@@ -2381,6 +2399,14 @@ function resolveUnicodeAddressIntentBridge(text: string): AddressIntentResolutio
|
||||
);
|
||||
}
|
||||
|
||||
if (hasVatPeriodInspectionBridgeSignal(normalized)) {
|
||||
return unicodeBridgeResolution(
|
||||
"vat_liability_confirmed_for_tax_period",
|
||||
"high",
|
||||
"vat_period_inspection_bridge_signal_detected"
|
||||
);
|
||||
}
|
||||
|
||||
const inventoryBridgeIntent = resolveInventoryAddressIntent(normalized);
|
||||
if (inventoryBridgeIntent) {
|
||||
if (inventoryBridgeIntent.intent === "inventory_aging_by_purchase_date") {
|
||||
|
||||
@@ -283,7 +283,15 @@ const FOLLOWUP_LOW_QUALITY_COUNTERPARTY_TOKENS = new Set([
|
||||
"сводную",
|
||||
"сводном",
|
||||
"сводного",
|
||||
"сводному"
|
||||
"сводному",
|
||||
"видно",
|
||||
"документам",
|
||||
"документами",
|
||||
"движение",
|
||||
"движения",
|
||||
"движениям",
|
||||
"проверить",
|
||||
"проверь"
|
||||
]);
|
||||
|
||||
const FOLLOWUP_LOW_QUALITY_CONTRACT_TOKENS = new Set([
|
||||
@@ -858,6 +866,11 @@ function mergeFollowupFilters(
|
||||
const hasFollowupSignal = hasAddressFollowupContextSignal(userMessage);
|
||||
const hasExplicitPeriodInMessage = hasExplicitPeriodLiteral(userMessage);
|
||||
const hasExplicitCurrentDateInMessage = hasExplicitCurrentDateHint(userMessage);
|
||||
const currentHasExplicitTemporalScope =
|
||||
hasExplicitPeriodWindow(merged) ||
|
||||
Boolean(toNonEmptyString(merged.as_of_date)) ||
|
||||
hasExplicitPeriodInMessage ||
|
||||
hasExplicitCurrentDateInMessage;
|
||||
const explicitQuotedItem = extractSelectedObjectItemFromFollowupText(userMessage);
|
||||
if (!toNonEmptyString(merged.organization) && previousOrganization) {
|
||||
merged.organization = previousOrganization;
|
||||
@@ -1196,6 +1209,7 @@ function mergeFollowupFilters(
|
||||
if (
|
||||
!sameDateRequested &&
|
||||
(intent === "inventory_on_hand_as_of_date" || intent === "inventory_supplier_stock_overlap_as_of_date") &&
|
||||
!currentHasExplicitTemporalScope &&
|
||||
hasOpenItemsHint(userMessage)
|
||||
) {
|
||||
const inheritedAsOfDate = previousAsOfDate ?? previousPeriodTo ?? previousPeriodFrom;
|
||||
|
||||
@@ -169,7 +169,28 @@ function isGarbageSemanticAnchorCandidate(value: string | null): boolean {
|
||||
"прокси",
|
||||
"proxy",
|
||||
"summary",
|
||||
"overall"
|
||||
"overall",
|
||||
"деньги",
|
||||
"денег",
|
||||
"деньгам",
|
||||
"деньгами",
|
||||
"ооо",
|
||||
"ип",
|
||||
"ао",
|
||||
"пао",
|
||||
"зао",
|
||||
"llc",
|
||||
"inc",
|
||||
"corp",
|
||||
"документам",
|
||||
"документами",
|
||||
"движение",
|
||||
"движения",
|
||||
"движениям",
|
||||
"операциям",
|
||||
"проверить",
|
||||
"проверь",
|
||||
"видно"
|
||||
]).has(compact)
|
||||
) {
|
||||
return true;
|
||||
@@ -1099,6 +1120,21 @@ function rawEntityResolutionCandidate(text: string): string | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
function rawScopedEntityCandidateFromText(text: string): string | null {
|
||||
const source = repairAddressMojibakeText(String(text ?? ""));
|
||||
const patterns = [
|
||||
/(?:^|[\s,.;:!?])(?:по|у|для|for|by)\s+([\p{L}\d._-]{2,})(?=$|[\s,.;:!?])/iu,
|
||||
/(?:документ(?:ам|ы)?|движени(?:ям|я)?|операци(?:ям|и)?|плат[её]ж(?:ам|и)?)\s+([\p{L}\d._-]{2,})(?=$|[\s,.;:!?])/iu
|
||||
];
|
||||
for (const pattern of patterns) {
|
||||
const candidate = normalizeEntityResolutionCandidate(source.match(pattern)?.[1] ?? "");
|
||||
if (candidate.length >= 2 && !isInvalidEntityCandidate(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function resolveEntityResolutionAmbiguityChoice(text: string, candidates: string[]): string | null {
|
||||
const normalizedText = canonicalizeEntityResolutionCandidate(text);
|
||||
if (!normalizedText || candidates.length <= 0) {
|
||||
@@ -1419,6 +1455,12 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
const rawMetadataScopeHint = rawMetadataSignal ? metadataScopeHintFromRawText(rawText) : null;
|
||||
const rawTopicSwitchSignal = hasExplicitTopicSwitchSignal(rawText);
|
||||
const rawEntityCandidate = rawEntityResolutionSignal ? rawEntityResolutionCandidate(rawEntitySourceText) : null;
|
||||
const rawScopedEntityCandidate =
|
||||
!predecomposeEntities.counterparty &&
|
||||
!predecomposeEntities.organization &&
|
||||
(rawValueFlowSignal || rawLifecycleSignal || rawMetadataSignal || rawBusinessOverviewSignal)
|
||||
? rawScopedEntityCandidateFromText(rawEntitySourceText)
|
||||
: null;
|
||||
const entityResolutionClarificationCandidate =
|
||||
followupSeed.pilotScope === "entity_resolution_search_v1" &&
|
||||
followupSeed.entityResolutionStatus === "ambiguous"
|
||||
@@ -1870,8 +1912,9 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
!metadataGroundedMovementLaneApplicable
|
||||
});
|
||||
const explicitCurrentCounterpartyCandidate =
|
||||
normalizedPredecomposeCounterparty && !isReferentialEntityPlaceholder(normalizedPredecomposeCounterparty)
|
||||
? normalizedPredecomposeCounterparty
|
||||
(normalizedPredecomposeCounterparty ?? rawScopedEntityCandidate) &&
|
||||
!isReferentialEntityPlaceholder(normalizedPredecomposeCounterparty ?? rawScopedEntityCandidate ?? "")
|
||||
? normalizedPredecomposeCounterparty ?? rawScopedEntityCandidate
|
||||
: null;
|
||||
const explicitCurrentCounterpartyOverridesFollowupEntity = Boolean(
|
||||
explicitCurrentCounterpartyCandidate &&
|
||||
@@ -1929,6 +1972,7 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
pushScopedEntityCandidate(entityCandidates, candidate, groundedFollowupEntity);
|
||||
}
|
||||
pushScopedEntityCandidate(entityCandidates, normalizedPredecomposeCounterparty, groundedFollowupEntity);
|
||||
pushScopedEntityCandidate(entityCandidates, rawScopedEntityCandidate, groundedFollowupEntity);
|
||||
if (!groundedFollowupEntity) {
|
||||
if (!rawMetadataScopeOverridesFollowupEntity) {
|
||||
pushScopedEntityCandidate(entityCandidates, effectiveFollowupCounterparty, null);
|
||||
@@ -1950,7 +1994,7 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
pushUnique(entityCandidates, rawMetadataScopeHint);
|
||||
}
|
||||
const openScopeValueFlowWithoutCounterparty =
|
||||
valueFlowSignal && !normalizedPredecomposeCounterparty && !effectiveFollowupCounterparty;
|
||||
valueFlowSignal && !explicitCurrentCounterpartyCandidate && !effectiveFollowupCounterparty;
|
||||
const valueFlowOrganizationStaysScope =
|
||||
openScopeValueFlowWithoutCounterparty &&
|
||||
Boolean(
|
||||
@@ -1962,7 +2006,7 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
followupSeed.organization
|
||||
);
|
||||
const openScopeValueFlowWithoutResolvedCounterparty = Boolean(
|
||||
valueFlowSignal && !normalizedPredecomposeCounterparty && !effectiveFollowupCounterparty
|
||||
valueFlowSignal && !explicitCurrentCounterpartyCandidate && !effectiveFollowupCounterparty
|
||||
);
|
||||
if (openScopeValueFlowWithoutCounterparty && !valueFlowOrganizationStaysScope) {
|
||||
pushUnique(entityCandidates, predecomposeEntities.organization);
|
||||
@@ -2409,6 +2453,9 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
) {
|
||||
pushReason(reasonCodes, "mcp_discovery_counterparty_from_predecompose");
|
||||
}
|
||||
if (rawScopedEntityCandidate && !normalizedPredecomposeCounterparty) {
|
||||
pushReason(reasonCodes, "mcp_discovery_counterparty_from_raw_scope");
|
||||
}
|
||||
if (
|
||||
effectiveFollowupCounterparty &&
|
||||
!rawEntitySearchOverridesStaleScope &&
|
||||
|
||||
@@ -1383,13 +1383,22 @@ const ADDRESS_PREDECOMPOSE_NOISE_TOKENS = new Set([
|
||||
"dokumenty",
|
||||
"документ",
|
||||
"документы",
|
||||
"документам",
|
||||
"документами",
|
||||
"документов",
|
||||
"банк",
|
||||
"банковские",
|
||||
"операции",
|
||||
"операциям",
|
||||
"движение",
|
||||
"движения",
|
||||
"движениям",
|
||||
"платеж",
|
||||
"платёж",
|
||||
"платежи",
|
||||
"проверить",
|
||||
"проверь",
|
||||
"видно",
|
||||
"контрагент",
|
||||
"контрагенту",
|
||||
"контрагента",
|
||||
@@ -2571,10 +2580,10 @@ function hasAddressFollowupContextSignal(userMessage) {
|
||||
if (ultraShortFollowup && hasAny(/^(?:давай|показывай|показывыай|ещ[её]|also|again|go|ok|okay)(?=$|[\s,.;:!?])/iu)) {
|
||||
return true;
|
||||
}
|
||||
const shortValueFlowRetargetCue = shortFollowup &&
|
||||
const valueFlowRetargetFollowup = minTokens <= 14 &&
|
||||
(hasMarker() || hasPointer() || hasAny(/^(?:Р°|a|Рё|i|also|then|now)(?=$|[\s,.;:!?])/iu)) &&
|
||||
hasAny(/(?:нетто|сальдо|разниц|получил|заплатил|поступ|входящ|исходящ|оборот|выручк|денеж)/iu);
|
||||
if (shortValueFlowRetargetCue) {
|
||||
hasAny(/(?:нетто|сальдо|разниц|получил|заплатил|поступ|входящ|исходящ|оборот|выручк|денеж|нетто|сальдо|разниц|получил|заплатил|поступ|РІС…РѕРґСЏС‰|РёСЃС…РѕРґСЏС‰|РѕР±РѕСЂРѕС‚|выручк|денеж)/iu);
|
||||
if (valueFlowRetargetFollowup) {
|
||||
return true;
|
||||
}
|
||||
if (hasStandaloneAddressTopicSignal(rawText || repairedText)) {
|
||||
|
||||
Reference in New Issue
Block a user