ЮИ - Перенести настройки ассистента в управление автопрогонами и убрать верхний режим Ассистент
This commit is contained in:
@@ -52,6 +52,7 @@ export interface AddressFollowupContext {
|
||||
| "unknown"
|
||||
| null;
|
||||
root_anchor_value?: string | null;
|
||||
root_context_only?: boolean;
|
||||
current_frame_kind?: "generic" | "inventory_root" | "inventory_drilldown";
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ function hasAllTimeHint(text: string): boolean {
|
||||
}
|
||||
|
||||
function hasSameDateHint(text: string): boolean {
|
||||
return /(?:на\s+ту\s+же\s+дат[ауеы]|на\s+эту\s+же\s+дат[ауеы]|на\s+эту\s+дат[ауеы]|эту\s+дат[ауеы]|та\s+же\s+дата|same\s+date|as\s+of\s+same\s+date|the\s+same\s+date)/iu.test(
|
||||
return /(?:на\s+ту\s+же\s+дат[ауеы]|на\s+эту\s+же\s+дат[ауеы]|на\s+эту\s+дат[ауеы]|эту\s+дат[ауеы]|та\s+же\s+дата|дат[ауеы],?\s+котор(?:ую|ая)\s+(?:до\s+этого|раньше|ранее)\s+(?:рассматривали|смотрели)|дат[ауеы],?\s+которая\s+был[ао]?\s+ранее\s+рассмотрен[ао]?|same\s+date|as\s+of\s+same\s+date|the\s+same\s+date|date\s+we\s+looked\s+at\s+before|previously\s+considered\s+date)/iu.test(
|
||||
String(text ?? "")
|
||||
);
|
||||
}
|
||||
@@ -487,6 +488,41 @@ function resolveRelativeMonthPeriodFromInventoryRoot(
|
||||
};
|
||||
}
|
||||
|
||||
function resolveRelativeMonthPeriodFromFollowupYear(
|
||||
userMessage: string,
|
||||
followupContext: AddressFollowupContext | null
|
||||
): { period_from: string; period_to: string; as_of_date: string } | null {
|
||||
if (!followupContext) {
|
||||
return null;
|
||||
}
|
||||
const month = resolveMonthNumberFromText(userMessage);
|
||||
if (!month) {
|
||||
return null;
|
||||
}
|
||||
const normalized = String(userMessage ?? "");
|
||||
if (hasExplicitPeriodLiteral(normalized) || hasExplicitCurrentDateHint(normalized) || hasSameDateHint(normalized)) {
|
||||
return null;
|
||||
}
|
||||
const shortTemporalPatch = getTokenCount(normalized) <= 8 || hasRelativeYearHint(normalized);
|
||||
if (!shortTemporalPatch) {
|
||||
return null;
|
||||
}
|
||||
const year =
|
||||
resolveYearFromFilters(followupContext.previous_filters) ??
|
||||
resolveYearFromFilters(followupContext.root_filters);
|
||||
if (!year) {
|
||||
return null;
|
||||
}
|
||||
const lastDay = new Date(Date.UTC(year, month, 0)).getUTCDate();
|
||||
const periodFrom = `${year}-${String(month).padStart(2, "0")}-01`;
|
||||
const periodTo = `${year}-${String(month).padStart(2, "0")}-${String(lastDay).padStart(2, "0")}`;
|
||||
return {
|
||||
period_from: periodFrom,
|
||||
period_to: periodTo,
|
||||
as_of_date: periodTo
|
||||
};
|
||||
}
|
||||
|
||||
function shouldRestoreInventoryRootFrame(
|
||||
userMessage: string,
|
||||
intent: AddressIntent,
|
||||
@@ -498,6 +534,7 @@ function shouldRestoreInventoryRootFrame(
|
||||
}
|
||||
const currentFrameKind = followupContext.current_frame_kind ?? null;
|
||||
const previousIntent = followupContext.previous_intent;
|
||||
const rootContextOnly = followupContext.root_context_only === true;
|
||||
const comingFromInventoryDrilldown =
|
||||
currentFrameKind === "inventory_drilldown" || isInventoryDrilldownFrameIntent(previousIntent);
|
||||
const normalized = String(userMessage ?? "");
|
||||
@@ -508,6 +545,7 @@ function shouldRestoreInventoryRootFrame(
|
||||
);
|
||||
const canReenterInventoryRoot =
|
||||
comingFromInventoryDrilldown ||
|
||||
rootContextOnly ||
|
||||
(currentFrameKind === "inventory_root" && hasSamePeriodHint(normalized)) ||
|
||||
(currentFrameKind === "generic" && hasInventoryRootRestatementCue && hasSamePeriodHint(normalized));
|
||||
if (!canReenterInventoryRoot) {
|
||||
@@ -517,7 +555,7 @@ function shouldRestoreInventoryRootFrame(
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
hasSelectedObjectInventorySignal(normalized) ||
|
||||
(hasSelectedObjectInventorySignal(normalized) && !hasInventoryRootRestatementCue) ||
|
||||
hasInventorySupplierFollowupCue(normalized) ||
|
||||
hasInventoryPurchaseDocumentsFollowupCue(normalized) ||
|
||||
hasInventoryPurchaseDateFollowupCue(normalized) ||
|
||||
@@ -533,6 +571,7 @@ function shouldRestoreInventoryRootFrame(
|
||||
const hasTemporalPatch =
|
||||
hasExplicitPeriodWindow(extractedFilters) ||
|
||||
Boolean(toNonEmptyString(extractedFilters.as_of_date)) ||
|
||||
hasSameDateHint(normalized) ||
|
||||
hasSamePeriodHint(normalized) ||
|
||||
hasExplicitPeriodLiteral(normalized) ||
|
||||
Boolean(resolveRelativeMonthPeriodFromInventoryRoot(normalized, followupContext));
|
||||
@@ -709,9 +748,11 @@ function mergeFollowupFilters(
|
||||
const previousPeriodFrom = toNonEmptyString(previous.period_from);
|
||||
const previousPeriodTo = toNonEmptyString(previous.period_to);
|
||||
const relativeMonthFromInventoryRoot = resolveRelativeMonthPeriodFromInventoryRoot(userMessage, followupContext);
|
||||
const relativeMonthFromFollowupYear = resolveRelativeMonthPeriodFromFollowupYear(userMessage, followupContext);
|
||||
const allTimeRequested = hasAllTimeHint(userMessage);
|
||||
const sameDateRequested = hasSameDateHint(userMessage);
|
||||
const samePeriodRequested = hasSamePeriodHint(userMessage);
|
||||
const explicitQuotedItem = extractSelectedObjectItemFromFollowupText(userMessage);
|
||||
if (!toNonEmptyString(merged.organization) && previousOrganization) {
|
||||
merged.organization = previousOrganization;
|
||||
reasons.push("organization_from_followup_context");
|
||||
@@ -837,6 +878,17 @@ function mergeFollowupFilters(
|
||||
merged.counterparty = inheritedCounterparty;
|
||||
reasons.push(currentCounterparty ? "counterparty_replaced_from_followup_context" : "counterparty_from_followup_context");
|
||||
}
|
||||
if (intent === "inventory_on_hand_as_of_date" && explicitQuotedItem) {
|
||||
const currentItem = toNonEmptyString(merged.item);
|
||||
if (
|
||||
!currentItem ||
|
||||
currentItem !== explicitQuotedItem ||
|
||||
isInventoryItemAnchorDegradation(explicitQuotedItem, currentItem)
|
||||
) {
|
||||
merged.item = explicitQuotedItem;
|
||||
reasons.push(currentItem ? "item_replaced_from_explicit_quote" : "item_from_explicit_quote");
|
||||
}
|
||||
}
|
||||
if (
|
||||
(intent === "inventory_purchase_provenance_for_item" ||
|
||||
intent === "inventory_purchase_documents_for_item" ||
|
||||
@@ -846,7 +898,6 @@ function mergeFollowupFilters(
|
||||
intent === "inventory_aging_by_purchase_date")
|
||||
) {
|
||||
const inheritedItem = previousItem ?? previousAnchorItem;
|
||||
const explicitQuotedItem = extractSelectedObjectItemFromFollowupText(userMessage);
|
||||
const currentItem = toNonEmptyString(merged.item);
|
||||
const shouldAdoptExplicitQuotedItem =
|
||||
Boolean(explicitQuotedItem) &&
|
||||
@@ -983,6 +1034,7 @@ function mergeFollowupFilters(
|
||||
if (
|
||||
!sameDateRequested &&
|
||||
hasFollowupSignalForConfirmed &&
|
||||
!isInventoryLifecycleHistoryIntent(intent) &&
|
||||
!hasExplicitPeriodLiteral(userMessage) &&
|
||||
!hasExplicitCurrentDateHint(userMessage)
|
||||
) {
|
||||
@@ -1040,12 +1092,29 @@ function mergeFollowupFilters(
|
||||
intent === "vat_payable_confirmed_as_of_date";
|
||||
const currentHasPeriod = hasExplicitPeriodWindow(merged);
|
||||
const previousHasPeriod = hasExplicitPeriodWindow(previous);
|
||||
const vatRelativeMonthFollowup =
|
||||
relativeMonthFromFollowupYear &&
|
||||
(intent === "vat_payable_confirmed_as_of_date" ||
|
||||
intent === "vat_payable_forecast" ||
|
||||
intent === "vat_liability_confirmed_for_tax_period");
|
||||
|
||||
if (vatRelativeMonthFollowup) {
|
||||
merged.period_from = relativeMonthFromFollowupYear.period_from;
|
||||
merged.period_to = relativeMonthFromFollowupYear.period_to;
|
||||
if (intent === "vat_payable_confirmed_as_of_date") {
|
||||
merged.as_of_date = relativeMonthFromFollowupYear.as_of_date;
|
||||
} else if (toNonEmptyString(merged.as_of_date)) {
|
||||
delete merged.as_of_date;
|
||||
}
|
||||
reasons.push("period_derived_from_followup_context_year");
|
||||
}
|
||||
|
||||
if (
|
||||
(intent === "vat_payable_forecast" || intent === "vat_liability_confirmed_for_tax_period") &&
|
||||
previousHasPeriod &&
|
||||
hasFollowupSignal &&
|
||||
!hasExplicitPeriodInMessage
|
||||
!hasExplicitPeriodInMessage &&
|
||||
!vatRelativeMonthFollowup
|
||||
) {
|
||||
const currentPeriodFrom = toNonEmptyString(merged.period_from);
|
||||
const currentPeriodTo = toNonEmptyString(merged.period_to);
|
||||
@@ -1067,7 +1136,8 @@ function mergeFollowupFilters(
|
||||
previousHasPeriod &&
|
||||
hasFollowupSignal &&
|
||||
!hasExplicitPeriodInMessage &&
|
||||
!inventoryLifecycleHistoryIntent
|
||||
!inventoryLifecycleHistoryIntent &&
|
||||
!vatRelativeMonthFollowup
|
||||
) {
|
||||
if (previousPeriodFrom) {
|
||||
merged.period_from = previousPeriodFrom;
|
||||
|
||||
Reference in New Issue
Block a user