ЮИ - Перенести настройки ассистента в управление автопрогонами и убрать верхний режим Ассистент
This commit is contained in:
@@ -77,6 +77,24 @@ function hasSelectedObjectInventoryActionCue(text: string | null): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function hasShortInventoryPurchaseFollowupCue(text: string | null): boolean {
|
||||
return /(?:^|[\s,.;:!?])(а\s+)?(?:купили\s+у\s+кого|у\s+кого\s+купили|поставщик|продавец|seller)(?:[\s,.;:!?]|$)/iu.test(
|
||||
String(text ?? "")
|
||||
);
|
||||
}
|
||||
|
||||
function isInventorySelectedObjectOrRootIntent(intent: string | null): boolean {
|
||||
return (
|
||||
intent === "inventory_on_hand_as_of_date" ||
|
||||
intent === "inventory_purchase_provenance_for_item" ||
|
||||
intent === "inventory_purchase_documents_for_item" ||
|
||||
intent === "inventory_sale_trace_for_item" ||
|
||||
intent === "inventory_profitability_for_item" ||
|
||||
intent === "inventory_purchase_to_sale_chain" ||
|
||||
intent === "inventory_aging_by_purchase_date"
|
||||
);
|
||||
}
|
||||
|
||||
function isGenericCanonicalDriftIntent(intent: string | null): boolean {
|
||||
return (
|
||||
intent === "open_items_by_counterparty_or_contract" ||
|
||||
@@ -89,6 +107,33 @@ function isGenericCanonicalDriftIntent(intent: string | null): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function hasSameDateFollowupSignal(text: string | null): boolean {
|
||||
return /(?:эту\s+же\s+дат(?:у|е|ой)|ту\s+же\s+дат(?:у|е|ой)|same\s+date)/iu.test(String(text ?? ""));
|
||||
}
|
||||
|
||||
function hasExplicitCurrentDateSignal(text: string | null): boolean {
|
||||
return /(?:текущ(?:ую|ая|ий|ее|ей)\s+дат(?:у|а|е|ой)|сегодняшн(?:юю|ий|ей)\s+дат(?:у|а|е|ой)|today|current\s+date)/iu.test(
|
||||
String(text ?? "")
|
||||
);
|
||||
}
|
||||
|
||||
function hasInventoryTemporalRootFollowupCue(text: string | null): boolean {
|
||||
const value = String(text ?? "").trim().toLowerCase();
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
const tokenCount = value.split(/\s+/).filter(Boolean).length;
|
||||
const hasMonthYearCue =
|
||||
/(?:январ(?:ь|е)|феврал(?:ь|е)|март(?:е)?|апрел(?:ь|е)|ма(?:й|е)|июн(?:ь|е)|июл(?:ь|е)|август(?:е)?|сентябр(?:ь|е)|октябр(?:ь|е)|ноябр(?:ь|е)|декабр(?:ь|е))(?:\s+\d{4})?/iu.test(
|
||||
value
|
||||
) || /\b(?:19|20)\d{2}\b/u.test(value);
|
||||
if (tokenCount <= 3 && hasMonthYearCue) {
|
||||
return true;
|
||||
}
|
||||
const hasInventoryLexeme = /(?:остат|склад|товар|позици|номенклатур)/iu.test(value);
|
||||
return hasInventoryLexeme && (hasMonthYearCue || hasSameDateFollowupSignal(value));
|
||||
}
|
||||
|
||||
function shouldPreferRawFollowupMessage(
|
||||
userMessage: string,
|
||||
addressInputMessage: string,
|
||||
@@ -112,15 +157,39 @@ function shouldPreferRawFollowupMessage(
|
||||
: null;
|
||||
const mode = toNonEmptyString(predecomposeContract?.mode) ?? "unknown";
|
||||
const intent = toNonEmptyString(predecomposeContract?.intent) ?? "unknown";
|
||||
const followupContext =
|
||||
carryover.followupContext && typeof carryover.followupContext === "object"
|
||||
? (carryover.followupContext as Record<string, unknown>)
|
||||
: null;
|
||||
const previousIntent = toNonEmptyString(followupContext?.previous_intent);
|
||||
const rootIntent = toNonEmptyString(followupContext?.root_intent);
|
||||
const previousAnchorType = toNonEmptyString(followupContext?.previous_anchor_type);
|
||||
const hasInventoryItemCarryover =
|
||||
previousAnchorType === "item" && isInventorySelectedObjectOrRootIntent(previousIntent);
|
||||
const hasInventoryFrameCarryover =
|
||||
isInventorySelectedObjectOrRootIntent(previousIntent) ||
|
||||
isInventorySelectedObjectOrRootIntent(rootIntent);
|
||||
|
||||
if (mode === "unsupported" && intent === "unknown") {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasSameDateFollowupSignal(rawMessage) && hasExplicitCurrentDateSignal(canonicalMessage)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
hasInventoryFrameCarryover &&
|
||||
hasInventoryTemporalRootFollowupCue(rawMessage) &&
|
||||
(intent === "account_balance_snapshot" || intent === "documents_forming_balance" || intent === "unknown")
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (
|
||||
hasSelectedObjectInventorySignal(rawMessage) &&
|
||||
hasSelectedObjectInventoryActionCue(rawMessage) &&
|
||||
isGenericCanonicalDriftIntent(intent)
|
||||
(hasSelectedObjectInventorySignal(rawMessage) || hasInventoryItemCarryover) &&
|
||||
(hasSelectedObjectInventoryActionCue(rawMessage) || hasShortInventoryPurchaseFollowupCue(rawMessage)) &&
|
||||
(isGenericCanonicalDriftIntent(intent) || intent === "unknown")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user