АРЧ АП11 - Commit title: Добавить контрактный слой переходов и capability-деклараций ассистента
This commit is contained in:
@@ -533,6 +533,30 @@ function hasSelectedObjectInventorySignal(text: string): boolean {
|
||||
return /(?:по\s+выбранному\s+объекту|for\s+selected\s+object)/iu.test(String(text ?? ""));
|
||||
}
|
||||
|
||||
function hasSelectedObjectInlineSnapshotMetadata(text: string): boolean {
|
||||
return /(?:дата\s+строки|строка\s+от|количество\s*:|стоимость\s*:|склад\s*:|организация\s*:|\|\s*(?:склад|количество|стоимость|организация|дата\s+строки)\s*:)/iu.test(
|
||||
String(text ?? "")
|
||||
);
|
||||
}
|
||||
|
||||
function extractSelectedObjectItemFromFollowupText(text: string): string | null {
|
||||
const rawSelectedObject = toNonEmptyString(extractSelectedObjectQuotedValue(text));
|
||||
if (!rawSelectedObject) {
|
||||
return null;
|
||||
}
|
||||
const firstLine = rawSelectedObject
|
||||
.replace(/\r\n?/g, "\n")
|
||||
.split("\n")
|
||||
.map((line) => line.trim())
|
||||
.find(Boolean);
|
||||
const primarySegment = String(firstLine ?? rawSelectedObject)
|
||||
.replace(/^\d+\.\s*/, "")
|
||||
.split("|")[0]
|
||||
?.trim();
|
||||
const normalized = toNonEmptyString(primarySegment);
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export function hasInventorySupplierFollowupCue(text: string): boolean {
|
||||
return hasInventorySupplierCue(String(text ?? ""));
|
||||
}
|
||||
@@ -800,7 +824,7 @@ function mergeFollowupFilters(
|
||||
intent === "inventory_aging_by_purchase_date")
|
||||
) {
|
||||
const inheritedItem = previousItem ?? previousAnchorItem;
|
||||
const explicitQuotedItem = toNonEmptyString(extractSelectedObjectQuotedValue(userMessage));
|
||||
const explicitQuotedItem = extractSelectedObjectItemFromFollowupText(userMessage);
|
||||
const currentItem = toNonEmptyString(merged.item);
|
||||
const shouldAdoptExplicitQuotedItem =
|
||||
Boolean(explicitQuotedItem) &&
|
||||
@@ -873,6 +897,23 @@ function mergeFollowupFilters(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (
|
||||
(Boolean(previousPeriodFrom) || Boolean(previousPeriodTo)) &&
|
||||
hasSelectedObjectInventorySignal(userMessage) &&
|
||||
hasSelectedObjectInlineSnapshotMetadata(userMessage) &&
|
||||
(intent === "inventory_purchase_provenance_for_item" || intent === "inventory_purchase_documents_for_item") &&
|
||||
!hasExplicitPeriodLiteral(userMessage) &&
|
||||
!hasExplicitCurrentDateHint(userMessage)
|
||||
) {
|
||||
if (previousPeriodFrom && merged.period_from !== previousPeriodFrom) {
|
||||
merged.period_from = previousPeriodFrom;
|
||||
reasons.push("period_from_from_followup_context");
|
||||
}
|
||||
if (previousPeriodTo && merged.period_to !== previousPeriodTo) {
|
||||
merged.period_to = previousPeriodTo;
|
||||
reasons.push("period_to_from_followup_context");
|
||||
}
|
||||
}
|
||||
if (
|
||||
!sameDateRequested &&
|
||||
(intent === "inventory_on_hand_as_of_date" || intent === "inventory_supplier_stock_overlap_as_of_date") &&
|
||||
|
||||
Reference in New Issue
Block a user