StructureParser

class StructureParser(executor: PromptExecutor, fixingModel: LLModel = OpenAIModels.Chat.GPT4o)(source)

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.

Constructors

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

Functions

Link copied to clipboard
suspend fun <T> parse(structure: StructuredData<T>, content: String): T

Parses the given content string into an instance of the specified type using the provided structured data schema. If the initial parsing fails, attempts to fix the content based on the error and retries parsing.