Help us shape the future of Go! Take the 2026 Go Developer Survey

transformers

package
v1.30.6 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package transformers contains SDK-owned response transformations. Presentation and output formats belong to pkg/custom and its internal rendering helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompletedImageResult added in v1.25.0

func CompletedImageResult(ctx context.Context, event gjson.Result) (gjson.Result, error)

CompletedImageResult selects the final image bytes into the same data array used by nonstreaming generation and editing. It does not write files or handle previews.

func Identity

func Identity(_ context.Context, value gjson.Result) (gjson.Result, error)

Identity preserves the original response, including its raw JSON bytes.

func ImageGenerationResult added in v1.24.0

func ImageGenerationResult(ctx context.Context, event gjson.Result) (gjson.Result, error)

ImageGenerationResult retains the generation-only contract for existing callers.

func ProjectAudioResponse added in v1.23.0

func ProjectAudioResponse(value gjson.Result, route Route) (readable.StreamEvent, bool)

ProjectAudioResponse separates a transcript from its metadata for readable presentation. Native text and subtitle bodies reach this boundary as strings. The original value remains available to every explicit data format.

func ProjectAudioStream added in v1.23.0

func ProjectAudioStream(value gjson.Result, route Route) (readable.StreamEvent, bool)

ProjectAudioStream selects ordinary transcription deltas and final snapshots. Diarized segments retain their complete structured representation: segment deltas cannot safely be reconciled with a final transcript by position alone.

func ProjectTextStream added in v1.22.0

func ProjectTextStream(value gjson.Result, route Route) (readable.StreamEvent, bool)

ProjectTextStream selects text components without modifying the API event. Unknown content stays in Details; a false result preserves the complete event. The caller applies this only to readable output, never explicit data formats.

func StreamFailure added in v1.22.0

func StreamFailure(value gjson.Result, route Route) string

StreamFailure classifies ordinary SSE results before projection or extraction. Messages are fixed API classifications; the caller separately preserves the original event, including error details, for every presentation format.

func SummarizeResource added in v1.21.0

func SummarizeResource(ctx context.Context, value gjson.Result, route Route) (gjson.Result, bool, error)

SummarizeResource projects known list/get records without modifying API data. A zero summary asks the presenter to show the full value. Omitted reports whether the projection hides fields; presentation owns any explanatory hint.

Types

type OutputKind

type OutputKind string

OutputKind identifies the successful-response boundary being presented.

const (
	OutputUnspecified OutputKind = ""
	OutputResponse    OutputKind = "response"
	OutputPageItem    OutputKind = "page_item"
	OutputStreamEvent OutputKind = "stream_event"
)

type Route

type Route struct {
	Operation  string
	OutputKind OutputKind
}

Route identifies an operation independently of its presentation format.

type StreamCompletionState added in v1.22.0

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

StreamCompletionState remembers only observed API progress, not event bodies. It detects clean EOF after an unfinished result even when transport framing reports no error. Empty streams and wholly unfamiliar events remain unchanged.

func (*StreamCompletionState) CompletionError added in v1.22.0

func (s *StreamCompletionState) CompletionError(route Route) string

func (*StreamCompletionState) Observe added in v1.22.0

func (s *StreamCompletionState) Observe(value gjson.Result, route Route)

type Transformer

type Transformer func(context.Context, gjson.Result) (gjson.Result, error)

Transformer changes one response or iterator value before presentation. Implementations must respect cancellation and must not consume other values.

func Select

func Select(route Route) Transformer

Select is the SDK-owned hook for command-specific default transformations. Only known API fields are summarized; unfamiliar routes preserve their values.

Jump to

Keyboard shortcuts

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