Interface PromptRunner.Creating
-
- All Implemented Interfaces:
public interface PromptRunner.Creating<T extends Object>Fluent interface for creating strongly-typed objects from LLM responses. Provides configuration options for:
Adding examples
Filtering properties
Enabling/disabling validation
Instances are obtained via PromptRunner.creating.
-
-
Method Summary
Modifier and Type Method Description PromptRunner.Creating<T>withExample(String description, T value)Add an example of the desired output to the prompt. abstract PromptRunner.Creating<T>withExample(CreationExample<T> example)Add an example of the desired output to the prompt. PromptRunner.Creating<T>withExamples(Iterable<CreationExample<T>> examples)Add multiple examples from a list or other iterable. PromptRunner.Creating<T>withExamples(CreationExample<T> examples)Add multiple examples using vararg syntax. abstract PromptRunner.Creating<T>withPropertyFilter(Predicate<String> filter)Add a filter that determines which properties are to be included when creating an object. PromptRunner.Creating<T>withProperties(String properties)Include the given properties when creating an object. PromptRunner.Creating<T>withoutProperties(String properties)Exclude the given properties when creating an object. abstract PromptRunner.Creating<T>withValidation(Boolean validation)Set whether to validate created objects. PromptRunner.Creating<T>withoutValidation()Disables validation of created objects. TfromPrompt(String prompt)Create an object of the desired type using the given prompt and LLM options from context (process context or implementing class). abstract TfromTemplate(String templateName, Map<String, Object> model)Create an object of this type from the given template. abstract TfromMessages(List<Message> messages)Create an object of the desired type from messages. -
-
Method Detail
-
withExample
PromptRunner.Creating<T> withExample(String description, T value)
Add an example of the desired output to the prompt. This will be included in JSON. It is possible to call this method multiple times. This will override PromptRunner.withGenerateExamples
- Parameters:
description- description of the examplevalue- the example object- Returns:
this instance for method chaining
-
withExample
abstract PromptRunner.Creating<T> withExample(CreationExample<T> example)
Add an example of the desired output to the prompt. This will be included in JSON. It is possible to call this method multiple times. This will override PromptRunner.withGenerateExamples
- Parameters:
example- the example to add- Returns:
this instance for method chaining
-
withExamples
PromptRunner.Creating<T> withExamples(Iterable<CreationExample<T>> examples)
Add multiple examples from a list or other iterable. Each example will be added as a prompt contributor to improve LLM output quality.
- Parameters:
examples- the examples to add- Returns:
this instance for method chaining
-
withExamples
PromptRunner.Creating<T> withExamples(CreationExample<T> examples)
Add multiple examples using vararg syntax. Each example will be added as a prompt contributor to improve LLM output quality.
- Parameters:
examples- the examples to add- Returns:
this instance for method chaining
-
withPropertyFilter
abstract PromptRunner.Creating<T> withPropertyFilter(Predicate<String> filter)
Add 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- Returns:
this instance for method chaining
-
withProperties
PromptRunner.Creating<T> withProperties(String properties)
Include 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- Returns:
this instance for method chaining
-
withoutProperties
PromptRunner.Creating<T> withoutProperties(String properties)
Exclude 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 to be excluded- Returns:
this instance for method chaining
-
withValidation
abstract PromptRunner.Creating<T> withValidation(Boolean validation)
Set whether to validate created objects.
- Parameters:
validation-trueto validate created objects;falseotherwise.- Returns:
this instance for method chaining
-
withoutValidation
PromptRunner.Creating<T> withoutValidation()
Disables validation of created objects.
- Returns:
this instance for method chaining
-
fromPrompt
T fromPrompt(String prompt)
Create an object of the desired type using the given prompt and LLM options from context (process context or implementing class). Prompts are typically created within the scope of an @Action method that provides access to domain object instances, offering type safety.
- Parameters:
prompt- the prompt text to send to the LLM- Returns:
the created object of type T
-
fromTemplate
abstract T fromTemplate(String templateName, Map<String, Object> model)
Create an object of this type from the given template.
- Parameters:
templateName- the name of the template to rendermodel- the model data to use for template rendering- Returns:
the created object of type T
-
fromMessages
abstract T fromMessages(List<Message> messages)
Create an object of the desired type from messages.
- Parameters:
messages- the conversation messages to send to the LLM- Returns:
the created object of type T
-
-
-
-