requestLLMStructured

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

Sends a message to a Large Language Model (LLM) and requests structured data from the LLM with error correction capabilities. The message becomes part of the current prompt, and the LLM's response is processed to extract structured data.

Return

Result containing the structured response if successful, or an error if parsing failed.

Parameters

message

The content of the message to be sent to the LLM.

examples

Examples of the structured output.

fixingParser

Optional parser to fix generated structured data.