responses

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package responses implements the provider-neutral Responses API wire codec.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRequestBody

func BuildRequestBody(req core.Request, dialect Dialect) ([]byte, error)

BuildRequestBody encodes a stateless streaming Responses API request.

func ConsumeStream

func ConsumeStream(ctx context.Context, body io.Reader, ch chan<- core.AssistantEvent, provider, model string)

consumeStream parses Responses API SSE and emits normalized AssistantEvents.

func ConsumeStreamSanitized

func ConsumeStreamSanitized(ctx context.Context, body io.Reader, ch chan<- core.AssistantEvent, provider, model string)

ConsumeStreamSanitized parses a Responses stream without exposing upstream error messages. Private compatibility backends can echo request metadata in SSE errors, so their adapters use this stricter boundary.

func ConsumeStreamSanitizedWithPriority added in v0.36.0

func ConsumeStreamSanitizedWithPriority(ctx context.Context, body io.Reader, ch chan<- core.AssistantEvent, provider, model string, requestedPriority bool)

ConsumeStreamSanitizedWithPriority is ConsumeStreamWithPriority without exposing upstream error messages.

func ConsumeStreamWithPriority added in v0.36.0

func ConsumeStreamWithPriority(ctx context.Context, body io.Reader, ch chan<- core.AssistantEvent, provider, model string, requestedPriority bool)

ConsumeStreamWithPriority parses a Responses stream and records whether the request asked for the priority tier when the response omits its tier echo.

func MapReasoningEffort

func MapReasoningEffort(level string, allowed []string) string

MapReasoningEffort maps Moa's effective thinking level to an OpenAI reasoning effort. Some models, including GPT-6 Astra, also support max.

func ParseTextSignature

func ParseTextSignature(sig string) (id, phase string)

parseTextSignature decodes a TextSignature blob back into id/phase. Tolerates empty/legacy values.

func RequestsPriority added in v0.36.0

func RequestsPriority(req core.Request, dialect Dialect) bool

RequestsPriority reports whether BuildRequestBody will request the premium Responses service tier. Providers pass this to stream consumption as the fallback when an upstream response omits its service_tier echo.

Types

type Dialect

type Dialect struct {
	Provider                         string
	Model                            string
	SupportsDocuments                bool
	SupportsMaxOutputTokens          bool
	SupportsParallelToolCalls        bool
	SupportsPromptCacheKey           bool
	SupportsExplicitCacheBreakpoints bool
	SupportsServiceTier              bool
	AllowedReasoningEfforts          []string
}

Dialect describes the validated Responses API capabilities of a transport. It intentionally contains protocol features only; URLs, credentials and retry policies stay in the owning provider.

Jump to

Keyboard shortcuts

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