executor

package
v7.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PinnedAuthMetadataKey locks execution to a specific auth ID.
	PinnedAuthMetadataKey = "pinned_auth_id"
	// SelectedAuthMetadataKey stores the auth ID selected by the scheduler.
	SelectedAuthMetadataKey = "selected_auth_id"
	// SelectedAuthCallbackMetadataKey carries an optional callback invoked with the selected auth ID.
	SelectedAuthCallbackMetadataKey = "selected_auth_callback"
	// ExecutionSessionMetadataKey identifies a long-lived downstream execution session.
	ExecutionSessionMetadataKey = "execution_session_id"
	// StickyRouteMetadataKey carries the caller-scoped sticky routing key for built-in affinity.
	StickyRouteMetadataKey = "sticky_route_key"
	// DisallowFreeAuthMetadataKey instructs auth selection to skip known free-tier credentials.
	DisallowFreeAuthMetadataKey = "disallow_free_auth"
)
View Source
const ReasoningEffortMetadataKey = "reasoning_effort"

ReasoningEffortMetadataKey stores the client-requested reasoning effort for usage logs.

View Source
const RequestPathMetadataKey = "request_path"

RequestPathMetadataKey stores the inbound HTTP request path (e.g. "/v1/images/generations") in Options.Metadata. It is optional and may be absent for non-HTTP executions.

View Source
const RequestedModelMetadataKey = "requested_model"

RequestedModelMetadataKey stores the client-requested model name in Options.Metadata.

Variables

This section is empty.

Functions

func DownstreamWebsocket

func DownstreamWebsocket(ctx context.Context) bool

DownstreamWebsocket reports whether the current request originates from a downstream websocket connection.

func ResponseFormatOrSource

func ResponseFormatOrSource(opts Options) sdktranslator.Format

ResponseFormatOrSource returns the response target format for an execution. It resolves to ResponseFormat when set, falling back to SourceFormat so that callers built against the historical single-protocol API keep working.

func WithDownstreamWebsocket

func WithDownstreamWebsocket(ctx context.Context) context.Context

WithDownstreamWebsocket marks the current request as coming from a downstream websocket connection.

Types

type Options

type Options struct {
	// Stream toggles streaming mode.
	Stream bool
	// Alt carries optional alternate format hint (e.g. SSE JSON key).
	Alt string
	// Headers are forwarded to the provider request builder.
	Headers http.Header
	// Query contains optional query string parameters.
	Query url.Values
	// OriginalRequest preserves the inbound request bytes prior to translation.
	OriginalRequest []byte
	// SourceFormat identifies the inbound schema.
	SourceFormat sdktranslator.Format
	// ResponseFormat identifies the downstream response schema expected by the
	// caller. When empty, responses are produced in SourceFormat to preserve
	// the historical single-protocol behaviour. Plugin-issued executions that
	// cross-translate between protocols (e.g. openai -> claude) set this field
	// so executor pipelines know which target schema to emit.
	ResponseFormat sdktranslator.Format
	// Metadata carries extra execution hints shared across selection and executors.
	Metadata map[string]any
}

Options controls execution behavior for both streaming and non-streaming calls.

type Request

type Request struct {
	// Model is the upstream model identifier after translation.
	Model string
	// Payload is the provider specific JSON payload.
	Payload []byte
	// Format represents the provider payload schema.
	Format sdktranslator.Format
	// Metadata carries optional provider specific execution hints.
	Metadata map[string]any
}

Request encapsulates the translated payload that will be sent to a provider executor.

type Response

type Response struct {
	// Payload is the provider response in the executor format.
	Payload []byte
	// Metadata exposes optional structured data for translators.
	Metadata map[string]any
	// Headers carries upstream HTTP response headers for passthrough to clients.
	Headers http.Header
}

Response wraps either a full provider response or metadata for streaming flows.

type StatusError

type StatusError interface {
	error
	StatusCode() int
}

StatusError represents an error that carries an HTTP-like status code. Provider executors should implement this when possible to enable better auth state updates on failures (e.g., 401/402/429).

type StreamChunk

type StreamChunk struct {
	// Payload is the raw provider chunk payload.
	Payload []byte
	// Err reports any terminal error encountered while producing chunks.
	Err error
}

StreamChunk represents a single streaming payload unit emitted by provider executors.

type StreamResult

type StreamResult struct {
	// Headers carries upstream HTTP response headers from the initial connection.
	Headers http.Header
	// Chunks is the channel of streaming payload units.
	Chunks <-chan StreamChunk
}

StreamResult wraps the streaming response, providing both the chunk channel and the upstream HTTP response headers captured before streaming begins.

Jump to

Keyboard shortcuts

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