diff --git a/core-jdk8/src/main/java/org/bsc/langgraph4j/CompileConfig.java b/core-jdk8/src/main/java/org/bsc/langgraph4j/CompileConfig.java index d6d2f79..6308d6f 100644 --- a/core-jdk8/src/main/java/org/bsc/langgraph4j/CompileConfig.java +++ b/core-jdk8/src/main/java/org/bsc/langgraph4j/CompileConfig.java @@ -1,5 +1,6 @@ package org.bsc.langgraph4j; +import lombok.Getter; import org.bsc.langgraph4j.checkpoint.BaseCheckpointSaver; import java.util.Optional; @@ -8,12 +9,12 @@ public class CompileConfig { private BaseCheckpointSaver checkpointSaver; + @Getter private String[] interruptBefore = {}; + @Getter private String[] interruptAfter = {}; - public Optional getCheckpointSaver() { return Optional.ofNullable(checkpointSaver); } - public String[] getInterruptBefore() { return interruptBefore; } - public String[] getInterruptAfter() { return interruptAfter; } + public Optional checkpointSaver() { return Optional.ofNullable(checkpointSaver); } public static Builder builder() { return new Builder(); diff --git a/core-jdk8/src/main/java/org/bsc/langgraph4j/CompiledGraph.java b/core-jdk8/src/main/java/org/bsc/langgraph4j/CompiledGraph.java index 43acad8..7a832f5 100644 --- a/core-jdk8/src/main/java/org/bsc/langgraph4j/CompiledGraph.java +++ b/core-jdk8/src/main/java/org/bsc/langgraph4j/CompiledGraph.java @@ -61,7 +61,7 @@ protected CompiledGraph(StateGraph stateGraph, CompileConfig compileConfi } public Collection> getStateHistory( RunnableConfig config ) { - var saver = compileConfig.getCheckpointSaver().orElseThrow( () -> (new IllegalStateException("Missing CheckpointSaver!")) ); + var saver = compileConfig.checkpointSaver().orElseThrow( () -> (new IllegalStateException("Missing CheckpointSaver!")) ); return saver.list(config).stream() .map( checkpoint -> StateSnapshot.of( checkpoint, config, stateGraph.getStateFactory() ) ) @@ -69,7 +69,7 @@ public Collection> getStateHistory( RunnableConfig config ) } public StateSnapshot getState( RunnableConfig config ) { - var saver = compileConfig.getCheckpointSaver().orElseThrow( () -> (new IllegalStateException("Missing CheckpointSaver!")) ); + var saver = compileConfig.checkpointSaver().orElseThrow( () -> (new IllegalStateException("Missing CheckpointSaver!")) ); var checkpoint = saver.get(config).orElseThrow( () -> (new IllegalStateException("Missing Checkpoint!")) ); @@ -77,7 +77,7 @@ public StateSnapshot getState( RunnableConfig config ) { } public RunnableConfig updateState( RunnableConfig config, Map values, String asNode ) throws Exception { - var saver = compileConfig.getCheckpointSaver().orElseThrow( () -> (new IllegalStateException("Missing CheckpointSaver!")) ); + var saver = compileConfig.checkpointSaver().orElseThrow( () -> (new IllegalStateException("Missing CheckpointSaver!")) ); // merge values with checkpoint values var updatedCheckpoint = saver.get(config) @@ -152,13 +152,13 @@ private String getEntryPoint( State state ) throws Exception { } private void addCheckpoint( RunnableConfig config, String nodeId, State state, String nextNodeId ) throws Exception { - if( compileConfig.getCheckpointSaver().isPresent() ) { + if( compileConfig.checkpointSaver().isPresent() ) { Checkpoint cp = Checkpoint.builder() .nodeId( nodeId ) .state( state ) .nextNodeId( nextNodeId ) .build(); - compileConfig.getCheckpointSaver().get().put( config, cp ); + compileConfig.checkpointSaver().get().put( config, cp ); } } @@ -172,7 +172,7 @@ Map getInitialStateFromSchema() { Map getInitialState(Map inputs, RunnableConfig config) { - return compileConfig.getCheckpointSaver() + return compileConfig.checkpointSaver() .flatMap( saver -> saver.get( config ) ) .map( cp -> AgentState.updateState( cp.getState(), inputs, stateGraph.getChannels() )) .orElseGet( () -> AgentState.updateState(getInitialStateFromSchema(), inputs, stateGraph.getChannels() )); @@ -258,7 +258,7 @@ public AsyncGenerator> stream(Map inputs, Runna if( isResumeRequest ) { - BaseCheckpointSaver saver = compileConfig.getCheckpointSaver().orElseThrow(() -> (new IllegalStateException("inputs cannot be null (ie. resume request) if no checkpoint saver is configured"))); + BaseCheckpointSaver saver = compileConfig.checkpointSaver().orElseThrow(() -> (new IllegalStateException("inputs cannot be null (ie. resume request) if no checkpoint saver is configured"))); Checkpoint startCheckpoint = saver.get( config ).orElseThrow( () -> (new IllegalStateException("Resume request without a saved checkpoint!")) );