From cc86564cc2f27595559018635e6af48117b28275 Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Mon, 26 Aug 2024 22:28:51 +0200 Subject: [PATCH] feat(StateSnapshot): add support StateSnaphot object work on #14 --- .../bsc/langgraph4j/state/StateSnapshot.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/core-jdk8/src/main/java/org/bsc/langgraph4j/state/StateSnapshot.java b/core-jdk8/src/main/java/org/bsc/langgraph4j/state/StateSnapshot.java index d0ee415..d78608f 100644 --- a/core-jdk8/src/main/java/org/bsc/langgraph4j/state/StateSnapshot.java +++ b/core-jdk8/src/main/java/org/bsc/langgraph4j/state/StateSnapshot.java @@ -1,2 +1,29 @@ -package org.bsc.langgraph4j.state;public class StateSnapshot { +package org.bsc.langgraph4j.state; + +import lombok.NonNull; +import lombok.Value; +import lombok.var; +import org.bsc.langgraph4j.RunnableConfig; +import org.bsc.langgraph4j.checkpoint.Checkpoint; + +@Value +public class StateSnapshot { + AgentState state; + String next; + RunnableConfig config; + + private StateSnapshot(@NonNull AgentState state, @NonNull String next, @NonNull RunnableConfig config) { + this.state = state; + this.next = next; + this.config = config; + } + + public static StateSnapshot of(Checkpoint checkpoint, RunnableConfig config) { + + var newConfig = RunnableConfig.builder(config) + .checkPointId( checkpoint.getId() ) + .build() ; + return new StateSnapshot(checkpoint.getState(), checkpoint.getNextNodeId(), newConfig); + } + }