Interface PromptRunner
-
- All Implemented Interfaces:
-
com.embabel.agent.api.common.PromptRunnerOperations,com.embabel.agent.core.ToolGroupConsumer,com.embabel.agent.spi.LlmUse,com.embabel.common.ai.prompt.PromptContributorConsumer
public interface PromptRunner implements LlmUse, PromptRunnerOperations
User code should always use this interface to execute prompts. Typically obtained from an OperationContext or ActionContext parameter, via OperationContext.ai A PromptRunner is immutable once constructed, and has determined LLM and hyperparameters. Use the "with" methods to evolve the state to your desired configuration before executing createObject, generateText or other LLM invocation methods. Thus, a PromptRunner can be reused within an action implementation. A contextual facade to LlmOperations.
-
-
Method Summary
Modifier and Type Method Description abstract PromptRunnerwithInteractionId(InteractionId interactionId)Set an interaction id for this prompt runner. PromptRunnerwithId(String id)Set the interaction id for this prompt runner. abstract PromptRunnerwithLlm(LlmOptions llm)Specify an LLM for the PromptRunner PromptRunnerwithMessage(Message message)Add a message that will be included in the final prompt. abstract PromptRunnerwithMessages(List<Message> messages)PromptRunnerwithMessages(Message message)PromptRunnerwithToolGroup(String toolGroup)Add a tool group to the PromptRunner abstract PromptRunnerwithToolGroup(ToolGroup toolGroup)Allows for dynamic tool groups to be added to the PromptRunner. abstract PromptRunnerwithToolGroup(ToolGroupRequirement toolGroup)PromptRunnerwithToolGroups(Set<String> toolGroups)PromptRunnerwithTools(String toolGroups)Add a set of tool groups to the PromptRunner PromptRunnerwithToolObject(Object toolObject)Add a tool object to the prompt runner. abstract PromptRunnerwithToolObject(ToolObject toolObject)Add a tool object PromptRunnerwithToolObjects(Object toolObjects)PromptRunnerwithReference(LlmReference reference)Add a reference which provides tools and prompt contribution. PromptRunnerwithReferences(List<LlmReference> references)Add a list of references which provide tools and prompt contributions. PromptRunnerwithReferences(LlmReference references)Add varargs of references which provide tools and prompt contributions. abstract PromptRunnerwithHandoffs(Class<?> outputTypes)Add a list of handoffs to agents on this platform abstract PromptRunnerwithSubagents(Subagent subagents)Add a list of subagents to hand off to. PromptRunnerwithSystemPrompt(String systemPrompt)Add a literal system prompt PromptRunnerwithPromptContributor(PromptContributor promptContributor)Add a prompt contributor that can add to the prompt. abstract PromptRunnerwithPromptContributors(List<PromptContributor> promptContributors)PromptRunnerwithPromptElements(PromptElement elements)Add varargs of prompt contributors and contextual prompt elements. abstract PromptRunnerwithContextualPromptContributors(List<ContextualPromptElement> contextualPromptContributors)Add a prompt contributor that can see context PromptRunnerwithContextualPromptContributor(ContextualPromptElement contextualPromptContributor)abstract PromptRunnerwithGenerateExamples(Boolean generateExamples)Set whether to generate examples of the output in the prompt on a per-PromptRunner basis. abstract PromptRunnerwithPropertyFilter(Predicate<String> filter)Adds a filter that determines which properties are to be included when creating an object. PromptRunnerwithProperties(String properties)Includes the given properties when creating an object. PromptRunnerwithoutProperties(String properties)Excludes the given properties when creating an object. abstract <T extends Any> ObjectCreator<T>creating(Class<T> outputClass)Create an object creator for the given output class. AssistantMessagerespond(List<Message> messages)Respond in a conversation abstract List<ToolObject>getToolObjects()Additional objects with @Tool annotation for use in this PromptRunner abstract List<Message>getMessages()Messages added to this PromptRunner -
Methods inherited from class com.embabel.agent.api.common.PromptRunnerOperations
createObject, createObject, createObjectIfPossible, createObjectIfPossible, evaluateCondition, generateText, withTemplate -
Methods inherited from class com.embabel.agent.spi.LlmUse
getGenerateExamples, getLlm, getPropertyFilter -
Methods inherited from class com.embabel.common.ai.prompt.PromptContributorConsumer
getPromptContributors -
Methods inherited from class com.embabel.agent.core.ToolGroupConsumer
getToolGroups -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
withInteractionId
abstract PromptRunner withInteractionId(InteractionId interactionId)
Set an interaction id for this prompt runner.
-
withId
PromptRunner withId(String id)
Set the interaction id for this prompt runner.
-
withLlm
abstract PromptRunner withLlm(LlmOptions llm)
Specify an LLM for the PromptRunner
-
withMessage
PromptRunner withMessage(Message message)
Add a message that will be included in the final prompt.
-
withMessages
abstract PromptRunner withMessages(List<Message> messages)
-
withMessages
PromptRunner withMessages(Message message)
-
withToolGroup
PromptRunner withToolGroup(String toolGroup)
Add a tool group to the PromptRunner
- Parameters:
toolGroup- name of the toolGroup we're requesting- Returns:
PromptRunner instance with the added tool group
-
withToolGroup
abstract PromptRunner withToolGroup(ToolGroup toolGroup)
Allows for dynamic tool groups to be added to the PromptRunner.
-
withToolGroup
abstract PromptRunner withToolGroup(ToolGroupRequirement toolGroup)
-
withToolGroups
PromptRunner withToolGroups(Set<String> toolGroups)
-
withTools
PromptRunner withTools(String toolGroups)
Add a set of tool groups to the PromptRunner
- Parameters:
toolGroups- the set of named tool groups to add
-
withToolObject
PromptRunner withToolObject(Object toolObject)
Add a tool object to the prompt runner.
- Parameters:
toolObject- the object to add.- Returns:
PromptRunner instance with the added tool object
-
withToolObject
abstract PromptRunner withToolObject(ToolObject toolObject)
Add a tool object
- Parameters:
toolObject- the object to add.
-
withToolObjects
PromptRunner withToolObjects(Object toolObjects)
-
withReference
PromptRunner withReference(LlmReference reference)
Add a reference which provides tools and prompt contribution.
-
withReferences
PromptRunner withReferences(List<LlmReference> references)
Add a list of references which provide tools and prompt contributions.
-
withReferences
PromptRunner withReferences(LlmReference references)
Add varargs of references which provide tools and prompt contributions.
-
withHandoffs
@ApiStatus.Experimental() abstract PromptRunner withHandoffs(Class<?> outputTypes)
Add a list of handoffs to agents on this platform
- Parameters:
outputTypes- the types of objects that can result from output flow
-
withSubagents
@ApiStatus.Experimental() abstract PromptRunner withSubagents(Subagent subagents)
Add a list of subagents to hand off to.
-
withSystemPrompt
PromptRunner withSystemPrompt(String systemPrompt)
Add a literal system prompt
-
withPromptContributor
PromptRunner withPromptContributor(PromptContributor promptContributor)
Add a prompt contributor that can add to the prompt. Facilitates reuse of prompt elements.
- Returns:
PromptRunner instance with the added PromptContributor
-
withPromptContributors
abstract PromptRunner withPromptContributors(List<PromptContributor> promptContributors)
-
withPromptElements
PromptRunner withPromptElements(PromptElement elements)
Add varargs of prompt contributors and contextual prompt elements.
-
withContextualPromptContributors
abstract PromptRunner withContextualPromptContributors(List<ContextualPromptElement> contextualPromptContributors)
Add a prompt contributor that can see context
-
withContextualPromptContributor
PromptRunner withContextualPromptContributor(ContextualPromptElement contextualPromptContributor)
-
withGenerateExamples
abstract PromptRunner withGenerateExamples(Boolean generateExamples)
Set whether to generate examples of the output in the prompt on a per-PromptRunner basis. This overrides platform defaults. Note that adding individual examples with ObjectCreator.withExample will always override this.
-
withPropertyFilter
abstract PromptRunner withPropertyFilter(Predicate<String> filter)
Adds a filter that determines which properties are to be included when creating an object.
Note that each predicate is applied in addition to previously registered predicates, including withProperties and withoutProperties.
- Parameters:
filter- the property predicate to be added
-
withProperties
PromptRunner withProperties(String properties)
Includes the given properties when creating an object.
Note that each predicate is applied in addition to previously registered predicates, including withPropertyFilter and withoutProperties.
- Parameters:
properties- the properties that are to be included
-
withoutProperties
PromptRunner withoutProperties(String properties)
Excludes the given properties when creating an object.
Note that each predicate is applied in addition to previously registered predicates, including withPropertyFilter and withProperties.
- Parameters:
properties- the properties that are to be included
-
creating
abstract <T extends Any> ObjectCreator<T> creating(Class<T> outputClass)
Create an object creator for the given output class. Allows setting strongly typed examples.
-
respond
AssistantMessage respond(List<Message> messages)
Respond in a conversation
-
getToolObjects
abstract List<ToolObject> getToolObjects()
Additional objects with @Tool annotation for use in this PromptRunner
-
getMessages
abstract List<Message> getMessages()
Messages added to this PromptRunner
-
-
-
-