response

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package response provides response enrichment capabilities for the Superbrain system. It adds healing metadata to successful responses and creates negotiated failure responses for unrecoverable errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildOpenAIErrorResponse

func BuildOpenAIErrorResponse(err error, aggregator *metadata.Aggregator, diagnosis *types.Diagnosis) ([]byte, error)

BuildOpenAIErrorResponse creates an OpenAI-compatible error response with Superbrain metadata.

func ExtractSuperbrainMetadata

func ExtractSuperbrainMetadata(payload []byte) (map[string]interface{}, bool)

ExtractSuperbrainMetadata extracts Superbrain metadata from a response payload.

func GetHealingActions

func GetHealingActions(payload []byte) []map[string]interface{}

GetHealingActions extracts the healing actions from a response payload.

func NegotiatedFailureToJSON

func NegotiatedFailureToJSON(nf *types.NegotiatedFailureResponse) ([]byte, error)

NegotiatedFailureToJSON converts a NegotiatedFailureResponse to JSON bytes.

func NegotiatedFailureToResponse

func NegotiatedFailureToResponse(nf *types.NegotiatedFailureResponse) (switchailocalexecutor.Response, error)

NegotiatedFailureToResponse converts a NegotiatedFailureResponse to an executor Response.

func WasHealed

func WasHealed(payload []byte) bool

WasHealed checks if a response indicates that healing occurred.

Types

type Enricher

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

Enricher provides response enrichment capabilities.

func NewEnricher

func NewEnricher() *Enricher

NewEnricher creates a new response enricher.

func (*Enricher) CreateNegotiatedFailureResponse

func (e *Enricher) CreateNegotiatedFailureResponse(err error, aggregator *metadata.Aggregator, diagnosis *types.Diagnosis) *types.NegotiatedFailureResponse

CreateNegotiatedFailureResponse creates a NegotiatedFailureResponse from an error and metadata.

func (*Enricher) EnrichResponse

EnrichResponse adds healing metadata to a successful response. If no healing actions were taken and includeMetadataOnlyWhenHealed is true, the response is returned unchanged.

func (*Enricher) EnrichResponseWithMetadata

func (e *Enricher) EnrichResponseWithMetadata(resp switchailocalexecutor.Response, healingMeta *types.HealingMetadata) switchailocalexecutor.Response

EnrichResponseWithMetadata adds specific healing metadata to a response.

func (*Enricher) SetIncludeMetadataOnSuccess

func (e *Enricher) SetIncludeMetadataOnSuccess(include bool)

SetIncludeMetadataOnSuccess controls whether to include metadata on successful responses.

func (*Enricher) SetIncludeMetadataOnlyWhenHealed

func (e *Enricher) SetIncludeMetadataOnlyWhenHealed(onlyWhenHealed bool)

SetIncludeMetadataOnlyWhenHealed controls whether to only include metadata when healing occurred.

type StreamChunkEnricher

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

StreamChunkEnricher provides enrichment for streaming responses.

func NewStreamChunkEnricher

func NewStreamChunkEnricher(aggregator *metadata.Aggregator) *StreamChunkEnricher

NewStreamChunkEnricher creates a new stream chunk enricher.

func (*StreamChunkEnricher) EnrichChunk

EnrichChunk enriches a stream chunk with metadata if it's the last chunk. For streaming responses, metadata is typically only added to the final chunk.

func (*StreamChunkEnricher) WrapStreamChannel

func (sce *StreamChunkEnricher) WrapStreamChannel(input <-chan switchailocalexecutor.StreamChunk) <-chan switchailocalexecutor.StreamChunk

WrapStreamChannel wraps a stream channel to add metadata to the final chunk.

Jump to

Keyboard shortcuts

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