feat(experiments): expose reconstruction open-question evidence
This commit is contained in:
@@ -67,6 +67,12 @@ async function runStartCaseExperiment(scenarioInput, experimentInstruction, opti
|
||||
let reconstructionModelName = options.reconstructionModelName;
|
||||
let reconstructionOnly = options.reconstructionOnly;
|
||||
const isMock = process.env.START_CASE_EXPERIMENT_HELPER_MOCK === "1";
|
||||
const productionRequest = {
|
||||
scenario: scenarioInput?.scenario,
|
||||
...(scenarioInput?.promptVersion !== undefined
|
||||
? { promptVersion: scenarioInput.promptVersion }
|
||||
: {}),
|
||||
};
|
||||
|
||||
if (process.env.START_CASE_EXPERIMENT_PROVIDER === "openai") {
|
||||
if (!process.env.OPENAI_API_KEY) {
|
||||
@@ -95,13 +101,51 @@ async function runStartCaseExperiment(scenarioInput, experimentInstruction, opti
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
situationGraph: { nodes: [], edges: [], activeUnknownNodeId: null, resolvedNodeIds: [], currentSummary: "test" },
|
||||
reconstruction: {
|
||||
importantUnknowns: [
|
||||
{
|
||||
id: "unknown-1",
|
||||
description: "Canonical uncertainty from the deterministic test double",
|
||||
confidence: "medium",
|
||||
question: "What would resolve the deterministic uncertainty?",
|
||||
},
|
||||
],
|
||||
},
|
||||
situationGraph: {
|
||||
nodes: [
|
||||
{
|
||||
id: "graph-unknown-1",
|
||||
label: "Canonical uncertainty",
|
||||
description: "Canonical uncertainty from the deterministic test double",
|
||||
openQuestion: "What would resolve the deterministic uncertainty?",
|
||||
status: "unknown",
|
||||
kind: "unknown",
|
||||
},
|
||||
{
|
||||
id: "graph-state-1",
|
||||
label: "Known state",
|
||||
description: "A non-unknown node",
|
||||
status: "supported",
|
||||
kind: "state",
|
||||
},
|
||||
],
|
||||
edges: [],
|
||||
activeUnknownNodeId: null,
|
||||
resolvedNodeIds: [],
|
||||
currentSummary: "test",
|
||||
},
|
||||
assessment: { phase: "initial", progress: 0 },
|
||||
selectedQuestion: null,
|
||||
summary: null,
|
||||
diagnostics: {
|
||||
validationStatus: "mock",
|
||||
modelName: "inline-test-double",
|
||||
promptVersion: productionRequest.promptVersion ?? "v0.5",
|
||||
presentationValidationStatus: "valid",
|
||||
presentationValidationIssues: [],
|
||||
compatibilityApplied: false,
|
||||
compatibilityChanges: [],
|
||||
compatibilityWarnings: [],
|
||||
reconstructionOnly: dependencies.reconstructionOnly === true,
|
||||
graphReferenceValidation: { valid: true, errors: [] },
|
||||
},
|
||||
@@ -125,7 +169,7 @@ async function runStartCaseExperiment(scenarioInput, experimentInstruction, opti
|
||||
let result;
|
||||
const endToEndStartedAt = Date.now();
|
||||
try {
|
||||
result = await startCase(scenarioInput, {
|
||||
result = await startCase(productionRequest, {
|
||||
reconstructionProvider,
|
||||
reconstructionModelName,
|
||||
reconstructionOnly,
|
||||
@@ -147,7 +191,7 @@ async function runStartCaseExperiment(scenarioInput, experimentInstruction, opti
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
const output = {
|
||||
success: result.success,
|
||||
summary: result.summary ?? null,
|
||||
reconstruction: result.reconstruction ?? null,
|
||||
@@ -162,6 +206,47 @@ async function runStartCaseExperiment(scenarioInput, experimentInstruction, opti
|
||||
error: result.success ? null : (result.error ?? "unknown"),
|
||||
statusCode: result.statusCode ?? (result.success ? 200 : 500),
|
||||
};
|
||||
|
||||
if (reconstructionOnly) {
|
||||
if (scenarioInput?.experimentId !== undefined) {
|
||||
output.experimentId = scenarioInput.experimentId;
|
||||
}
|
||||
if (scenarioInput?.scenarioId !== undefined) {
|
||||
output.scenarioId = scenarioInput.scenarioId;
|
||||
}
|
||||
|
||||
const configuredProvider =
|
||||
process.env.START_CASE_EXPERIMENT_PROVIDER === "openai" ? "openai" : "ollama";
|
||||
const configuredModel =
|
||||
result.diagnostics?.modelName ??
|
||||
reconstructionModelName ??
|
||||
(configuredProvider === "ollama" ? process.env.OLLAMA_MODEL : undefined);
|
||||
const effectivePromptVersion = result.diagnostics?.promptVersion;
|
||||
|
||||
output.execution = {
|
||||
provider: configuredProvider,
|
||||
...(configuredModel !== undefined ? { model: configuredModel } : {}),
|
||||
...(effectivePromptVersion !== undefined
|
||||
? { promptVersion: effectivePromptVersion }
|
||||
: {}),
|
||||
};
|
||||
|
||||
if (Array.isArray(result.situationGraph?.nodes)) {
|
||||
output.graphUnknownNodes = result.situationGraph.nodes
|
||||
.filter((node) => node.kind === "unknown")
|
||||
.map((node) => ({
|
||||
id: node.id,
|
||||
label: node.label,
|
||||
description: node.description,
|
||||
...(node.openQuestion !== undefined
|
||||
? { openQuestion: node.openQuestion }
|
||||
: {}),
|
||||
...(node.status !== undefined ? { status: node.status } : {}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
|
||||
Reference in New Issue
Block a user