structured

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractJSON

func ExtractJSON(text string) (string, error)

ExtractJSON tries to recover a valid JSON object/array from model output. It accepts pure JSON or mixed text with embedded JSON.

Types

type Config

type Config struct {
	// Output must be a non-nil pointer to target value (struct, slice, map, etc).
	Output any

	// MaxAttempts is total attempts (first generation + repairs).
	// If <= 0, default is 3.
	MaxAttempts int

	// BasePrompt allows overriding the initial prompt template.
	// Supported placeholders: {{SCHEMA}}, {{USER_INPUT}}.
	BasePrompt string

	// RepairPrompt allows overriding the self-repair prompt template.
	// Supported placeholders: {{SCHEMA}}, {{ERROR}}, {{LAST_RESPONSE}}, {{USER_INPUT}}.
	RepairPrompt string

	// AllowUnknownFields disables strict unknown-field checks during decode.
	AllowUnknownFields bool
}

type Controller

type Controller[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any](cfg Config) *Controller[T]

func (*Controller[T]) Run

func (c *Controller[T]) Run(ctx context.Context, agent controller.AgentLike[T], input string) (string, error)

Jump to

Keyboard shortcuts

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