executor

package
v0.2.37 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestIDFromContext added in v0.2.6

func RequestIDFromContext(ctx context.Context) string

func WithAllowedProviders added in v0.2.21

func WithAllowedProviders(ctx context.Context, providers []string) context.Context

func WithRequestID added in v0.2.6

func WithRequestID(ctx context.Context, id string) context.Context

Types

type AttemptHook added in v0.2.6

type AttemptHook func(accounts.RequestAttempt)

type ChatExecutor

type ChatExecutor struct {
	Pool        *accounts.Pool
	WorkerKey   string
	HTTPClient  *http.Client
	Providers   *providerRegistry
	OnAttempt   AttemptHook
	MaxAttempts int
}

func NewChatExecutor

func NewChatExecutor(pool *accounts.Pool, workerKey string) ChatExecutor

func (ChatExecutor) ChatNonStream

func (e ChatExecutor) ChatNonStream(ctx context.Context, req translate.ChatRequest, prefer, providerFilter string) (ChatResult, error)

func (ChatExecutor) ChatStreamProxy

func (e ChatExecutor) ChatStreamProxy(ctx context.Context, req translate.ChatRequest, prefer, providerFilter string) (StreamResult, error)

func (ChatExecutor) ObserveStreamFailure added in v0.2.28

func (e ChatExecutor) ObserveStreamFailure(accountID string, err error, model string)

ObserveStreamFailure applies a post-headers streaming failure to the pool. Upstream can answer 200 and then fail inside the SSE body, which happens after the executor already returned a successful StreamResult; the relay error is the first place the failure is observable. Same-account retry is impossible at that point (bytes are on the wire), so this only records the classified state for the next request's scheduling.

type ChatResult

type ChatResult struct {
	Model            string
	Content          string
	Reasoning        string
	ToolCalls        json.RawMessage
	FinishReason     string
	PromptTokens     int
	CompletionTokens int
	CacheReadTokens  *int
	CacheWriteTokens *int
	CachedTokens     *int
	UsageSource      string
	Credits          *float64
	AccountID        string
	Provider         string
	AttemptCount     int
	RawNote          string
}

type StreamResult added in v0.2.6

type StreamResult struct {
	Response     *http.Response
	AccountID    string
	Provider     string
	AttemptCount int
	TTFBMs       int
}

Jump to

Keyboard shortcuts

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