structuredoutput

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package structuredoutput lets LLM text-prompt components accept a JSON Schema that describes the desired response. The component shows a default schema the user edits; the backend validates that it is well-formed JSON before the provider request is fired, and normalizes it to the constraints both providers enforce:

  • Every object node gets "additionalProperties": false.
  • OpenAI strict mode (strict=true) additionally forces every object's "required" to list all of its properties; optional fields are expressed by making their type nullable in the schema itself.
  • Anthropic (strict=false) leaves "required" as the user wrote it.

Index

Constants

View Source
const DefaultSchema = `` /* 264-byte string literal not displayed */

DefaultSchema is the starter JSON Schema shown in the field for the user to edit.

Variables

This section is empty.

Functions

func ConfigField

func ConfigField(name, label, description string) configuration.Field

ConfigField returns the togglable JSON-schema text field for a component.

func Parse

func Parse(raw any) (map[string]any, error)

Parse reads the raw config value (a JSON Schema string) into a schema object. It returns (nil, nil) when the field is unset, so callers can treat structured output as optional. Otherwise it validates that the value is a JSON object that looks like an object schema, so malformed input surfaces at config/Setup time rather than as a provider error.

func Prepare

func Prepare(schema map[string]any, strict bool) map[string]any

Prepare returns a copy of the schema normalized to provider constraints, ready to send. It does not mutate the input.

Types

This section is empty.

Jump to

Keyboard shortcuts

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