Package-level declarations

Types

Link copied to clipboard

Represents a metadata definition for annotated descriptions of a class and its fields. This interface facilitates managing descriptions for classes and their corresponding fields.

Link copied to clipboard
Link copied to clipboard
abstract class StructuredData<TStruct>(val id: String, val examples: List<TStruct>, val schema: LLMParams.Schema) : StructuredDataDefinition

Represents a generic structure for handling data with a specific schema.

Link copied to clipboard

Represents the definition of structured data, enabling content construction and customization.

Link copied to clipboard

An object that provides utilities for formatting structured output prompts.

Link copied to clipboard
data class StructuredResponse<T>(val structure: T, val raw: String)

Represents a container for structured data parsed from raw text.

Link copied to clipboard
class StructureParser(executor: PromptExecutor, fixingModel: LLModel = OpenAIModels.Chat.GPT4o)

A parser for processing structured data that utilizes language models (LLMs) and attempts to correct any errors in the provided content to produce valid structured outputs.

Functions

Link copied to clipboard
suspend fun <T> PromptExecutor.executeStructured(prompt: Prompt, mainModel: LLModel, structure: StructuredData<T>, retries: Int = 1, fixingModel: LLModel = OpenAIModels.Chat.GPT4o): Result<StructuredResponse<T>>

Executes a prompt and ensures the response is properly structured by applying automatic output coercion.

Link copied to clipboard

Executes a given prompt and parses the resulting text, expecting structured data in the response message.

Link copied to clipboard
inline fun <T> TextContentBuilder.structure(language: JsonStructureLanguage, value: T)

Adds a structured representation of the given value to the text content using the specified language.

fun <T> TextContentBuilder.structure(language: JsonStructureLanguage, value: T, serializer: KSerializer<T>)

Adds a structured JSON representation of the given value to the TextContentBuilder.