ai_proxy_multi

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveHealthCheck

type ActiveHealthCheck struct {
	Type                   string               `json:"type,omitempty"`
	Timeout                float64              `json:"timeout,omitempty"`
	Concurrency            int                  `json:"concurrency,omitempty"`
	Host                   string               `json:"host,omitempty"`
	Port                   int                  `json:"port,omitempty"`
	HTTPPath               string               `json:"http_path,omitempty"`
	HTTPSVerifyCertificate *bool                `json:"https_verify_certificate,omitempty"`
	Healthy                HealthyCheckPolicy   `json:"healthy"`
	Unhealthy              UnhealthyCheckPolicy `json:"unhealthy"`
	ReqHeaders             []string             `json:"req_headers,omitempty"`
}

type Auth

type Auth struct {
	Header map[string]string  `json:"header,omitempty"`
	Query  map[string]string  `json:"query,omitempty"`
	AWS    *ai_auth.AWSConfig `json:"aws,omitempty"`
	GCP    *ai_auth.GCPConfig `json:"gcp,omitempty"`
}

type Balancer

type Balancer struct {
	Algorithm string `json:"algorithm,omitempty"`
	HashOn    string `json:"hash_on,omitempty"`
	Key       string `json:"key,omitempty"`
}

type Config

type Config struct {
	Balancer                 Balancer   `json:"balancer"`
	Instances                []Instance `json:"instances"`
	Logging                  Logging    `json:"logging"`
	FallbackStrategy         any        `json:"fallback_strategy,omitempty"`
	MaxRetries               *int       `json:"max_retries,omitempty"`
	RetryOnFailureWithinMS   int        `json:"retry_on_failure_within_ms,omitempty"`
	Timeout                  int        `json:"timeout,omitempty"`
	MaxReqBodySize           int64      `json:"max_req_body_size,omitempty"`
	MaxStreamDurationMS      int        `json:"max_stream_duration_ms,omitempty"`
	MaxResponseBytes         int64      `json:"max_response_bytes,omitempty"`
	Keepalive                *bool      `json:"keepalive,omitempty"`
	KeepaliveTimeout         int        `json:"keepalive_timeout,omitempty"`
	KeepalivePool            int        `json:"keepalive_pool,omitempty"`
	StreamingFlushIntervalMS *int       `json:"streaming_flush_interval_ms,omitempty"`
	SSLVerify                *bool      `json:"ssl_verify,omitempty"`
}

func (*Config) DescribeResponseMode

func (*Config) DescribeResponseMode() (base.ResponseModeDescriptor, error)

DescribeResponseMode conservatively includes bounded and streaming modes; each selected provider instance may choose SSE at request time.

type HealthChecks

type HealthChecks struct {
	Active ActiveHealthCheck `json:"active"`
}

type HealthyCheckPolicy

type HealthyCheckPolicy struct {
	Interval     int   `json:"interval,omitempty"`
	HTTPStatuses []int `json:"http_statuses,omitempty"`
	Successes    int   `json:"successes,omitempty"`
}

type Instance

type Instance struct {
	Name         string         `json:"name"`
	Provider     string         `json:"provider"`
	ProviderConf map[string]any `json:"provider_conf,omitempty"`
	Priority     int            `json:"priority,omitempty"`
	Weight       int            `json:"weight"`
	Auth         Auth           `json:"auth"`
	Options      map[string]any `json:"options,omitempty"`
	Override     Override       `json:"override"`
	Checks       *HealthChecks  `json:"checks,omitempty"`
}

type LLMOptions

type LLMOptions struct {
	MaxTokens int `json:"max_tokens,omitempty"`
}

type Logging

type Logging struct {
	Summaries bool `json:"summaries,omitempty"`
	Payloads  bool `json:"payloads,omitempty"`
}

type Override

type Override struct {
	Endpoint                 string         `json:"endpoint,omitempty"`
	LLMOptions               LLMOptions     `json:"llm_options"`
	RequestBody              map[string]any `json:"request_body,omitempty"`
	RequestBodyForceOverride *bool          `json:"request_body_force_override,omitempty"`
}

type Plugin

type Plugin struct {
	base.BasePlugin
	// contains filtered or unexported fields
}

func (*Plugin) Config

func (p *Plugin) Config() any

func (*Plugin) Handler

func (p *Plugin) Handler(next http.Handler) http.Handler

Handler is retained only for direct callers that have not installed the explicit request/response phases. Route assembly uses the interfaces above.

func (*Plugin) Init

func (p *Plugin) Init() error

func (*Plugin) PostInit

func (p *Plugin) PostInit() error

func (*Plugin) RunExclusiveProtocol

RunExclusiveProtocol executes the selected AI instance once and marks its response as upstream-owned before any provider bytes can be committed.

func (*Plugin) RunRequestPhase

func (p *Plugin) RunRequestPhase(w http.ResponseWriter, r *http.Request) base.RequestPhaseResult

RunRequestPhase parses the client document, selects the initial provider instance, and publishes one request-local execution state. Provider I/O is deferred to RunExclusiveProtocol until all before-proxy hooks have run.

func (*Plugin) Stop

func (p *Plugin) Stop()

type UnhealthyCheckPolicy

type UnhealthyCheckPolicy struct {
	Interval     int   `json:"interval,omitempty"`
	HTTPStatuses []int `json:"http_statuses,omitempty"`
	HTTPFailures int   `json:"http_failures,omitempty"`
	TCPFailures  int   `json:"tcp_failures,omitempty"`
	Timeouts     int   `json:"timeouts,omitempty"`
}

Jump to

Keyboard shortcuts

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