ObjectCreator

interface ObjectCreator<T>

Interface to create objects of the given type from a prompt or messages. Allows setting strongly typed examples.

Functions

Link copied to clipboard
abstract fun fromMessages(messages: List<Message>): T

Create an object of the desired typed from messages

Link copied to clipboard
open fun fromPrompt(prompt: String): T

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

Link copied to clipboard
abstract fun fromTemplate(templateName: String, model: Map<String, Any>): T

Create an object of this type from the given template

Link copied to clipboard
open fun withExample(description: String, value: T): ObjectCreator<T>

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

Link copied to clipboard
open fun withExamples(vararg examples: ObjectCreationExample<T>): ObjectCreator<T>

Convenience method to add multiple examples using vararg syntax. Each example will be added as a prompt contributor to improve LLM output quality.

Convenience method to add multiple examples from a list or other iterable. Each example will be added as a prompt contributor to improve LLM output quality.

Link copied to clipboard
open fun withoutProperties(vararg properties: String): ObjectCreator<T>

Excludes the given properties when creating an object.

Link copied to clipboard

Excludes the given properties when creating an object.

Link copied to clipboard
open fun withProperties(vararg properties: String): ObjectCreator<T>

Includes the given properties when creating an object.

Link copied to clipboard
fun <T> ObjectCreator<T>.withProperties(vararg properties: KProperty1<T, Any>): ObjectCreator<T>

Includes the given properties when creating an object.

Link copied to clipboard

Adds a filter that determines which properties are to be included when creating an object.