opt

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ToolkitKey              = "toolkit"
	ContentBlockKey         = "content-block"
	ThinkingKey             = "thinking"
	ThinkingBudgetKey       = "thinking-budget"
	SystemPromptKey         = "system"
	TemperatureKey          = "temperature"
	TopPKey                 = "top-p"
	TopKKey                 = "top-k"
	MaxTokensKey            = "max-tokens"
	StopSequencesKey        = "stop-sequences"
	TaskTypeKey             = "task-type"
	TitleKey                = "title"
	OutputDimensionalityKey = "output-dimensionality"
	SeedKey                 = "seed"
	PresencePenaltyKey      = "presence-penalty"
	FrequencyPenaltyKey     = "frequency-penalty"
	JSONSchemaKey           = "json-schema"
	AfterIdKey              = "after-id"
	BeforeIdKey             = "before-id"
	LimitKey                = "limit"
	OffsetKey               = "offset"
	ProviderKey             = "provider"
	UserIdKey               = "user-id"
	ServiceTierKey          = "service-tier"
	CacheControlKey         = "cache-control"
	OutputConfigKey         = "output-config"
	ToolChoiceKey           = "tool-choice"
	ToolChoiceNameKey       = "tool-choice-name"
	MaxIterationsKey        = "max-iterations"
	LabelKey                = "label"
)

Option keys used across providers

Variables

This section is empty.

Functions

func Apply

func Apply(o ...Opt) (*opts, error)

Apply returns a structure of applied options

Types

type ClientOptFn

type ClientOptFn func(provider string) Opt

ClientOptFn is a function that receives a provider name and returns a provider-specific option. Used by agent-level option dispatchers to defer option resolution until the target provider is known.

type Opt

type Opt func(*opts) error

A generic option type, which can set options on an agent or session

func AddAny

func AddAny(key string, value any) Opt

AddAny appends a value to a typed slice for key. If the key does not exist, a new slice of the value's type is created. If the key exists, the existing value must be a slice of the same element type.

func AddFloat64

func AddFloat64(key string, value float64) Opt

AddFloat64 appends a float64 value for key, preserving any existing values

func AddString

func AddString(key string, value ...string) Opt

AddString appends string values for key, preserving any existing values

func AddUint

func AddUint(key string, value ...uint) Opt

AddUint appends uint values for key, preserving any existing values

func ConvertOptsForClient

func ConvertOptsForClient(o *opts, provider string) ([]Opt, error)

ConvertOptsForClient walks the accumulated client-aware options and resolves them against the given provider name, returning a flat slice of concrete Opts.

func Error

func Error(err error) Opt

Error returns an option that always returns the given error.

func NoOp

func NoOp() Opt

NoOp does nothing

func SetAny

func SetAny(key string, value any) Opt

SetAny sets an arbitrary value for key, replacing any existing values

func SetBool

func SetBool(key string, value bool) Opt

SetBool sets a boolean value for key, replacing any existing values

func SetFloat64

func SetFloat64(key string, value float64) Opt

SetFloat64 sets a float64 value for key, replacing any existing values

func SetString

func SetString(key string, value string) Opt

SetString sets a string value for key, replacing any existing values

func SetUint

func SetUint(key string, value uint) Opt

SetUint sets a uint value for key, replacing any existing values

func WithClient

func WithClient(fn ClientOptFn) Opt

WithClient wraps a ClientOptFn so it can be stored among regular Opts. The returned Opt is a marker; it is not applied immediately. Instead, ConvertOptsForClient resolves it once the target provider is known.

func WithOpts

func WithOpts(options ...Opt) Opt

WithOpts combines multiple options into a single option

func WithProgress

func WithProgress(fn ProgressFn) Opt

WithProgress sets a progress callback function

func WithStream

func WithStream(fn StreamFn) Opt

WithStream sets a streaming callback function. When set, generators that support streaming will deliver text chunks to fn as they arrive, rather than waiting for the complete response.

type Options

type Options interface {
	// Returns true if the key exists
	Has(key string) bool

	// Return a value for key, or nil
	Get(key string) any

	// Get a string value for key
	GetString(key string) string

	// Get a string array for key
	GetStringArray(key string) []string

	// Get a boolean value for key
	GetBool(key string) bool

	// Get a float64 value for key
	GetFloat64(key string) float64

	// Get a uint value for key
	GetUint(key string) uint

	// Return a set of keys as a url.Values
	Query(keys ...string) url.Values
}

Options is the interface for accessing options

type ProgressFn

type ProgressFn func(status string, percent float64)

ProgressFn is a callback function for progress updates status: descriptive status message (e.g., "downloading", "verifying") percent: progress percentage (0-100)

type StreamFn

type StreamFn func(role, text string)

StreamFn is a callback function for streaming text generation. Each invocation receives a role ("assistant" or "thinking") and a text chunk from the model's response as it arrives.

Jump to

Keyboard shortcuts

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