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.

    • Constructor Detail

    • 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 example
        value - 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

      • withValidation

         abstract PromptRunner.Creating<T> withValidation(Boolean validation)

        Set whether to validate created objects.

        Parameters:
        validation - true to validate created objects; false otherwise.
        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 render
        model - 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