StructureFixingParser
class StructureFixingParser(val fixingModel: LLModel, val retries: Int, fixingPrompt: (builder: PromptBuilder, content: String, structure: StructuredData<*, *>, exception: SerializationException) -> PromptBuilder = ::defaultFixingPrompt)(source)
Helper fixing parser for handling malformed structured data that uses LLMs to attempt to correct any errors in the provided content to produce valid structured outputs.
Constructors
Link copied to clipboard
constructor(fixingModel: LLModel, retries: Int, fixingPrompt: (builder: PromptBuilder, content: String, structure: StructuredData<*, *>, exception: SerializationException) -> PromptBuilder = ::defaultFixingPrompt)
Types
Functions
Link copied to clipboard
suspend fun <T> parse(executor: PromptExecutor, 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.