Class FakePromptRunner
-
- All Implemented Interfaces:
-
com.embabel.agent.api.common.PromptRunner,com.embabel.agent.api.common.PromptRunnerOperations,com.embabel.agent.api.tool.agentic.ToolChaining,com.embabel.agent.core.ToolGroupConsumer,com.embabel.agent.core.support.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 List<AgentImage>imagesprivate final Set<ToolGroupRequirement>toolGroupsprivate final List<ToolObject>toolObjectsprivate final List<PromptContributor>promptContributorsprivate final BooleangenerateExamplesprivate final Predicate<String>propertyFilterprivate final Booleanvalidationprivate final InteractionIdinteractionId
-
Constructor Summary
Constructors Constructor Description FakePromptRunner(LlmOptions llm, List<Message> messages, List<AgentImage> images, Set<ToolGroupRequirement> toolGroups, List<ToolObject> toolObjects, List<PromptContributor> promptContributors, List<ContextualPromptElement> contextualPromptContributors, Boolean generateExamples, Predicate<String> propertyFilter, Boolean validation, OperationContext context, List<LlmInvocation> _llmInvocations, List<Object> responses, List<Tool> otherTools, InteractionId interactionId, List<GuardRail> guardRails)
-
Method Summary
Modifier and Type Method Description final List<LlmInvocation>getLlmInvocations()LlmOptionsgetLlm()List<Message>getMessages()Messages added to this PromptRunner List<AgentImage>getImages()Images 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. BooleangetValidation()Whether to validate generated objects. final InteractionIdgetInteractionId()The interaction ID set via withInteractionId() or withId(). PromptRunnerwithInteractionId(InteractionId interactionId)Set an interaction id for this prompt runner. PromptRunnerwithMessages(List<Message> messages)PromptRunnerwithImages(List<AgentImage> images)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. PromptRunnerwithValidation(Boolean validation)Set whether to validate created objects. PromptRunner.Renderingrendering(String templateName)Returns Rendering for rendering the specified template. PromptRunnerwithTool(Tool tool)Add a framework-agnostic Tool to the prompt runner. <T extends Any> PromptRunner.Creating<T>creating(Class<T> outputClass)Returns a mode for creating strongly-typed objects. PromptRunnerwithGuardRails(GuardRail guards)Add guardrail instances to this PromptRunner (additive). <T extends Any> PromptRunnerwithToolChainingFrom(Class<T> type, DomainToolPredicate<T> predicate)Register a domain class with a predicate to control when its @LlmTool methods become available as tools. PromptRunnerwithToolChainingFromAny()Enable auto-discovery of chained tools from any returned artifact. -
Methods inherited from class com.embabel.agent.api.common.PromptRunner
respond, stream, streaming, supportsStreaming, supportsThinking, thinking, withContextualPromptContributor, withFunctionTools, withId, withImage, withImages, withMessage, withMessages, withPromptContributor, withPromptElements, withReference, withReferences, withReferences, withSystemPrompt, withTemplate, withThinking, withToolGroup, withToolGroups, withToolGroups, withToolObject, withToolObjectInstances, withToolObjects, withToolObjects, withTools, withTools, withTools -
Methods inherited from class com.embabel.agent.api.common.PromptRunnerOperations
createObject, createObjectIfPossible, createObjectIfPossible, generateText, generateText, respond -
Methods inherited from class com.embabel.agent.api.tool.agentic.ToolChaining
withToolChainingFrom -
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, List<AgentImage> images, Set<ToolGroupRequirement> toolGroups, List<ToolObject> toolObjects, List<PromptContributor> promptContributors, List<ContextualPromptElement> contextualPromptContributors, Boolean generateExamples, Predicate<String> propertyFilter, Boolean validation, OperationContext context, List<LlmInvocation> _llmInvocations, List<Object> responses, List<Tool> otherTools, InteractionId interactionId, List<GuardRail> guardRails)
-
-
Method Detail
-
getLlmInvocations
final List<LlmInvocation> getLlmInvocations()
-
getLlm
LlmOptions getLlm()
-
getMessages
List<Message> getMessages()
Messages added to this PromptRunner
-
getImages
List<AgentImage> getImages()
Images 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.
-
getValidation
Boolean getValidation()
Whether to validate generated objects. Defaults to
true; set tofalseto skip validation.
-
getInteractionId
final InteractionId getInteractionId()
The interaction ID set via withInteractionId() or withId(). Can be inspected in tests to verify the correct ID was set.
-
withInteractionId
PromptRunner withInteractionId(InteractionId interactionId)
Set an interaction id for this prompt runner.
-
withMessages
PromptRunner withMessages(List<Message> messages)
-
withImages
PromptRunner withImages(List<AgentImage> images)
-
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 Creating.withExample will always override this.
-
withPropertyFilter
@Deprecated(message = "Use creating().withPropertyFilter() instead") 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.
- Parameters:
filter- the property predicate to be added
-
withValidation
@Deprecated(message = "Use creating().withValidation() instead") PromptRunner withValidation(Boolean validation)
Set whether to validate created objects.
- Parameters:
validation-trueto validate created objects;falseotherwise.
-
rendering
PromptRunner.Rendering rendering(String templateName)
Returns Rendering for rendering the specified template.
- Parameters:
templateName- the name of the template to render- Returns:
rendering mode for creating objects and generating text from templates
-
withTool
PromptRunner withTool(Tool tool)
Add a framework-agnostic Tool to the prompt runner.
- Parameters:
tool- the tool to add- Returns:
PromptRunner instance with the added tool
-
creating
<T extends Any> PromptRunner.Creating<T> creating(Class<T> outputClass)
Returns a mode for creating strongly-typed objects.
- Parameters:
outputClass- the class of objects to create- Returns:
creating mode supporting examples, property filtering, and validation
-
withGuardRails
PromptRunner withGuardRails(GuardRail guards)
Add guardrail instances to this PromptRunner (additive).
- Parameters:
guards- the guardrail instances to add- Returns:
PromptRunner instance with additional guardrails configured
-
withToolChainingFrom
<T extends Any> PromptRunner withToolChainingFrom(Class<T> type, DomainToolPredicate<T> predicate)
Register a domain class with a predicate to control when its @LlmTool methods become available as tools.
When a single artifact of the specified type is returned, any @LlmTool annotated methods on that instance become available as tools, provided the predicate is satisfied.
When multiple artifacts of the same type are returned, "last wins" - only the most recent artifact that passes the predicate will have its tools exposed.
- Parameters:
type- The domain class that may contribute @LlmTool methodspredicate- Predicate to filter which instances contribute tools
-
withToolChainingFromAny
PromptRunner withToolChainingFromAny()
Enable auto-discovery of chained tools from any returned artifact.
When enabled, any artifact with @LlmTool methods will automatically have its tools exposed, replacing ALL previous bindings.
-
-
-
-