Code: Select all
const graphAnnotation = Annotation.Root({
input: Annotation(),
activitiesToDo: Annotation(),
});
export type State = typeof graphAnnotation.State;
export type Update = {
activitiesToDo?: Activity[];
};
export function createGraph(checkpointer?: BaseCheckpointSaver) {
const workflow = new StateGraph(graphAnnotation)
.addNode("type", TypeNode)
.addNode("budget", BudgetNode)
.addNode("activities", ActivitiesNode)
.addEdge(START, "type")
.addEdge("type", "budget")
.addEdge("budget", "activities")
.addEdge("activities", END);
// Compile the graph with the checkpointer
const graph = workflow.compile({ checkpointer });
return { graph };
}
Wenn ich meinen Flow jetzt zum ersten Mal ausführe, funktioniert er einwandfrei. Anschließend überprüfe ich die JSON-Dateien und erhalte die Prüfpunkt-ID des Aktivitätsknotens. Ich verwende es dann in der Konfiguration:
Code: Select all
async function main() {
console.log("Starting...");
const config = {
configurable: {
thread_id: "thread-1-here",
checkpoint_id: "1efd33fa-9d7b-6060-8003-33b2528001d3",
},
};
const checkpointer = new FileCheckpointSaver("./checkpoints");
const { graph } = createGraph(checkpointer);
const res: any = await graph.invoke(
{
input: {
type: "indoor",
budget: "medium",
},
},
config
);
console.log(res);
}
main().catch(console.error);
Code: Select all
Starting...
Runing Type Node...
Runing Budget Node...
Runing Activities Node...
Vielen Dank