АРЧ АП11 - Архитектура: вынести reply packaging из composeStage в отдельный owner
This commit is contained in:
@@ -4,6 +4,7 @@ exports.contractCandidatesFromRows = contractCandidatesFromRows;
|
||||
exports.composeFactualReply = composeFactualReply;
|
||||
exports.inferReplyType = inferReplyType;
|
||||
const assistantOrganizationMatcher_1 = require("../assistantOrganizationMatcher");
|
||||
const replyPackaging_1 = require("./replyPackaging");
|
||||
function uniqueStrings(values) {
|
||||
return Array.from(new Set(values
|
||||
.map((item) => item.trim())
|
||||
@@ -2106,8 +2107,13 @@ function buildOpenContractRiskAggregate(rows) {
|
||||
});
|
||||
}
|
||||
function composeFactualReply(intent, rows, options = {}) {
|
||||
const applyNumericEmphasis = (line) => (options.emphasizeNumbers ? emphasizeNumericTokens(line) : line);
|
||||
const joinLines = (lines) => lines.map(applyNumericEmphasis).join("\n");
|
||||
return (0, replyPackaging_1.finalizeComposeReplyResult)(composeFactualReplyBody(intent, rows, options), {
|
||||
emphasizeNumbers: options.emphasizeNumbers,
|
||||
emphasizeNumericTokens
|
||||
});
|
||||
}
|
||||
function composeFactualReplyBody(intent, rows, options = {}) {
|
||||
const joinLines = replyPackaging_1.joinComposeReplyLines;
|
||||
if (intent === "document_type_and_account_section_profile") {
|
||||
const rowsByMarker = new Map();
|
||||
for (const row of rows) {
|
||||
@@ -4370,8 +4376,5 @@ function composeFactualReply(intent, rows, options = {}) {
|
||||
};
|
||||
}
|
||||
function inferReplyType(responseType) {
|
||||
if (responseType === "FACTUAL_LIST" || responseType === "FACTUAL_SUMMARY") {
|
||||
return "factual";
|
||||
}
|
||||
return "partial_coverage";
|
||||
return (0, replyPackaging_1.inferAddressReplyType)(responseType);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.joinComposeReplyLines = joinComposeReplyLines;
|
||||
exports.finalizeComposeReplyResult = finalizeComposeReplyResult;
|
||||
exports.inferAddressReplyType = inferAddressReplyType;
|
||||
function joinComposeReplyLines(lines) {
|
||||
return lines.join("\n");
|
||||
}
|
||||
function finalizeComposeReplyResult(result, options = {}) {
|
||||
if (!options.emphasizeNumbers || typeof options.emphasizeNumericTokens !== "function") {
|
||||
return result;
|
||||
}
|
||||
return {
|
||||
...result,
|
||||
text: String(result.text ?? "")
|
||||
.split("\n")
|
||||
.map((line) => options.emphasizeNumericTokens(line))
|
||||
.join("\n")
|
||||
};
|
||||
}
|
||||
function inferAddressReplyType(responseType) {
|
||||
if (responseType === "FACTUAL_LIST" || responseType === "FACTUAL_SUMMARY") {
|
||||
return "factual";
|
||||
}
|
||||
return "partial_coverage";
|
||||
}
|
||||
Reference in New Issue
Block a user