bedrockconverse

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeResponse

func DecodeResponse(body []byte) (*inference.Response, error)

DecodeResponse parses a native Bedrock Converse response into the shared inference response. Bedrock does not echo the model ID in this envelope, so Model is intentionally left empty for the provider client to fill from the bound request.

func EncodeCountTokensInput

func EncodeCountTokensInput(req inference.Request) ([]byte, error)

EncodeCountTokensInput emits the Converse union member accepted by Bedrock's CountTokens API. Inference controls, output formatting, response-field paths, guardrails, and service tiers are intentionally excluded because CountTokens accepts only the conversation, system, tool configuration, and additional model-request fields.

func EncodeRequest

func EncodeRequest(req inference.Request) ([]byte, error)

EncodeRequest builds the native Converse JSON request. The model ID is intentionally absent: Bedrock identifies it in the URL path.

Types

type Codec

type Codec struct{}

Codec is Amazon Bedrock's native Converse API dialect. The request body is shared by Converse and ConverseStream; streaming is selected by the provider route and response content type, not by a JSON flag.

func (Codec) DecodeResponse

func (Codec) DecodeResponse(body []byte) (*inference.Response, error)

DecodeResponse is completed in decode.go; keeping the method here makes the codec's public shape explicit while request encoding is developed separately.

func (Codec) DecodeStream

func (Codec) DecodeStream(resp *http.Response) (*stream.StreamReader[content.Chunk], error)

DecodeStream frames a successful ConverseStream response with AWS Event Stream and maps each event to shared content chunks. The returned reader owns resp.Body through the wire framer.

func (Codec) EncodeRequest

func (Codec) EncodeRequest(req inference.Request, _ codec.RequestMode) (codec.EncodedRequest, error)

EncodeRequest implements codec.RequestEncoder. Converse and ConverseStream use the same body, so mode is intentionally ignored.

type ConversationCollisionError

type ConversationCollisionError struct {
	Reason string
}

ConversationCollisionError reports adjacent neutral turns that Bedrock cannot represent without mixing ordinary user content and toolResult blocks in one Converse message.

func (*ConversationCollisionError) Error

type DecodeError

type DecodeError struct {
	Reason string
	Err    error
}

DecodeError is used by the response decoder for malformed successful Bedrock payloads. It is defined with the request codec so callers can use one stable typed error family across the codec's directions.

func (*DecodeError) Error

func (e *DecodeError) Error() string

func (*DecodeError) Unwrap

func (e *DecodeError) Unwrap() error

type EncodeError

type EncodeError struct {
	Reason string
	Err    error
}

EncodeError wraps a request-construction failure that is not a feature or content-type validation error. It intentionally carries bounded diagnostics rather than raw provider payloads.

func (*EncodeError) Error

func (e *EncodeError) Error() string

func (*EncodeError) Unwrap

func (e *EncodeError) Unwrap() error

type ForeignReasoningSignatureError

type ForeignReasoningSignatureError struct {
	// Format is the label carried by the signature, or "" when it carries none.
	Format string
}

ForeignReasoningSignatureError reports a reasoning signature this dialect cannot prove it minted, either because another dialect's label is attached (Format names it) or because no label is attached at all (Format is empty).

It is a hard error, not a degrade. A reasoning signature is verified by its issuer: measured against api.anthropic.com on 2026-08-13, a verbatim signature is accepted, a tampered one draws HTTP 400, and an EMPTY one draws the same 400. Both degrades therefore lose — forwarding sends a request certain to be rejected, stripping sends an unsigned reasoning block equally certain to be rejected while destroying the only copy of the continuation state. Failing here costs the same turn and names the cause.

Converse fronts the same Claude models as the Anthropic Messages API, so the foreign case is an ordinary session moved between endpoints, not an attack.

func (*ForeignReasoningSignatureError) Error

type StreamAPIError

type StreamAPIError struct {
	Type    string
	Message string
}

StreamAPIError reports an AWS event-stream exception after the HTTP success boundary. Only its typed exception name and bounded message are retained.

func (*StreamAPIError) Error

func (e *StreamAPIError) Error() string

type StreamDecodeError

type StreamDecodeError struct {
	Reason string
	Err    error
}

StreamDecodeError reports malformed or out-of-order ConverseStream events. It never includes the raw provider event body in its diagnostic.

func (*StreamDecodeError) Error

func (e *StreamDecodeError) Error() string

func (*StreamDecodeError) Unwrap

func (e *StreamDecodeError) Unwrap() error

type ToolInputError

type ToolInputError struct {
	Tool   string
	Reason string
}

ToolInputError reports malformed arguments on a replayed tool-use block.

func (*ToolInputError) Error

func (e *ToolInputError) Error() string

type ToolSchemaError

type ToolSchemaError struct {
	Tool   string
	Reason string
}

ToolSchemaError reports a missing, malformed, or otherwise invalid tool input schema before it reaches the Bedrock endpoint.

func (*ToolSchemaError) Error

func (e *ToolSchemaError) Error() string

type UnsupportedBlockError

type UnsupportedBlockError struct {
	Block  string
	Reason string
}

UnsupportedBlockError reports a content block that Bedrock Converse cannot represent in the shared request vocabulary.

func (*UnsupportedBlockError) Error

func (e *UnsupportedBlockError) Error() string

type UnsupportedConversationError

type UnsupportedConversationError struct {
	Conversation string
}

UnsupportedConversationError reports an unexpected conversation variant.

func (*UnsupportedConversationError) Error

type UnsupportedEffortError added in v0.12.0

type UnsupportedEffortError struct {
	Effort string
}

UnsupportedEffortError reports a neutral reasoning effort that the generic Converse request has no model-independent field to represent.

func (*UnsupportedEffortError) Error added in v0.12.0

func (e *UnsupportedEffortError) Error() string

Jump to

Keyboard shortcuts

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