Class FakePromptRunner
-
- All Implemented Interfaces:
-
com.embabel.agent.api.common.PromptRunner,com.embabel.agent.api.common.PromptRunnerOperations,com.embabel.agent.core.ToolGroupConsumer,com.embabel.agent.spi.LlmUse,com.embabel.common.ai.prompt.PromptContributorConsumer
public final class FakePromptRunner implements PromptRunner
-
-
Field Summary
Fields Modifier and Type Field Description private final List<LlmInvocation>llmInvocationsprivate final LlmOptionsllmprivate final List<Message>messagesprivate final Set<ToolGroupRequirement>toolGroupsprivate final List<ToolObject>toolObjectsprivate final List<PromptContributor>promptContributorsprivate final BooleangenerateExamplesprivate final Predicate<String>propertyFilter
-
Constructor Summary
Constructors Constructor Description FakePromptRunner(LlmOptions llm, List<Message> messages, Set<ToolGroupRequirement> toolGroups, List<ToolObject> toolObjects, List<PromptContributor> promptContributors, List<ContextualPromptElement> contextualPromptContributors, Boolean generateExamples, Predicate<String> propertyFilter, OperationContext context, List<LlmInvocation> _llmInvocations, List<Object> responses)
-
Method Summary
Modifier and Type Method Description final List<LlmInvocation>getLlmInvocations()LlmOptionsgetLlm()List<Message>getMessages()Messages added to this PromptRunner Set<ToolGroupRequirement>getToolGroups()Tool groups exposed. List<ToolObject>getToolObjects()Additional objects with @Tool annotation for use in this PromptRunner List<PromptContributor>getPromptContributors()BooleangetGenerateExamples()Whether to generate examples for the prompt. Predicate<String>getPropertyFilter()Filter that determines which properties to include when creating objects. PromptRunnerwithInteractionId(InteractionId interactionId)Set an interaction id for this prompt runner. PromptRunnerwithMessages(List<Message> messages)final UnitexpectResponse(Object response)Add a response to the list of expected responses. <T extends Any> TcreateObject(String prompt, Class<T> outputClass)Create an object of the given type using the given prompt and LLM options from context (process context or implementing class). <T extends Any> TcreateObject(List<Message> messages, Class<T> outputClass)Create an object from messages <T extends Any> TcreateObjectIfPossible(List<Message> messages, Class<T> outputClass)BooleanevaluateCondition(String condition, String context, Double confidenceThreshold)PromptRunnerwithLlm(LlmOptions llm)Specify an LLM for the PromptRunner PromptRunnerwithToolGroup(ToolGroupRequirement toolGroup)PromptRunnerwithToolGroup(ToolGroup toolGroup)Allows for dynamic tool groups to be added to the PromptRunner. PromptRunnerwithToolObject(ToolObject toolObject)Add a tool object PromptRunnerwithPromptContributors(List<PromptContributor> promptContributors)PromptRunnerwithContextualPromptContributors(List<ContextualPromptElement> contextualPromptContributors)Add a prompt contributor that can see context PromptRunnerwithGenerateExamples(Boolean generateExamples)Set whether to generate examples of the output in the prompt on a per-PromptRunner basis. PromptRunnerwithPropertyFilter(Predicate<String> filter)Adds a filter that determines which properties are to be included when creating an object. TemplateOperationswithTemplate(String templateName)Use operations from a given template PromptRunnerwithHandoffs(Class<?> outputTypes)Add a list of handoffs to agents on this platform PromptRunnerwithSubagents(Subagent subagents)Add a list of subagents to hand off to. <T extends Any> ObjectCreator<T>creating(Class<T> outputClass)Create an object creator for the given output class. -
Methods inherited from class com.embabel.agent.api.common.PromptRunner
respond, withContextualPromptContributor, withId, withMessage, withMessages, withPromptContributor, withPromptElements, withProperties, withReference, withReferences, withReferences, withSystemPrompt, withToolGroup, withToolGroups, withToolObject, withToolObjects, withTools, withoutProperties -
Methods inherited from class com.embabel.agent.api.common.PromptRunnerOperations
createObjectIfPossible, generateText -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
FakePromptRunner
FakePromptRunner(LlmOptions llm, List<Message> messages, Set<ToolGroupRequirement> toolGroups, List<ToolObject> toolObjects, List<PromptContributor> promptContributors, List<ContextualPromptElement> contextualPromptContributors, Boolean generateExamples, Predicate<String> propertyFilter, OperationContext context, List<LlmInvocation> _llmInvocations, List<Object> responses)
-
-
Method Detail
-
getLlmInvocations
final List<LlmInvocation> getLlmInvocations()
-
getLlm
LlmOptions getLlm()
-
getMessages
List<Message> getMessages()
Messages added to this PromptRunner
-
getToolGroups
Set<ToolGroupRequirement> getToolGroups()
Tool groups exposed. This will include directly registered tool groups and tool groups resolved from ToolGroups.
-
getToolObjects
List<ToolObject> getToolObjects()
Additional objects with @Tool annotation for use in this PromptRunner
-
getPromptContributors
List<PromptContributor> getPromptContributors()
-
getGenerateExamples
Boolean getGenerateExamples()
Whether to generate examples for the prompt. Defaults to unknown: Set to false if generating your own examples.
-
getPropertyFilter
Predicate<String> getPropertyFilter()
Filter that determines which properties to include when creating objects.
-
withInteractionId
PromptRunner withInteractionId(InteractionId interactionId)
Set an interaction id for this prompt runner.
-
withMessages
PromptRunner withMessages(List<Message> messages)
-
expectResponse
final Unit expectResponse(Object response)
Add a response to the list of expected responses. This is used to simulate responses from the LLM.
-
createObject
<T extends Any> T createObject(String prompt, Class<T> outputClass)
Create an object of the given type using the given prompt and LLM options from context (process context or implementing class). Prompts are typically created within the scope of an
-
createObject
<T extends Any> T createObject(List<Message> messages, Class<T> outputClass)
Create an object from messages
-
createObjectIfPossible
<T extends Any> T createObjectIfPossible(List<Message> messages, Class<T> outputClass)
-
evaluateCondition
Boolean evaluateCondition(String condition, String context, Double confidenceThreshold)
-
withLlm
PromptRunner withLlm(LlmOptions llm)
Specify an LLM for the PromptRunner
-
withToolGroup
PromptRunner withToolGroup(ToolGroupRequirement toolGroup)
-
withToolGroup
PromptRunner withToolGroup(ToolGroup toolGroup)
Allows for dynamic tool groups to be added to the PromptRunner.
-
withToolObject
PromptRunner withToolObject(ToolObject toolObject)
Add a tool object
- Parameters:
toolObject- the object to add.
-
withPromptContributors
PromptRunner withPromptContributors(List<PromptContributor> promptContributors)
-
withContextualPromptContributors
PromptRunner withContextualPromptContributors(List<ContextualPromptElement> contextualPromptContributors)
Add a prompt contributor that can see context
-
withGenerateExamples
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
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
-
withTemplate
TemplateOperations withTemplate(String templateName)
Use operations from a given template
-
withHandoffs
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
PromptRunner withSubagents(Subagent subagents)
Add a list of subagents to hand off to.
-
-
-
-