requestparams

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package requestparams applies operator-configured request parameters to translated inference requests. A virtual model or model policy may carry two parameter sets: defaults, filled in only when the client omitted the key, and forced params, which replace the client's value. Keys use Chat Completions spelling; provider adapters translate them exactly as they translate client-sent values.

Index

Constants

View Source
const (
	MaxKeys   = 64
	MaxKeyLen = 64
	MaxBytes  = 16 << 10
)

Limits bounding a configured set, so a row cannot grow a request body without bound or stall validation.

Variables

This section is empty.

Functions

func ApplyChat

func ApplyChat(req *core.ChatRequest, defaults, params Set) (*core.ChatRequest, error)

ApplyChat returns req with defaults filled in and params forced. The request is never mutated: the result is req itself when both sets are empty and a shallow copy otherwise.

func ApplyResponses

func ApplyResponses(req *core.ResponsesRequest, defaults, params Set) (*core.ResponsesRequest, error)

ApplyResponses is ApplyChat for the Responses API. Keys keep Chat Completions spelling: any token-limit spelling sets max_output_tokens. Chat members the Responses API rejects are skipped, response_format and verbosity included: a format for this API is set through text.

func Disjoint

func Disjoint(defaults, params Set) error

Disjoint rejects a key configured in both sets of one row, where the forced value would silently make the default dead.

Types

type Overrides

type Overrides struct {
	ReasoningEffort string
	Defaults        Set
	Params          Set
}

Overrides is everything the operator forces onto one provider attempt: the reasoning effort and both parameter sets, already merged along the route the request took.

func (Overrides) IsZero

func (o Overrides) IsZero() bool

IsZero reports whether nothing is configured.

func (Overrides) Layer

func (o Overrides) Layer(over Overrides) Overrides

Layer returns o with the deeper over applied on top: a non-empty effort replaces, and parameter sets merge per key with over winning. Precedence holds across the two sets: a key over configures as a default stops being forced by a shallower row, and one it forces stops being a shallower row's default.

type Set

type Set map[string]json.RawMessage

Set maps body-level parameter names to their JSON values. A nil value in a forced set removes the key from the request.

func Clone

func Clone(set Set) Set

Clone deep-copies a set so stored rows are never shared with callers.

func FromAny

func FromAny(values map[string]any) (Set, error)

FromAny encodes a decoded YAML or JSON object into a set.

func Merge

func Merge(base, over Set) Set

Merge returns base with over's keys added, over winning on conflict. Sets are treated as immutable: the result shares no map with either input when both are non-empty, and is the non-empty input otherwise.

func Normalize

func Normalize(field string, set Set, allowNull bool) (Set, error)

Normalize validates a configured set and returns it in canonical form: trimmed keys, compact values, and nil for an empty set. allowNull admits null values, which a forced set uses to strip a key. field names the setting in messages.

Jump to

Keyboard shortcuts

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