feat: formulate follow-up questions from graph context
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { describeGraph } from "./builder.js";
|
||||
import { formulateQuestion } from "./question-formulator.js";
|
||||
import { graphUpdateSchema, situationGraphSchema } from "./schema.js";
|
||||
import {
|
||||
applyGraphUpdate,
|
||||
buildDeterministicQuestionForUnknown,
|
||||
detectDuplicateNodeIds,
|
||||
findAffectedNodes,
|
||||
scoreUnknownCandidate,
|
||||
@@ -630,17 +630,32 @@ export function applyValidatedProposal({ situationGraph, proposal }) {
|
||||
updatedSituationGraph.activeUnknownNodeId = newActiveUnknownNodeId;
|
||||
updatedSituationGraph.currentSummary = describeGraph(updatedSituationGraph);
|
||||
|
||||
const selectedNode = deterministicSelection?.nodeId
|
||||
? updatedSituationGraph.nodes.find(
|
||||
(node) => node.id === deterministicSelection.nodeId,
|
||||
)
|
||||
: null;
|
||||
const formulatedQuestion = selectedNode
|
||||
? formulateQuestion({
|
||||
node: selectedNode,
|
||||
graph: updatedSituationGraph,
|
||||
context: {
|
||||
resolvedValues: validatedProposal.updatedNodes
|
||||
.map((update) => update.newValue)
|
||||
.filter(
|
||||
(value) => typeof value === "string" && value.trim().length > 0,
|
||||
),
|
||||
},
|
||||
})
|
||||
: null;
|
||||
|
||||
const finalSelectedQuestion = deterministicSelection
|
||||
? {
|
||||
nodeId: deterministicSelection.nodeId,
|
||||
question:
|
||||
deterministicSelection.question ||
|
||||
buildDeterministicQuestionForUnknown(
|
||||
updatedSituationGraph.nodes.find(
|
||||
(node) => node.id === deterministicSelection.nodeId,
|
||||
),
|
||||
),
|
||||
reason: deterministicSelection.reason,
|
||||
formulatedQuestion?.question || deterministicSelection.question,
|
||||
reason: formulatedQuestion?.reason || deterministicSelection.reason,
|
||||
strategy: formulatedQuestion?.strategy,
|
||||
}
|
||||
: null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user