Код: Выделить всё
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 };
}
Теперь, когда я запускаю свой поток в первый раз, он работает нормально. Затем я проверяю файлы JSON и получаю идентификатор контрольной точки узла действий. Затем я использую его в конфигурации:
Код: Выделить всё
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);
Код: Выделить всё
Starting...
Runing Type Node...
Runing Budget Node...
Runing Activities Node...
Спасибо
Подробнее здесь: https://stackoverflow.com/questions/793 ... ork-starts
Мобильная версия