ЮИ - Автопрогоны: доработать иконки и hover-состояния saved sessions
This commit is contained in:
@@ -11,6 +11,30 @@ function uniqueStrings(values) {
|
||||
.map((item) => item.trim())
|
||||
.filter((item) => item.length > 0)));
|
||||
}
|
||||
function normalizeCounterpartyDisplayLabel(value) {
|
||||
const source = String(value ?? "").trim().replace(/[.]+$/u, "");
|
||||
if (!source) {
|
||||
return null;
|
||||
}
|
||||
return source.replace(/\s+/gu, " ");
|
||||
}
|
||||
function isGenericCounterpartyDisplayLabel(value) {
|
||||
const normalized = normalizeCounterpartyDisplayLabel(value);
|
||||
if (!normalized) {
|
||||
return true;
|
||||
}
|
||||
return /^(?:группа|контрагент|компания|организация)$/iu.test(normalized);
|
||||
}
|
||||
function resolvePreferredCounterpartyDisplayLabel(requestedHint, rowLabels) {
|
||||
const requested = normalizeCounterpartyDisplayLabel(requestedHint);
|
||||
const resolvedFromRows = rowLabels.length === 1 ? normalizeCounterpartyDisplayLabel(rowLabels[0]) : null;
|
||||
if (requested && resolvedFromRows) {
|
||||
if (isGenericCounterpartyDisplayLabel(resolvedFromRows) || requested.includes(resolvedFromRows)) {
|
||||
return requested;
|
||||
}
|
||||
}
|
||||
return requested ?? resolvedFromRows;
|
||||
}
|
||||
function formatTopRows(rows, limit = 6) {
|
||||
return rows.slice(0, limit).map((row, index) => {
|
||||
const period = row.period ?? "дата не указана";
|
||||
@@ -3266,15 +3290,10 @@ function composeFactualReplyBody(intent, rows, options = {}) {
|
||||
};
|
||||
}
|
||||
if (intent === "list_documents_by_counterparty") {
|
||||
const resolvedCounterparty = (typeof options.counterpartyHint === "string" && options.counterpartyHint.trim().length > 0
|
||||
? options.counterpartyHint.trim()
|
||||
: null) ??
|
||||
(() => {
|
||||
const counterparties = uniqueStrings(rows
|
||||
.map((row) => extractCounterpartyName(row))
|
||||
.filter((item) => Boolean(item)));
|
||||
return counterparties.length === 1 ? counterparties[0] : null;
|
||||
})();
|
||||
const rowCounterparties = uniqueStrings(rows
|
||||
.map((row) => extractCounterpartyName(row))
|
||||
.filter((item) => Boolean(item)));
|
||||
const resolvedCounterparty = resolvePreferredCounterpartyDisplayLabel(typeof options.counterpartyHint === "string" ? options.counterpartyHint : null, rowCounterparties);
|
||||
const counterpartyLabel = typeof resolvedCounterparty === "string" && resolvedCounterparty.endsWith(".")
|
||||
? resolvedCounterparty
|
||||
: resolvedCounterparty
|
||||
|
||||
Reference in New Issue
Block a user