StructuredRequestConfig

data class StructuredRequestConfig<T>(val default: StructuredRequest<T>? = null, val byProvider: Map<LLMProvider, StructuredRequest<T>> = emptyMap())(source)

Configures structured output behavior. Defines which structures in which modes should be used for each provider when requesting a structured output.

Constructors

Link copied to clipboard
constructor(default: StructuredRequest<T>? = null, byProvider: Map<LLMProvider, StructuredRequest<T>> = emptyMap())

Properties

Link copied to clipboard

A map matching LLMProvider to compatible StructuredRequest definitions. Each provider may require different schema formats. E.g. for JsonStructure this means you have to use the appropriate ai.koog.prompt.structure.json.generator.JsonSchemaGenerator implementation for each provider for StructuredRequest.Native, or fallback to StructuredRequest.Manual

Link copied to clipboard

Fallback StructuredRequest to be used when there's no suitable structure found in byProvider for a requested LLMProvider. Defaults to null, meaning structured output would fail with error in such a case.

Functions

Link copied to clipboard
fun structure(model: LLModel): Structure<T, *>

Retrieves the structured data configuration for a specific large language model (LLM).

Link copied to clipboard
fun updatePrompt(model: LLModel, prompt: Prompt): Prompt

Updates a given prompt to configure structured output using the specified large language model (LLM). Depending on the model's support for structured outputs, the prompt is updated either manually or natively.