output

package
v0.36.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package output provides parsers for structured LLM output.

Contains JSON and XML parsers that handle common LLM output artifacts like markdown code blocks, conversational text, and malformed markup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONParser

type JSONParser[T any] struct{}

JSONParser implements schema.OutputParser[T] for JSON-formatted LLM output. It is designed to be robust against common LLM artifacts like markdown fences and conversational preambles/postambles.

func NewJSONParser

func NewJSONParser[T any]() *JSONParser[T]

NewJSONParser creates a new JSON parser for the specified type.

func (*JSONParser[T]) Parse

func (p *JSONParser[T]) Parse(ctx context.Context, text string) (T, error)

Parse extracts JSON from the raw LLM output and unmarshals it into type T.

type XMLParser

type XMLParser[T any] struct {
	RootTag string
}

func NewXMLParser

func NewXMLParser[T any](rootTag string) *XMLParser[T]

func (*XMLParser[T]) Parse

func (p *XMLParser[T]) Parse(ctx context.Context, text string) (T, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL