openai

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package openai implements the OpenAI-compatible HTTP execution boundary. It classifies transport/protocol failures into stable load error codes and never returns response bodies, request bodies, URLs, or credentials in an Observation.

Index

Constants

View Source
const (

	// MaxSSELineBytes and MaxSSEEventBytes cap transient parser allocations
	// independently of the total response limit. MaxSSELines caps parser work.
	MaxSSELineBytes  int64 = 64 << 10
	MaxSSEEventBytes int64 = 256 << 10
	MaxSSELines      int64 = 32_768
)

Variables

View Source
var (
	ErrSecretSerialization   = errors.New("openai client contains credential material and cannot be serialized")
	ErrInvalidChannel        = errors.New("invalid OpenAI channel configuration")
	ErrUnsupportedProtocol   = errors.New("unsupported OpenAI channel protocol")
	ErrCredentialRequired    = errors.New("OpenAI credential lease is required")
	ErrCredentialUnavailable = errors.New("OpenAI credential is unavailable")
	ErrInvalidTransport      = errors.New("invalid OpenAI HTTP transport")
	ErrInvalidOption         = errors.New("invalid OpenAI client option")
	ErrInvalidRequest        = errors.New("invalid OpenAI request definition")
	ErrClientClosed          = errors.New("OpenAI client is closed")
)

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(channel domain.ChannelSnapshot, lease *credentials.Lease, transport http.RoundTripper, options ...Option) (*Client, error)

NewClient constructs an executor-owned HTTP client. Callers may supply a transport (for proxy/TLS/test configuration), but never an http.Client, so redirect behavior remains under this package's control.

func (*Client) Close

func (client *Client) Close() error

Close is a revocation barrier: it blocks new executions, clears the retained credential, cancels active requests, and waits until their executor frames have completed before returning.

func (*Client) Executor

func (client *Client) Executor(request domain.TestRequest) (load.Executor, error)

func (Client) GoString

func (Client) GoString() string

func (Client) MarshalJSON

func (Client) MarshalJSON() ([]byte, error)

func (*Client) ProbeExecutor

func (client *Client) ProbeExecutor(request domain.TestRequest, classifier ProbeClassifier) (load.Executor, error)

func (Client) String

func (Client) String() string

type FailureResponseEvidence

type FailureResponseEvidence struct {
	RequestIndex uint64
	HTTPStatus   int
	ContentType  string
	RequestID    string
	Body         string
	BodyBytes    uint64
	Truncated    bool
}

FailureResponseEvidence contains only bounded response metadata and a redacted body; it never includes request headers or credentials.

type FailureResponseEvidenceSink

type FailureResponseEvidenceSink func(FailureResponseEvidence)

FailureResponseEvidenceSink receives one safe response snapshot for each request that fails after an HTTP response is available.

type Option

type Option func(*Client) error

func WithFailureResponseEvidence

func WithFailureResponseEvidence(limit int64, sink FailureResponseEvidenceSink) Option

WithFailureResponseEvidence enables opt-in, bounded, redacted capture for failed HTTP responses. The default executor behavior does not retain bodies.

func WithMaxResponseBytes

func WithMaxResponseBytes(limit int64) Option

type ProbeClassifier

type ProbeClassifier func([]byte) (map[string]string, error)

Jump to

Keyboard shortcuts

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