requestLLMStructured

Sends a request to LLM and gets a structured response.

Parameters

config

A configuration defining structures and behavior.

See also


open suspend fun <T> requestLLMStructured(serializer: KSerializer<T>, examples: List<T> = emptyList(), fixingParser: StructureFixingParser? = null): Result<StructuredResponse<T>>(source)

Sends a request to LLM and gets a structured response.

This is a simple version of the full requestLLMStructured. Unlike the full version, it does not require specifying struct definitions and structured output modes manually. It attempts to find the best approach to provide a structured output based on the defined model capabilities.

Parameters

serializer

Serializer for the requested structure type.

examples

Optional list of examples in case manual mode will be used. These examples might help the model to understand the format better.

fixingParser

Optional parser that handles malformed responses by using an auxiliary LLM to intelligently fix parsing errors. When specified, parsing errors trigger additional LLM calls with error context to attempt correction of the structure format.


inline suspend fun <T> requestLLMStructured(examples: List<T> = emptyList(), fixingParser: StructureFixingParser? = null): Result<StructuredResponse<T>>(source)

Sends a request to LLM and gets a structured response.

This is a simple version of the full requestLLMStructured. Unlike the full version, it does not require specifying struct definitions and structured output modes manually. It attempts to find the best approach to provide a structured output based on the defined model capabilities.

Parameters

T

The structure to request.

examples

Optional list of examples in case manual mode will be used. These examples might help the model to understand the format better.

fixingParser

Optional parser that handles malformed responses by using an auxiliary LLM to intelligently fix parsing errors. When specified, parsing errors trigger additional LLM calls with error context to attempt correction of the structure format.