ObjectCreator

Deprecated

Use PromptRunner.Creating instead

Replace with

import com.embabel.agent.api.common.PromptRunner.Creating
PromptRunner.Creating<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 type 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 @Action method that provides access to domain object instances, offering type safety.

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): PromptRunner.Creating<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: CreationExample<T>): PromptRunner.Creating<T>

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

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): PromptRunner.Creating<T>

Exclude the given properties when creating an object.

Link copied to clipboard

Excludes the given properties when creating an object.

Link copied to clipboard

Disables validation of created objects.

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

Include the given properties when creating an object.

Link copied to clipboard

Includes the given properties when creating an object.

Link copied to clipboard

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

Link copied to clipboard
abstract fun withValidation(validation: Boolean = true): PromptRunner.Creating<T>

Set whether to validate created objects.