Class FlowAgentBuilder<T extends FlowAgent,B extends FlowAgentBuilder<T,B>>
java.lang.Object
com.alibaba.cloud.ai.graph.agent.flow.builder.FlowAgentBuilder<T,B>
- Type Parameters:
T- the concrete FlowAgent type this builder createsB- the concrete builder type (for fluent interface support)
- Direct Known Subclasses:
LlmRoutingAgent.LlmRoutingAgentBuilder,LoopAgent.LoopAgentBuilder,ParallelAgent.ParallelAgentBuilder,SequentialAgent.SequentialAgentBuilder
public abstract class FlowAgentBuilder<T extends FlowAgent,B extends FlowAgentBuilder<T,B>>
extends Object
Abstract base builder for FlowAgent and its subclasses. Provides common builder
functionality and enforces consistent builder patterns.
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Tbuild()Builds the concrete FlowAgent instance.compileConfig(CompileConfig compileConfig) Sets the compile configuration.description(String description) Sets the agent description.Sets the agent name.protected abstract Bself()Returns the concrete builder instance.Sets the list of sub-agents.protected voidvalidate()Validates the builder state before creating the agent.
-
Field Details
-
name
-
description
-
compileConfig
-
subAgents
-
-
Constructor Details
-
FlowAgentBuilder
public FlowAgentBuilder()
-
-
Method Details
-
name
Sets the agent name.- Parameters:
name- the unique name of the agent- Returns:
- this builder instance for method chaining
-
description
Sets the agent description.- Parameters:
description- the description of the agent's capability- Returns:
- this builder instance for method chaining
-
compileConfig
Sets the compile configuration.- Parameters:
compileConfig- the compile configuration- Returns:
- this builder instance for method chaining
-
subAgents
Sets the list of sub-agents.- Parameters:
subAgents- the list of sub-agents- Returns:
- this builder instance for method chaining
-
self
Returns the concrete builder instance. This method enables fluent interface support in subclasses.- Returns:
- this builder instance
-
validate
protected void validate()Validates the builder state before creating the agent. Subclasses can override this method to add specific validation logic.- Throws:
IllegalArgumentException- if validation fails
-
build
Builds the concrete FlowAgent instance. Subclasses must implement this method to create the specific agent type.- Returns:
- the built FlowAgent instance
- Throws:
GraphStateException- if agent creation fails
-