options

package
v1.111.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ModelOptions

type ModelOptions struct {
	// contains filtered or unexported fields
}

func Apply added in v1.94.0

func Apply(opts ...Opt) ModelOptions

Apply builds a ModelOptions from a list of Opts, skipping nil entries. It centralises the accumulation loop that every provider constructor otherwise repeats.

func (*ModelOptions) Gateway

func (c *ModelOptions) Gateway() string

func (*ModelOptions) GeneratingTitle

func (c *ModelOptions) GeneratingTitle() bool

func (*ModelOptions) MaxTokens

func (c *ModelOptions) MaxTokens() int64

func (*ModelOptions) ModelsDevStore added in v1.59.0

func (c *ModelOptions) ModelsDevStore() *modelsdev.Store

func (*ModelOptions) NoThinking added in v1.35.0

func (c *ModelOptions) NoThinking() bool

func (*ModelOptions) OpenAIVendor added in v1.104.0

func (c *ModelOptions) OpenAIVendor() bool

OpenAIVendor reports whether the model this ModelOptions was built for is a genuine OpenAI vendor endpoint (as opposed to a third-party provider that merely speaks the OpenAI-compatible wire protocol, e.g. xai/mistral). It is set exclusively by WithOpenAIVendor, which pkg/model/provider's factory calls after applyProviderDefaults has resolved custom providers and built-in aliases — never by user-controllable config (YAML/provider_opts cannot reach this field). The OpenAI client trusts it for gating OpenAI-only wire behavior (e.g. gpt-5.6's real "none" reasoning effort) that must not leak onto an OpenAI-compatible alias for a different vendor.

func (*ModelOptions) Providers

func (c *ModelOptions) Providers() map[string]latest.ProviderConfig

func (*ModelOptions) StructuredOutput

func (c *ModelOptions) StructuredOutput() *latest.StructuredOutput

func (*ModelOptions) TransportWrapper added in v1.79.0

func (c *ModelOptions) TransportWrapper() func(http.RoundTripper) http.RoundTripper

TransportWrapper returns the HTTP transport wrapper function registered via WithHTTPTransportWrapper, or nil if none was set.

func (*ModelOptions) WrapTransport added in v1.94.0

func (c *ModelOptions) WrapTransport(ctx context.Context, client *http.Client)

WrapTransport applies the registered transport wrapper (if any) to client's transport in place. A wrapper that returns nil is treated as a no-op and the original transport is kept (with a warning). No-op when client is nil or no wrapper is registered.

type Opt

type Opt func(*ModelOptions)

func FromModelOptions

func FromModelOptions(m ModelOptions) []Opt

FromModelOptions converts a concrete ModelOptions value into a slice of Opt configuration functions. Later Opts override earlier ones when applied.

func WithGateway

func WithGateway(gateway string) Opt

func WithGeneratingTitle

func WithGeneratingTitle() Opt

func WithHTTPTransportWrapper added in v1.79.0

func WithHTTPTransportWrapper(fn func(base http.RoundTripper) http.RoundTripper) Opt

WithHTTPTransportWrapper registers a function that wraps the HTTP transport used by provider clients (Anthropic, OpenAI, and Gemini with the Gemini API backend). The function receives the transport that docker-agent built (including OTel instrumentation, SSE decompression fix, and Desktop proxy support) and must return a new RoundTripper that delegates to it. The wrapper is applied in both direct mode and gateway/proxy mode.

Call-frequency note: in direct mode the wrapper is invoked once at client construction time; in gateway mode it is invoked on every LLM request (because gateway clients are rebuilt on each call to refresh short-lived auth tokens). Wrappers with per-call side effects (metrics, token rotation) will therefore be called more frequently in gateway mode.

Limitations:

  • OpenAI clients configured with transport=websocket bypass the HTTP transport layer entirely; the wrapper is not applied in that mode.
  • Gemini clients using the Vertex AI backend (project/location config or GOOGLE_GENAI_USE_VERTEXAI) rely on the genai SDK's default HTTP client; the wrapper is not applied and a warning is logged.

The wrapper function must return a non-nil RoundTripper; returning nil is a no-op (a warning is logged and the original transport is kept).

Example — inject a bearer token on every outbound LLM request:

options.WithHTTPTransportWrapper(func(base http.RoundTripper) http.RoundTripper {
    return &bearerTransport{token: myToken, base: base}
})

func WithMaxTokens

func WithMaxTokens(maxTokens int64) Opt

func WithModelsDevStore added in v1.59.0

func WithModelsDevStore(store *modelsdev.Store) Opt

func WithNoThinking added in v1.35.0

func WithNoThinking() Opt

func WithOpenAIVendor added in v1.104.0

func WithOpenAIVendor(v bool) Opt

WithOpenAIVendor records the trusted, internally-resolved "genuine OpenAI vendor" bit (see ModelOptions.OpenAIVendor). It is meant to be called exactly once, by pkg/model/provider's Registry after applyProviderDefaults has resolved custom providers and built-in aliases — not from user config, since no YAML/provider_opts key can invoke a Go option constructor.

func WithProviders

func WithProviders(providers map[string]latest.ProviderConfig) Opt

func WithStructuredOutput

func WithStructuredOutput(structuredOutput *latest.StructuredOutput) Opt

Jump to

Keyboard shortcuts

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