responseformat

package
v0.0.0-beta Latest Latest
Warning

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

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

Documentation

Overview

Package responseformat defines structured output constraints for LLM responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResponseFormat

type ResponseFormat struct {
	// Type is one of "text", "json_object", "json_schema".
	Type Type `yaml:"type"`
	// Name identifies the schema (required by OpenAI for json_schema).
	Name string `yaml:"name"`
	// Schema is the JSON Schema as a Go map (required for json_schema).
	Schema map[string]any `yaml:"schema"`
	// Strict enables strict schema adherence when supported (OpenAI, OpenRouter).
	Strict bool `yaml:"strict"`
}

ResponseFormat constrains the LLM's response to a specific format.

func (*ResponseFormat) EffectiveName

func (r *ResponseFormat) EffectiveName() string

EffectiveName returns the schema name, defaulting to "response" when empty. OpenAI requires a non-empty name for json_schema; others ignore it.

type Type

type Type string

Type enumerates the allowed response format types.

const (
	Text       Type = "text"
	JSONObject Type = "json_object"
	JSONSchema Type = "json_schema"
)

Jump to

Keyboard shortcuts

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