Documentation
¶
Index ¶
- Constants
- Variables
- func EncodeResultJSON(result AttemptProxyResult) ([]byte, error)
- func EncodeResultJSONWithin(result AttemptProxyResult, maxBytes int) ([]byte, error)
- func ProviderPathAllowed(method, path string) bool
- func WithAttemptResultWriter(ctx context.Context, writer AttemptResultWriter) context.Context
- func WithMeta(ctx context.Context, meta AttemptProxyMeta) context.Context
- type AttemptProxyMeta
- type AttemptProxyResult
- type AttemptResultWriter
- type AttemptTraceBodyWire
- type AttemptTraceWire
- type BoundAttempt
- type ChannelAutoDisableTrigger
- type ChannelRef
- type ChannelSource
- type ExecutionMode
- type ResultKind
Constants ¶
View Source
const ( EndpointPath = "/internal/agent/attempt" HeaderMode = "X-Vaala-Attempt-Mode" ModeControl = "control" ModeResponse = "response" MaxResultWireBytes = 48 * 1024 MaxAutoDisableTriggersPerResult = 1 )
View Source
const ( SourceAdmin ChannelSource = "admin" SourcePrivate ChannelSource = "private" ChannelAutoDisableReasonConsecutiveErrors = "consecutive_errors" ModeNative ExecutionMode = "native" ModePassthrough ExecutionMode = "passthrough" ModeLegacy ExecutionMode = "legacy" ResultSucceeded ResultKind = "succeeded" ResultProviderFailed ResultKind = "provider_failed" ResultExecutionRejected ResultKind = "execution_rejected" ResultProxyRejected ResultKind = "proxy_rejected" ResultCommitUncertain ResultKind = "commit_uncertain" ResultCanceled ResultKind = "canceled" )
Variables ¶
View Source
var ErrInvalidContract = errors.New("attempt proxy contract invalid")
View Source
var ErrResultTooLarge = errors.New("attempt proxy result too large")
Functions ¶
func EncodeResultJSON ¶
func EncodeResultJSON(result AttemptProxyResult) ([]byte, error)
EncodeResultJSON encodes a bounded result payload for the explicit Result frame carried by the tunnel stream.
func EncodeResultJSONWithin ¶ added in v0.0.14
func EncodeResultJSONWithin(result AttemptProxyResult, maxBytes int) ([]byte, error)
EncodeResultJSONWithin applies the negotiated tunnel Result payload limit.
func ProviderPathAllowed ¶
func WithAttemptResultWriter ¶ added in v0.0.14
func WithAttemptResultWriter(ctx context.Context, writer AttemptResultWriter) context.Context
Types ¶
type AttemptProxyMeta ¶
type AttemptProxyMeta struct {
Attempt BoundAttempt `json:"attempt"`
RequestPath string `json:"request_path"`
}
func MetaFromContext ¶
func MetaFromContext(ctx context.Context) (AttemptProxyMeta, bool)
func (AttemptProxyMeta) Validate ¶
func (meta AttemptProxyMeta) Validate() error
type AttemptProxyResult ¶
type AttemptProxyResult struct {
Kind ResultKind `json:"kind"`
PromptTokens int `json:"prompt_tokens,omitempty"`
CompletionTokens int `json:"completion_tokens,omitempty"`
CacheReadTokens int `json:"cache_read_tokens,omitempty"`
CacheWriteTokens int `json:"cache_write_tokens,omitempty"`
FirstResponseMs int `json:"first_response_ms,omitempty"`
UpstreamModel string `json:"upstream_model,omitempty"`
TokenSource string `json:"token_source,omitempty"`
Dispatches int `json:"dispatches,omitempty"`
ProviderDispatched bool `json:"provider_dispatched,omitempty"`
ProviderResultKnown bool `json:"provider_result_known,omitempty"`
Written bool `json:"written,omitempty"`
PlanAdvanceAllowed bool `json:"plan_advance_allowed,omitempty"`
ResponseStarted bool `json:"response_started,omitempty"`
HTTPStatus int `json:"http_status,omitempty"`
ErrorType string `json:"error_type,omitempty"`
ReasonCode string `json:"reason_code,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
Trace *AttemptTraceWire `json:"trace,omitempty"`
AutoDisableTriggers []ChannelAutoDisableTrigger `json:"auto_disable_triggers,omitempty"`
}
func DecodeResultJSON ¶ added in v0.0.14
func DecodeResultJSON(payload []byte) (AttemptProxyResult, error)
func DecodeResultJSONWithin ¶ added in v0.0.14
func DecodeResultJSONWithin(payload []byte, maxBytes int) (AttemptProxyResult, error)
DecodeResultJSONWithin applies the same negotiated limit as frame decoding.
func (AttemptProxyResult) Validate ¶
func (result AttemptProxyResult) Validate() error
type AttemptResultWriter ¶ added in v0.0.14
type AttemptResultWriter interface {
WriteAttemptResult(AttemptProxyResult) error
}
func AttemptResultWriterFromContext ¶ added in v0.0.14
func AttemptResultWriterFromContext(ctx context.Context) (AttemptResultWriter, bool)
type AttemptTraceBodyWire ¶ added in v0.0.14
type AttemptTraceWire ¶
type AttemptTraceWire struct {
InboundPath string `json:"inbound_path,omitempty"`
OutboundPath string `json:"outbound_path,omitempty"`
InboundHeaders string `json:"inbound_headers,omitempty"`
OutboundHeaders string `json:"outbound_headers,omitempty"`
InboundBody string `json:"inbound_body,omitempty"`
OutboundBody string `json:"outbound_body,omitempty"`
ResponseHeaders string `json:"response_headers,omitempty"`
ResponseBody string `json:"response_body,omitempty"`
ClientResponseBody string `json:"client_response_body,omitempty"`
UpstreamStatus int `json:"upstream_status,omitempty"`
ErrorStage string `json:"error_stage,omitempty"`
FailureFallback *AttemptTraceBodyWire `json:"failure_fallback,omitempty"`
}
type BoundAttempt ¶
type BoundAttempt struct {
Channel ChannelRef `json:"channel"`
RealModel string `json:"real_model"`
Mode ExecutionMode `json:"mode"`
}
func (BoundAttempt) Validate ¶
func (attempt BoundAttempt) Validate() error
type ChannelAutoDisableTrigger ¶ added in v0.0.15
type ChannelAutoDisableTrigger struct {
Source ChannelSource `json:"source"`
ChannelID uint `json:"channel_id"`
Revision uint64 `json:"revision"`
Reason string `json:"reason"`
}
func (ChannelAutoDisableTrigger) Validate ¶ added in v0.0.15
func (trigger ChannelAutoDisableTrigger) Validate() error
type ChannelRef ¶
type ChannelRef struct {
Source ChannelSource `json:"source"`
ID uint `json:"id"`
}
func (ChannelRef) Validate ¶
func (ref ChannelRef) Validate() error
type ChannelSource ¶
type ChannelSource string
type ExecutionMode ¶
type ExecutionMode string
type ResultKind ¶
type ResultKind string
Click to show internal directories.
Click to hide internal directories.