ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Рефакторинг этапов 2.522.55 - Перевод finalizeAddressLaneResponse на builder вместо inline-сборки в assistantAddressAttemptRuntimeAdapter.ts \ Добавлен builder для lane-attempt input: assistantAddressLaneAttemptInputBuilder.ts. \ Добавлен builder для финального address-runtime input: assistantAddressRuntimeInputBuilder.ts.
This commit is contained in:
@@ -11,11 +11,14 @@ import {
|
||||
runAssistantAddressLaneResponseAttemptRuntime,
|
||||
type RunAssistantAddressLaneResponseAttemptRuntimeInput
|
||||
} from "./assistantAddressLaneResponseAttemptRuntimeAdapter";
|
||||
import { buildAssistantAddressLaneResponseAttemptRuntimeInput } from "./assistantAddressLaneResponseAttemptInputBuilder";
|
||||
import {
|
||||
runAssistantLivingChatAttemptRuntime,
|
||||
type RunAssistantLivingChatAttemptRuntimeInput
|
||||
} from "./assistantLivingChatAttemptRuntimeAdapter";
|
||||
import { buildAssistantLivingChatAttemptRuntimeInput } from "./assistantLivingChatAttemptInputBuilder";
|
||||
import { buildAssistantAddressLaneAttemptRuntimeInput } from "./assistantAddressLaneAttemptInputBuilder";
|
||||
import { buildAssistantAddressRuntimeInput } from "./assistantAddressRuntimeInputBuilder";
|
||||
|
||||
interface AddressAttemptPayload {
|
||||
llmProvider?: unknown;
|
||||
@@ -110,27 +113,29 @@ export async function runAssistantAddressAttemptRuntime<ResponseType = unknown>(
|
||||
carryoverMeta = null,
|
||||
llmPreDecomposeMeta = null
|
||||
) =>
|
||||
runAddressLaneResponseAttemptRuntimeSafe({
|
||||
sessionId: input.sessionId,
|
||||
userMessage: input.userMessage,
|
||||
effectiveAddressUserMessage,
|
||||
addressLane,
|
||||
carryoverMeta,
|
||||
llmPreDecomposeMeta,
|
||||
knownOrganizations: input.sessionScope.knownOrganizations,
|
||||
activeOrganization: input.sessionScope.activeOrganization,
|
||||
sanitizeOutgoingAssistantText: input.sanitizeOutgoingAssistantText,
|
||||
buildAddressDebugPayload: input.buildAddressDebugPayload,
|
||||
buildAddressFollowupOffer: input.buildAddressFollowupOffer,
|
||||
mergeKnownOrganizations: input.mergeKnownOrganizations as any,
|
||||
toNonEmptyString: input.toNonEmptyString,
|
||||
appendItem: input.appendItem,
|
||||
getSession: input.getSession,
|
||||
persistSession: input.persistSession,
|
||||
cloneConversation: input.cloneConversation,
|
||||
logEvent: input.logEvent,
|
||||
messageIdFactory: input.messageIdFactory
|
||||
} as RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>);
|
||||
runAddressLaneResponseAttemptRuntimeSafe(
|
||||
buildAssistantAddressLaneResponseAttemptRuntimeInput({
|
||||
sessionId: input.sessionId,
|
||||
userMessage: input.userMessage,
|
||||
effectiveAddressUserMessage,
|
||||
addressLane,
|
||||
carryoverMeta,
|
||||
llmPreDecomposeMeta,
|
||||
knownOrganizations: input.sessionScope.knownOrganizations,
|
||||
activeOrganization: input.sessionScope.activeOrganization,
|
||||
sanitizeOutgoingAssistantText: input.sanitizeOutgoingAssistantText,
|
||||
buildAddressDebugPayload: input.buildAddressDebugPayload,
|
||||
buildAddressFollowupOffer: input.buildAddressFollowupOffer,
|
||||
mergeKnownOrganizations: input.mergeKnownOrganizations,
|
||||
toNonEmptyString: input.toNonEmptyString,
|
||||
appendItem: input.appendItem,
|
||||
getSession: input.getSession,
|
||||
persistSession: input.persistSession,
|
||||
cloneConversation: input.cloneConversation,
|
||||
logEvent: input.logEvent,
|
||||
messageIdFactory: input.messageIdFactory
|
||||
})
|
||||
);
|
||||
|
||||
const tryHandleLivingChat: RunAssistantAddressRuntimeInput<ResponseType>["tryHandleLivingChat"] = async (
|
||||
modeDecision,
|
||||
@@ -190,41 +195,43 @@ export async function runAssistantAddressAttemptRuntime<ResponseType = unknown>(
|
||||
carryMeta,
|
||||
analysisDateHint
|
||||
) =>
|
||||
runAddressLaneAttemptRuntimeSafe({
|
||||
messageUsed,
|
||||
carryMeta,
|
||||
analysisDateHint,
|
||||
activeOrganization: input.sessionScope.activeOrganization,
|
||||
mergeFollowupContextWithOrganizationScope: input.mergeFollowupContextWithOrganizationScope,
|
||||
runAddressQueryTryHandle: input.runAddressQueryTryHandle
|
||||
});
|
||||
runAddressLaneAttemptRuntimeSafe(
|
||||
buildAssistantAddressLaneAttemptRuntimeInput({
|
||||
messageUsed,
|
||||
carryMeta,
|
||||
analysisDateHint,
|
||||
activeOrganization: input.sessionScope.activeOrganization,
|
||||
mergeFollowupContextWithOrganizationScope: input.mergeFollowupContextWithOrganizationScope,
|
||||
runAddressQueryTryHandle: input.runAddressQueryTryHandle
|
||||
})
|
||||
);
|
||||
|
||||
return runAddressRuntimeSafe({
|
||||
featureAssistantAddressQueryV1: input.featureAssistantAddressQueryV1,
|
||||
sessionId: input.sessionId,
|
||||
userMessage: input.userMessage,
|
||||
sessionItems: input.sessionItems,
|
||||
llmProvider: input.payload.llmProvider,
|
||||
useMock: Boolean(input.payload.useMock),
|
||||
featureAddressLlmPredecomposeV1: input.featureAddressLlmPredecomposeV1,
|
||||
runAddressLlmPreDecompose: input.runAddressLlmPreDecompose,
|
||||
buildAddressLlmPredecomposeContractV1: input.buildAddressLlmPredecomposeContractV1,
|
||||
sanitizeAddressMessageForFallback: input.sanitizeAddressMessageForFallback,
|
||||
toNonEmptyString: input.toNonEmptyString,
|
||||
resolveAddressFollowupCarryoverContext: input.resolveAddressFollowupCarryoverContext,
|
||||
resolveAssistantOrchestrationDecision: input.resolveAssistantOrchestrationDecision,
|
||||
buildAddressDialogContinuationContractV2: input.buildAddressDialogContinuationContractV2,
|
||||
runtimeAnalysisContextAsOfDate: input.runtimeAnalysisContextAsOfDate,
|
||||
payloadContextPeriodHint: input.payload?.context?.period_hint,
|
||||
compactWhitespace: input.compactWhitespace,
|
||||
runAddressLaneAttempt,
|
||||
isRetryableAddressLimitedResult: input.isRetryableAddressLimitedResult,
|
||||
finalizeAddressLaneResponse,
|
||||
tryHandleLivingChat,
|
||||
logEvent: input.logEvent,
|
||||
nowIso: input.nowIso,
|
||||
runAddressOrchestrationRuntime: input.runAddressOrchestrationRuntime,
|
||||
runAddressToolGateRuntime: input.runAddressToolGateRuntime,
|
||||
runAddressLaneRuntime: input.runAddressLaneRuntime
|
||||
});
|
||||
return runAddressRuntimeSafe(
|
||||
buildAssistantAddressRuntimeInput({
|
||||
featureAssistantAddressQueryV1: input.featureAssistantAddressQueryV1,
|
||||
sessionId: input.sessionId,
|
||||
userMessage: input.userMessage,
|
||||
sessionItems: input.sessionItems,
|
||||
payload: input.payload,
|
||||
featureAddressLlmPredecomposeV1: input.featureAddressLlmPredecomposeV1,
|
||||
runAddressLlmPreDecompose: input.runAddressLlmPreDecompose,
|
||||
buildAddressLlmPredecomposeContractV1: input.buildAddressLlmPredecomposeContractV1,
|
||||
sanitizeAddressMessageForFallback: input.sanitizeAddressMessageForFallback,
|
||||
toNonEmptyString: input.toNonEmptyString,
|
||||
resolveAddressFollowupCarryoverContext: input.resolveAddressFollowupCarryoverContext,
|
||||
resolveAssistantOrchestrationDecision: input.resolveAssistantOrchestrationDecision,
|
||||
buildAddressDialogContinuationContractV2: input.buildAddressDialogContinuationContractV2,
|
||||
runtimeAnalysisContextAsOfDate: input.runtimeAnalysisContextAsOfDate,
|
||||
compactWhitespace: input.compactWhitespace,
|
||||
runAddressLaneAttempt,
|
||||
isRetryableAddressLimitedResult: input.isRetryableAddressLimitedResult,
|
||||
finalizeAddressLaneResponse,
|
||||
tryHandleLivingChat,
|
||||
logEvent: input.logEvent,
|
||||
nowIso: input.nowIso,
|
||||
runAddressOrchestrationRuntime: input.runAddressOrchestrationRuntime,
|
||||
runAddressToolGateRuntime: input.runAddressToolGateRuntime,
|
||||
runAddressLaneRuntime: input.runAddressLaneRuntime
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import type { RunAssistantAddressLaneAttemptRuntimeInput } from "./assistantAddressLaneAttemptRuntimeAdapter";
|
||||
|
||||
export interface BuildAssistantAddressLaneAttemptRuntimeInputInput {
|
||||
messageUsed: RunAssistantAddressLaneAttemptRuntimeInput["messageUsed"];
|
||||
carryMeta: RunAssistantAddressLaneAttemptRuntimeInput["carryMeta"];
|
||||
analysisDateHint: RunAssistantAddressLaneAttemptRuntimeInput["analysisDateHint"];
|
||||
activeOrganization: RunAssistantAddressLaneAttemptRuntimeInput["activeOrganization"];
|
||||
mergeFollowupContextWithOrganizationScope:
|
||||
RunAssistantAddressLaneAttemptRuntimeInput["mergeFollowupContextWithOrganizationScope"];
|
||||
runAddressQueryTryHandle: RunAssistantAddressLaneAttemptRuntimeInput["runAddressQueryTryHandle"];
|
||||
}
|
||||
|
||||
export function buildAssistantAddressLaneAttemptRuntimeInput(
|
||||
input: BuildAssistantAddressLaneAttemptRuntimeInputInput
|
||||
): RunAssistantAddressLaneAttemptRuntimeInput {
|
||||
return {
|
||||
messageUsed: input.messageUsed,
|
||||
carryMeta: input.carryMeta,
|
||||
analysisDateHint: input.analysisDateHint,
|
||||
activeOrganization: input.activeOrganization,
|
||||
mergeFollowupContextWithOrganizationScope: input.mergeFollowupContextWithOrganizationScope,
|
||||
runAddressQueryTryHandle: input.runAddressQueryTryHandle
|
||||
};
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
import type { RunAssistantAddressLaneResponseAttemptRuntimeInput } from "./assistantAddressLaneResponseAttemptRuntimeAdapter";
|
||||
|
||||
export interface BuildAssistantAddressLaneResponseAttemptRuntimeInputInput<ResponseType = unknown> {
|
||||
sessionId: string;
|
||||
userMessage: string;
|
||||
effectiveAddressUserMessage: string;
|
||||
addressLane: RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["addressLane"];
|
||||
carryoverMeta?: RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["carryoverMeta"];
|
||||
llmPreDecomposeMeta?: RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["llmPreDecomposeMeta"];
|
||||
knownOrganizations: string[];
|
||||
activeOrganization: string | null;
|
||||
sanitizeOutgoingAssistantText:
|
||||
RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["sanitizeOutgoingAssistantText"];
|
||||
buildAddressDebugPayload:
|
||||
RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["buildAddressDebugPayload"];
|
||||
buildAddressFollowupOffer:
|
||||
RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["buildAddressFollowupOffer"];
|
||||
mergeKnownOrganizations:
|
||||
RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["mergeKnownOrganizations"];
|
||||
toNonEmptyString: RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["toNonEmptyString"];
|
||||
appendItem: RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["appendItem"];
|
||||
getSession: RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["getSession"];
|
||||
persistSession: RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["persistSession"];
|
||||
cloneConversation: RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["cloneConversation"];
|
||||
logEvent: RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["logEvent"];
|
||||
messageIdFactory?: RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>["messageIdFactory"];
|
||||
}
|
||||
|
||||
export function buildAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType = unknown>(
|
||||
input: BuildAssistantAddressLaneResponseAttemptRuntimeInputInput<ResponseType>
|
||||
): RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType> {
|
||||
return {
|
||||
sessionId: input.sessionId,
|
||||
userMessage: input.userMessage,
|
||||
effectiveAddressUserMessage: input.effectiveAddressUserMessage,
|
||||
addressLane: input.addressLane,
|
||||
carryoverMeta: input.carryoverMeta ?? null,
|
||||
llmPreDecomposeMeta: input.llmPreDecomposeMeta ?? null,
|
||||
knownOrganizations: input.knownOrganizations,
|
||||
activeOrganization: input.activeOrganization,
|
||||
sanitizeOutgoingAssistantText: input.sanitizeOutgoingAssistantText,
|
||||
buildAddressDebugPayload: input.buildAddressDebugPayload,
|
||||
buildAddressFollowupOffer: input.buildAddressFollowupOffer,
|
||||
mergeKnownOrganizations: input.mergeKnownOrganizations,
|
||||
toNonEmptyString: input.toNonEmptyString,
|
||||
appendItem: input.appendItem,
|
||||
getSession: input.getSession,
|
||||
persistSession: input.persistSession,
|
||||
cloneConversation: input.cloneConversation,
|
||||
logEvent: input.logEvent,
|
||||
messageIdFactory: input.messageIdFactory
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import type { RunAssistantAddressRuntimeInput } from "./assistantAddressRuntimeAdapter";
|
||||
|
||||
interface AssistantAddressAttemptPayloadLike {
|
||||
llmProvider?: unknown;
|
||||
useMock?: unknown;
|
||||
context?: {
|
||||
period_hint?: unknown;
|
||||
} | null;
|
||||
}
|
||||
|
||||
export interface BuildAssistantAddressRuntimeInputInput<ResponseType = unknown>
|
||||
extends Omit<RunAssistantAddressRuntimeInput<ResponseType>, "llmProvider" | "useMock" | "payloadContextPeriodHint"> {
|
||||
payload: AssistantAddressAttemptPayloadLike;
|
||||
}
|
||||
|
||||
export function buildAssistantAddressRuntimeInput<ResponseType = unknown>(
|
||||
input: BuildAssistantAddressRuntimeInputInput<ResponseType>
|
||||
): RunAssistantAddressRuntimeInput<ResponseType> {
|
||||
return {
|
||||
featureAssistantAddressQueryV1: input.featureAssistantAddressQueryV1,
|
||||
sessionId: input.sessionId,
|
||||
userMessage: input.userMessage,
|
||||
sessionItems: input.sessionItems,
|
||||
llmProvider: input.payload.llmProvider,
|
||||
useMock: Boolean(input.payload.useMock),
|
||||
featureAddressLlmPredecomposeV1: input.featureAddressLlmPredecomposeV1,
|
||||
runAddressLlmPreDecompose: input.runAddressLlmPreDecompose,
|
||||
buildAddressLlmPredecomposeContractV1: input.buildAddressLlmPredecomposeContractV1,
|
||||
sanitizeAddressMessageForFallback: input.sanitizeAddressMessageForFallback,
|
||||
toNonEmptyString: input.toNonEmptyString,
|
||||
resolveAddressFollowupCarryoverContext: input.resolveAddressFollowupCarryoverContext,
|
||||
resolveAssistantOrchestrationDecision: input.resolveAssistantOrchestrationDecision,
|
||||
buildAddressDialogContinuationContractV2: input.buildAddressDialogContinuationContractV2,
|
||||
runtimeAnalysisContextAsOfDate: input.runtimeAnalysisContextAsOfDate,
|
||||
payloadContextPeriodHint: input.payload?.context?.period_hint,
|
||||
compactWhitespace: input.compactWhitespace,
|
||||
runAddressLaneAttempt: input.runAddressLaneAttempt,
|
||||
isRetryableAddressLimitedResult: input.isRetryableAddressLimitedResult,
|
||||
finalizeAddressLaneResponse: input.finalizeAddressLaneResponse,
|
||||
tryHandleLivingChat: input.tryHandleLivingChat,
|
||||
logEvent: input.logEvent,
|
||||
nowIso: input.nowIso,
|
||||
runAddressOrchestrationRuntime: input.runAddressOrchestrationRuntime,
|
||||
runAddressToolGateRuntime: input.runAddressToolGateRuntime,
|
||||
runAddressLaneRuntime: input.runAddressLaneRuntime
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user