Class AgentExecutor.Builder
java.lang.Object
org.bsc.langgraph4j.spring.ai.agentexecutor.AgentExecutor.Builder
- Enclosing interface:
- AgentExecutor
Class responsible for building a state graph.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds and returns a StateGraph with the specified configuration.chatModel
(org.springframework.ai.chat.model.ChatModel chatModel) chatService
(ChatService chatService) Deprecated, for removal: This API element is subject to removal in a future version.defaultSystem
(String systemMessage) stateSerializer
(StateSerializer<AgentExecutor.State> stateSerializer) Sets the state serializer for the graph builder.streamingChatModel
(org.springframework.ai.chat.model.ChatModel chatModel) tool
(org.springframework.ai.tool.ToolCallback tool) tools
(org.springframework.ai.tool.ToolCallbackProvider toolCallbackProvider) toolsFromObject
(Object objectWithTools)
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
stateSerializer
Sets the state serializer for the graph builder.- Parameters:
stateSerializer
- the state serializer to set- Returns:
- the current instance of GraphBuilder for method chaining
-
chatModel
-
streamingChatModel
public AgentExecutor.Builder streamingChatModel(org.springframework.ai.chat.model.ChatModel chatModel) -
defaultSystem
-
tool
-
tools
-
tools
public AgentExecutor.Builder tools(org.springframework.ai.tool.ToolCallbackProvider toolCallbackProvider) -
toolsFromObject
-
chatService
Deprecated, for removal: This API element is subject to removal in a future version. -
build
Builds and returns a StateGraph with the specified configuration. Initializes the stateSerializer if it's null. Then, constructs a new StateGraph object using the provided schema and serializer, adds an initial edge from the START node to "agent", and then proceeds to add nodes for "agent" and "action". It also sets up conditional edges from the "agent" node based on whether or not to continue.- Returns:
- A configured StateGraph object.
- Throws:
GraphStateException
- If there is an issue with building the graph state.
-