output

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package output provides output strategies for structured text generation. This mirrors the ai-sdk output module (text, object, array, choice, json).

All strategies implement stream.Output so they can be assigned to stream.Input.Output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Array

func Array(opts ArrayOptions) stream.Output

Array generates an array of elements matching the element schema. The model responds with {"elements": [...]} wrapper.

func Choice

func Choice(opts ChoiceOptions) stream.Output

Choice generates one of the predefined choice options. The model responds with {"result": "chosen_option"} wrapper.

func JSON

func JSON(opts JSONOptions) stream.Output

JSON generates unstructured JSON (any valid JSON value).

func Object

func Object(opts ObjectOptions) stream.Output

Object generates a typed object matching the schema.

func Text

func Text() stream.Output

Text generates plain text. This is the default output mode.

Types

type ArrayOptions

type ArrayOptions struct {
	// Element is the schema for array elements.
	Element     *schema.Schema
	Name        string
	Description string
}

ArrayOptions configures array output generation.

type ChoiceOptions

type ChoiceOptions struct {
	Options     []string
	Name        string
	Description string
}

ChoiceOptions configures choice output generation.

type JSONOptions

type JSONOptions struct {
	Name        string
	Description string
}

JSONOptions configures unstructured JSON output generation.

type NoObjectGeneratedError

type NoObjectGeneratedError struct {
	Message      string
	Cause        error
	Text         string
	FinishReason stream.FinishReason
	Usage        stream.Usage
}

NoObjectGeneratedError indicates the model failed to generate a valid object.

func (*NoObjectGeneratedError) Error

func (e *NoObjectGeneratedError) Error() string

func (*NoObjectGeneratedError) Unwrap

func (e *NoObjectGeneratedError) Unwrap() error

type ObjectOptions

type ObjectOptions struct {
	Schema      *schema.Schema
	Name        string
	Description string
}

ObjectOptions configures object output generation.

Jump to

Keyboard shortcuts

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