АРЧ АП11 - Архитектура после регресса: Архитектура: исправить deep-turn normalizer schema contract и вернуть hybrid follow-up authority в phase13 replay
This commit is contained in:
+36
-2
@@ -2,6 +2,7 @@ import type { AssistantMessageRequestPayload } from "../types/assistant";
|
||||
import type { NormalizeRequestPayload, NormalizeResponsePayload } from "../types/normalizer";
|
||||
import type { InvestigationStateWithProblemUnits } from "../types/stage2ProblemUnits";
|
||||
import type { AssistantFollowupUsage } from "./assistantFollowupUsage";
|
||||
import { toRouteHintSummary } from "./routeHintAdapter";
|
||||
|
||||
export interface AssistantDeepTurnFollowupBinding {
|
||||
normalizedQuestion: string;
|
||||
@@ -29,6 +30,27 @@ export interface BuildAssistantDeepTurnNormalizationRuntimeOutput {
|
||||
normalized: NormalizeResponsePayload;
|
||||
}
|
||||
|
||||
function resolveDeepTurnNormalizerPromptVersion(promptVersion: NormalizeRequestPayload["promptVersion"]): string {
|
||||
const normalized = String(promptVersion ?? "").trim().toLowerCase();
|
||||
if (
|
||||
normalized === "normalizer_v2_0_2" ||
|
||||
normalized === "normalizer_v2_0_1" ||
|
||||
normalized === "normalizer_v2" ||
|
||||
normalized === "normalizer_v1"
|
||||
) {
|
||||
return String(promptVersion);
|
||||
}
|
||||
return "normalizer_v2_0_2";
|
||||
}
|
||||
|
||||
function canSynthesizeRouteSummary(normalized: NormalizeResponsePayload["normalized"]): boolean {
|
||||
if (!normalized || typeof normalized !== "object") {
|
||||
return false;
|
||||
}
|
||||
const source = normalized as unknown as Record<string, unknown>;
|
||||
return Array.isArray(source.fragments);
|
||||
}
|
||||
|
||||
export async function buildAssistantDeepTurnNormalizationRuntime(
|
||||
input: BuildAssistantDeepTurnNormalizationRuntimeInput
|
||||
): Promise<BuildAssistantDeepTurnNormalizationRuntimeOutput> {
|
||||
@@ -58,7 +80,8 @@ export async function buildAssistantDeepTurnNormalizationRuntime(
|
||||
baseUrl: input.payload.baseUrl,
|
||||
temperature: input.payload.temperature,
|
||||
maxOutputTokens: input.payload.maxOutputTokens,
|
||||
promptVersion: input.payload.promptVersion ?? "address_query_runtime_v1",
|
||||
promptVersion: resolveDeepTurnNormalizerPromptVersion(input.payload.promptVersion),
|
||||
schemaVersion: "v2_0_2",
|
||||
systemPrompt: input.payload.systemPrompt,
|
||||
developerPrompt: input.payload.developerPrompt,
|
||||
domainPrompt: input.payload.domainPrompt,
|
||||
@@ -69,10 +92,21 @@ export async function buildAssistantDeepTurnNormalizationRuntime(
|
||||
};
|
||||
|
||||
const normalized = await input.normalize(normalizePayload);
|
||||
const normalizedPayload = normalized.normalized;
|
||||
const synthesizedRouteSummary =
|
||||
normalized.route_hint_summary ??
|
||||
(normalizedPayload && canSynthesizeRouteSummary(normalizedPayload) ? toRouteHintSummary(normalizedPayload) : null);
|
||||
const normalizedWithRouteSummary: NormalizeResponsePayload =
|
||||
synthesizedRouteSummary === normalized.route_hint_summary
|
||||
? normalized
|
||||
: {
|
||||
...normalized,
|
||||
route_hint_summary: synthesizedRouteSummary
|
||||
};
|
||||
|
||||
return {
|
||||
followupBinding,
|
||||
normalizePayload,
|
||||
normalized
|
||||
normalized: normalizedWithRouteSummary
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user