47 lines
2.2 KiB
JavaScript
47 lines
2.2 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.runAssistantAddressLaneResponseRuntime = runAssistantAddressLaneResponseRuntime;
|
|
const assistantAddressTurnFinalizeRuntimeAdapter_1 = require("./assistantAddressTurnFinalizeRuntimeAdapter");
|
|
function runAssistantAddressLaneResponseRuntime(input) {
|
|
const finalizeAddressTurnSafe = input.finalizeAddressTurn ?? assistantAddressTurnFinalizeRuntimeAdapter_1.finalizeAssistantAddressTurn;
|
|
const safeAddressReply = input.sanitizeOutgoingAssistantText(input.addressLane.reply_text);
|
|
const debug = input.buildAddressDebugPayload(input.addressLane.debug, input.llmPreDecomposeMeta);
|
|
const followupOffer = input.buildAddressFollowupOffer(debug);
|
|
if (followupOffer) {
|
|
debug.address_followup_offer = followupOffer;
|
|
}
|
|
const debugKnownOrganizations = input.mergeKnownOrganizations(input.knownOrganizations);
|
|
const debugFilters = debug?.extracted_filters && typeof debug.extracted_filters === "object"
|
|
? debug.extracted_filters
|
|
: null;
|
|
const debugActiveOrganization = input.toNonEmptyString(debugFilters?.organization) ??
|
|
input.toNonEmptyString(input.activeOrganization);
|
|
if (debugKnownOrganizations.length > 0) {
|
|
debug.assistant_known_organizations = debugKnownOrganizations;
|
|
}
|
|
if (debugActiveOrganization) {
|
|
debug.assistant_active_organization = debugActiveOrganization;
|
|
}
|
|
const finalization = finalizeAddressTurnSafe({
|
|
sessionId: input.sessionId,
|
|
userMessage: input.userMessage,
|
|
effectiveAddressUserMessage: input.effectiveAddressUserMessage,
|
|
assistantReply: safeAddressReply,
|
|
replyType: input.addressLane.reply_type,
|
|
addressLaneDebug: (input.addressLane.debug ?? null),
|
|
debug,
|
|
carryoverMeta: (input.carryoverMeta ?? null),
|
|
llmPreDecomposeMeta: (input.llmPreDecomposeMeta ?? null),
|
|
appendItem: input.appendItem,
|
|
getSession: input.getSession,
|
|
persistSession: input.persistSession,
|
|
cloneConversation: input.cloneConversation,
|
|
logEvent: input.logEvent,
|
|
messageIdFactory: input.messageIdFactory
|
|
});
|
|
return {
|
|
response: finalization.response,
|
|
debug
|
|
};
|
|
}
|