Package com.embabel.agent.api.dsl
Class AgentBuilder
-
- All Implemented Interfaces:
-
com.embabel.common.ai.prompt.PromptContributorConsumer
public final class AgentBuilder implements PromptContributorConsumerInstances of this are usually created via the convenient agent() function.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classAgentBuilder.ConditionDelegateProviderpublic final classAgentBuilder.ConditionDelegate
-
Constructor Summary
Constructors Constructor Description AgentBuilder(String name, String provider, Semver version, String description, List<PromptContributor> promptContributors)
-
Method Summary
Modifier and Type Method Description final List<Action>getActions()List<PromptContributor>getPromptContributors()final StringgetName()final StringgetProvider()final SemvergetVersion()final StringgetDescription()final Unitaction(Function1<AgentBuilder, Action> block)Create an action final UnitregisterPromptContributors(PromptContributor promptContributors)Require prompt contributors at agent level final <I extends Any, O extends Any> UnitlocalAgentAction(Agent agent)Add an action is an anonymous agent. final <I extends Any, O extends Any> UnitreferencedAgentAction(String agentName)Add an action that references the agent with a given name final Unitadd(AgentScope agentScope)final Unitflow(Function1<AgentBuilder, AgentScopeBuilder<?>> block)Add a pattern builder, such as an aggregation flow, to the agent. final <I extends Any, O extends Any> Unittransformation(String name, String description, List<Condition> preConditions, List<String> pre, List<Condition> post, Boolean canRerun, String inputVarName, String outputVarName, Double cost, Set<ToolGroupRequirement> toolGroups, ActionQos qos, Set<String> referencedInputProperties, Transformation<I, O> block)Add an action that is a transformation NOT using an LLM. final <I extends Any, O extends Any> UnitpromptedTransformer(String name, String description, List<Condition> pre, List<Condition> post, String inputVarName, String outputVarName, Double cost, Set<ToolGroupRequirement> toolGroups, ActionQos qos, Set<String> referencedInputProperties, LlmOptions llm, List<PromptContributor> promptContributors, Boolean canRerun, Collection<ToolCallback> toolCallbacks, Function1<TransformationActionContext<I, O>, String> prompt)Add an action that is a transformation using an LLM. final Unitgoal(String name, String description, KClass<?> satisfiedBy, Set<KClass<?>> requires, Set<IoBinding> inputs, List<Condition> pre, Double value, Export export)Add a goal to the agent. final Unitcondition(Function1<AgentBuilder, Condition> block)final AgentBuilder.ConditionDelegateProviderconditionOf(String name, Double cost, Function1<OperationContext, Boolean> block)final AgentBuilder.ConditionDelegateProviderpromptedCondition(String name, Function1<OperationContext, String> prompt, LlmCall llm)Declare a condition determined with an LLM. final Agentbuild()Build the agent -
-
Method Detail
-
getActions
final List<Action> getActions()
-
getPromptContributors
List<PromptContributor> getPromptContributors()
-
getProvider
final String getProvider()
-
getVersion
final Semver getVersion()
-
getDescription
final String getDescription()
-
action
final Unit action(Function1<AgentBuilder, Action> block)
Create an action
-
registerPromptContributors
final Unit registerPromptContributors(PromptContributor promptContributors)
Require prompt contributors at agent level
-
localAgentAction
final <I extends Any, O extends Any> Unit localAgentAction(Agent agent)
Add an action is an anonymous agent. This is valuable because the agent will be private and will not pollute the global action space.
-
referencedAgentAction
final <I extends Any, O extends Any> Unit referencedAgentAction(String agentName)
Add an action that references the agent with a given name
-
add
final Unit add(AgentScope agentScope)
-
flow
final Unit flow(Function1<AgentBuilder, AgentScopeBuilder<?>> block)
Add a pattern builder, such as an aggregation flow, to the agent. Must be used if you have multiple actions
-
transformation
final <I extends Any, O extends Any> Unit transformation(String name, String description, List<Condition> preConditions, List<String> pre, List<Condition> post, Boolean canRerun, String inputVarName, String outputVarName, Double cost, Set<ToolGroupRequirement> toolGroups, ActionQos qos, Set<String> referencedInputProperties, Transformation<I, O> block)
Add an action that is a transformation NOT using an LLM.
-
promptedTransformer
final <I extends Any, O extends Any> Unit promptedTransformer(String name, String description, List<Condition> pre, List<Condition> post, String inputVarName, String outputVarName, Double cost, Set<ToolGroupRequirement> toolGroups, ActionQos qos, Set<String> referencedInputProperties, LlmOptions llm, List<PromptContributor> promptContributors, Boolean canRerun, Collection<ToolCallback> toolCallbacks, Function1<TransformationActionContext<I, O>, String> prompt)
Add an action that is a transformation using an LLM.
-
goal
final Unit goal(String name, String description, KClass<?> satisfiedBy, Set<KClass<?>> requires, Set<IoBinding> inputs, List<Condition> pre, Double value, Export export)
Add a goal to the agent.
- Parameters:
name- The name of the goal.description- A description of the goal.satisfiedBy- A class that satisfies this goal.requires- A set of classes that are required to satisfy this goal.pre- custom preconditions, in addition to input preconditionsvalue- the value of achieving this goal
-
condition
final Unit condition(Function1<AgentBuilder, Condition> block)
-
conditionOf
final AgentBuilder.ConditionDelegateProvider conditionOf(String name, Double cost, Function1<OperationContext, Boolean> block)
-
promptedCondition
final AgentBuilder.ConditionDelegateProvider promptedCondition(String name, Function1<OperationContext, String> prompt, LlmCall llm)
Declare a condition determined with an LLM. Assign it a name to ensure type safe access val myCondition = condition("custom prompt")
-
-
-
-