Documentation
¶
Overview ¶
Package bedrock adapts Amazon Bedrock Converse Stream to sigma.
The provider keeps AWS-specific regions, credential discovery, endpoints, model IDs, inference profiles, SigV4 signing, and EventStream parsing inside this package. Tests can inject ConverseStreamClient and CredentialDetector fakes; production calls use the stdlib HTTP client.
Bedrock model families do not expose identical Converse behavior. Anthropic Claude models support inline images, tools, prompt cache points, and extended thinking through model-specific fields. Amazon Nova and other families differ in tool-result status, image support, cache support, and reasoning controls. This adapter maps provider-neutral sigma features only where Converse exposes a stable field or a documented model-specific extension hook.
Index ¶
- func Register(registry *sigma.Registry, providerID sigma.ProviderID, opts ...ProviderOption) error
- func RegisterDefault(providerID sigma.ProviderID, opts ...ProviderOption) error
- type Config
- type ConverseCachePointBlock
- type ConverseContentBlock
- type ConverseEvent
- type ConverseEventKind
- type ConverseImageBlock
- type ConverseInferenceConfig
- type ConverseMessage
- type ConverseReasoningBlock
- type ConverseRequest
- type ConverseStream
- type ConverseStreamClient
- type ConverseTool
- type ConverseToolResultBlock
- type ConverseToolResultContent
- type ConverseToolUseBlock
- type ConverseUsage
- type CredentialDetector
- type CredentialInfo
- type CredentialSource
- type DefaultCredentialDetector
- type Provider
- type ProviderOption
- func WithConfig(config Config) ProviderOption
- func WithConverseStreamClient(client ConverseStreamClient) ProviderOption
- func WithCredentialDetector(detector CredentialDetector) ProviderOption
- func WithCredentialSource(source CredentialSource) ProviderOption
- func WithEndpoint(endpoint string) ProviderOption
- func WithInferenceProfileARN(arn string) ProviderOption
- func WithModelID(modelID string) ProviderOption
- func WithRegion(region string) ProviderOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(registry *sigma.Registry, providerID sigma.ProviderID, opts ...ProviderOption) error
Register adds a Bedrock Converse Stream text provider to registry.
func RegisterDefault ¶
func RegisterDefault(providerID sigma.ProviderID, opts ...ProviderOption) error
RegisterDefault adds a Bedrock Converse Stream provider to sigma's default registry.
Types ¶
type Config ¶
type Config struct {
Region string
ModelID string
InferenceProfileARN string
Endpoint string
CredentialSource CredentialSource
}
Config carries Bedrock-specific settings without adding AWS SDK types to the root sigma package.
type ConverseCachePointBlock ¶ added in v0.2.0
type ConverseCachePointBlock struct {
TTL string `json:"ttl,omitempty"`
}
ConverseCachePointBlock carries Bedrock prompt cache marker options.
type ConverseContentBlock ¶
type ConverseContentBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Image *ConverseImageBlock `json:"image,omitempty"`
ToolUse *ConverseToolUseBlock `json:"toolUse,omitempty"`
ToolResult *ConverseToolResultBlock `json:"toolResult,omitempty"`
Reasoning *ConverseReasoningBlock `json:"reasoning,omitempty"`
CachePoint *ConverseCachePointBlock `json:"cachePoint,omitempty"`
}
ConverseContentBlock is a provider-owned Converse content block.
type ConverseEvent ¶
type ConverseEvent struct {
Kind ConverseEventKind
ContentBlockIndex int
Role string
TextDelta string
ThinkingDelta string
ThinkingSignature string
RedactedThinking string
ToolUseID string
ToolName string
ToolInputDelta string
StopReason string
Usage *ConverseUsage
Err error
}
ConverseEvent is a provider-owned Bedrock stream event without AWS SDK types.
type ConverseEventKind ¶
type ConverseEventKind string
ConverseEventKind identifies provider-owned Bedrock stream events.
const ( ConverseEventMessageStart ConverseEventKind = "message_start" ConverseEventContentBlockStart ConverseEventKind = "content_block_start" ConverseEventContentBlockDelta ConverseEventKind = "content_block_delta" ConverseEventContentBlockStop ConverseEventKind = "content_block_stop" ConverseEventMessageStop ConverseEventKind = "message_stop" ConverseEventMetadata ConverseEventKind = "metadata" ConverseEventError ConverseEventKind = "error" )
type ConverseImageBlock ¶
ConverseImageBlock carries inline image bytes as base64 text.
type ConverseInferenceConfig ¶
type ConverseInferenceConfig struct {
MaxTokens *int `json:"maxTokens,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"topP,omitempty"`
StopSequences []string `json:"stopSequences,omitempty"`
}
ConverseInferenceConfig carries portable Converse inference parameters.
type ConverseMessage ¶
type ConverseMessage struct {
Role string `json:"role"`
Content []ConverseContentBlock `json:"content"`
}
ConverseMessage is a Bedrock Converse message without AWS SDK types.
type ConverseReasoningBlock ¶
type ConverseReasoningBlock struct {
Text string `json:"text,omitempty"`
Signature string `json:"signature,omitempty"`
ProviderSignature string `json:"providerSignature,omitempty"`
Redacted bool `json:"redacted,omitempty"`
}
ConverseReasoningBlock carries replayed reasoning content.
type ConverseRequest ¶
type ConverseRequest struct {
ModelID string `json:"modelId"`
System []ConverseContentBlock `json:"system,omitempty"`
Messages []ConverseMessage `json:"messages,omitempty"`
InferenceConfig *ConverseInferenceConfig `json:"inferenceConfig,omitempty"`
Tools []ConverseTool `json:"tools,omitempty"`
ToolChoice *sigma.BedrockToolChoice `json:"toolChoice,omitempty"`
AdditionalModelRequestFields map[string]any `json:"additionalModelRequestFields,omitempty"`
AdditionalModelResponseFieldPaths []string `json:"additionalModelResponseFieldPaths,omitempty"`
RequestMetadata map[string]string `json:"requestMetadata,omitempty"`
}
ConverseRequest is the provider-owned request shape sent through the client seam.
type ConverseStream ¶
type ConverseStream interface {
Events() <-chan ConverseEvent
Close() error
Err() error
}
ConverseStream is the fakeable Bedrock stream seam.
type ConverseStreamClient ¶
type ConverseStreamClient interface {
ConverseStream(context.Context, ConverseRequest) (ConverseStream, error)
}
ConverseStreamClient is the narrow fakeable Bedrock runtime seam.
type ConverseTool ¶
type ConverseTool struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
InputSchema any `json:"inputSchema,omitempty"`
}
ConverseTool carries a function tool spec.
type ConverseToolResultBlock ¶
type ConverseToolResultBlock struct {
ToolUseID string `json:"toolUseId"`
Content []ConverseToolResultContent `json:"content,omitempty"`
Status string `json:"status,omitempty"`
}
ConverseToolResultBlock carries a user tool result.
type ConverseToolResultContent ¶ added in v0.2.0
type ConverseToolResultContent struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Image *ConverseImageBlock `json:"image,omitempty"`
}
ConverseToolResultContent carries one tool-result content item.
type ConverseToolUseBlock ¶
type ConverseToolUseBlock struct {
ID string `json:"id"`
Name string `json:"name"`
Input any `json:"input,omitempty"`
}
ConverseToolUseBlock carries an assistant tool request.
type ConverseUsage ¶
type ConverseUsage struct {
InputTokens int
OutputTokens int
TotalTokens int
CacheReadInputTokens int
CacheWriteInputTokens int
}
ConverseUsage carries Bedrock token accounting.
type CredentialDetector ¶
type CredentialDetector interface {
Detect(context.Context, sigma.Model, sigma.Options, Config) (CredentialInfo, error)
}
CredentialDetector detects AWS credentials without exposing AWS SDK types in the provider's fakeable client seam.
type CredentialInfo ¶
type CredentialInfo struct {
Source CredentialSource
AccessKeyID string
SecretAccessKey string
SessionToken string
BearerToken string
}
CredentialInfo is diagnostic-safe AWS credential metadata plus optional static credential fields for the HTTP transport.
func (CredentialInfo) Format ¶
func (c CredentialInfo) Format(state fmt.State, verb rune)
Format prevents fmt from printing secrets with struct formatting verbs.
func (CredentialInfo) String ¶
func (c CredentialInfo) String() string
String returns a redacted credential description.
type CredentialSource ¶
type CredentialSource string
CredentialSource identifies how the Bedrock provider should find AWS credentials.
const ( // CredentialSourceAuto checks sigma's auth resolver first, then the AWS default chain. CredentialSourceAuto CredentialSource = "" // CredentialSourceDefaultChain uses the stdlib environment credential chain. CredentialSourceDefaultChain CredentialSource = "default-chain" // CredentialSourceAuthResolver uses sigma.Options.AuthResolver only. CredentialSourceAuthResolver CredentialSource = "auth-resolver" )
type DefaultCredentialDetector ¶
type DefaultCredentialDetector struct{}
DefaultCredentialDetector uses sigma auth callbacks and a stdlib environment credential chain.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider adapts Amazon Bedrock Converse Stream to sigma.
Known limitations:
- Image inputs support inline base64 bytes only. URL and S3 image shims are intentionally not inferred from provider-neutral image blocks.
- Reasoning is sent through model-specific additional request fields when a thinking token budget is provided; model-family support varies.
- Prompt caching is represented with Bedrock cache points, but cache TTL and cacheable block placement differ across Anthropic, Nova, and other model families.
- Bedrock model access, IAM permissions, and available model discovery are AWS account concerns and are not handled by this adapter.
func NewProvider ¶
func NewProvider(opts ...ProviderOption) *Provider
NewProvider constructs a Bedrock Converse Stream provider.
type ProviderOption ¶
type ProviderOption func(*Provider)
ProviderOption configures a Provider.
func WithConfig ¶
func WithConfig(config Config) ProviderOption
WithConfig configures Bedrock request defaults.
func WithConverseStreamClient ¶
func WithConverseStreamClient(client ConverseStreamClient) ProviderOption
WithConverseStreamClient injects a fakeable Bedrock client.
func WithCredentialDetector ¶
func WithCredentialDetector(detector CredentialDetector) ProviderOption
WithCredentialDetector injects credential detection for tests or custom AWS auth.
func WithCredentialSource ¶
func WithCredentialSource(source CredentialSource) ProviderOption
WithCredentialSource configures which AWS credential path should be used.
func WithEndpoint ¶
func WithEndpoint(endpoint string) ProviderOption
WithEndpoint configures a custom Bedrock Runtime endpoint.
func WithInferenceProfileARN ¶
func WithInferenceProfileARN(arn string) ProviderOption
WithInferenceProfileARN configures an inference profile ARN or ID as modelId.
func WithModelID ¶
func WithModelID(modelID string) ProviderOption
WithModelID configures the Bedrock modelId sent to ConverseStream.
func WithRegion ¶
func WithRegion(region string) ProviderOption
WithRegion configures the AWS region used by the SDK client.