bedrock

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Copyright 2026 Teradata

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// DefaultBedrockModelID uses Claude Sonnet 4.5 with cross-region inference profile (us.* prefix)
	DefaultBedrockModelID     = "us.anthropic.claude-sonnet-4-5-20250929-v1:0"
	DefaultBedrockRegion      = "us-west-2"
	DefaultBedrockMaxTokens   = 4096
	DefaultBedrockTemperature = 1.0
)

Default Bedrock configuration values. Can be overridden via environment variables:

  • AWS_BEDROCK_MODEL_ID / LOOM_LLM_BEDROCK_MODEL_ID
  • AWS_DEFAULT_REGION / LOOM_LLM_BEDROCK_REGION

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client implements the LLMProvider interface for AWS Bedrock.

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient creates a new Bedrock client.

func (*Client) Chat

func (c *Client) Chat(ctx context.Context, messages []llmtypes.Message, tools []shuttle.Tool) (*llmtypes.LLMResponse, error)

Chat sends a conversation to Bedrock and returns the response.

func (*Client) ChatConverse

func (c *Client) ChatConverse(ctx context.Context, messages []llmtypes.Message, tools []shuttle.Tool) (*llmtypes.LLMResponse, error)

ChatConverse implements non-streaming using AWS Bedrock Converse API. This is the modern, unified API that properly handles tool use. This method is used when streaming is not needed or disabled.

func (*Client) ChatStream

func (c *Client) ChatStream(ctx context.Context, messages []llmtypes.Message, tools []shuttle.Tool, tokenCallback llmtypes.TokenCallback) (*llmtypes.LLMResponse, error)

ChatStream is DISABLED due to bugs with document.NewLazyDocument causing empty tool inputs. The ConverseStream API cannot properly serialize tool schemas, resulting in all tool calls having empty parameters ({}). Use the non-streaming Chat() method instead.

func (*Client) Model

func (c *Client) Model() string

Model returns the model identifier.

func (*Client) Name

func (c *Client) Name() string

Name returns the provider name.

type Config

type Config struct {
	// AWS Configuration
	Region          string // Required: AWS region (e.g., us-east-1, us-west-2)
	AccessKeyID     string // Optional: if not using IAM role/profile
	SecretAccessKey string // Optional: if not using IAM role/profile
	SessionToken    string // Optional: for temporary credentials
	Profile         string // Optional: AWS profile name from ~/.aws/config
	BearerToken     string // Optional: bearer token for IAM Identity Center / SSO auth (bypasses SigV4)

	// Model Configuration
	ModelID     string  // Default: us.anthropic.claude-sonnet-4-5-20250929-v1:0
	MaxTokens   int     // Default: 4096
	Temperature float64 // Default: 1.0

	// Rate Limiting Configuration
	RateLimiterConfig llm.RateLimiterConfig // Optional: rate limiting config (enables automatic throttle handling)
}

Config holds configuration for the Bedrock client.

type SDKClient

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

SDKClient implements the LLMProvider interface using the official Anthropic SDK for Bedrock. This is simpler and better maintained than the direct AWS SDK approach.

func NewSDKClient

func NewSDKClient(cfg Config) (*SDKClient, error)

NewSDKClient creates a new Bedrock client using the Anthropic SDK.

func (*SDKClient) Chat

func (c *SDKClient) Chat(ctx context.Context, messages []llmtypes.Message, tools []shuttle.Tool) (*llmtypes.LLMResponse, error)

Chat sends a conversation to Bedrock using the Anthropic SDK and returns the response.

func (*SDKClient) ChatStream

func (c *SDKClient) ChatStream(ctx context.Context, messages []llmtypes.Message, tools []shuttle.Tool,
	tokenCallback llmtypes.TokenCallback) (*llmtypes.LLMResponse, error)

ChatStream streams tokens as they're generated from Bedrock using the Anthropic SDK.

func (*SDKClient) Model

func (c *SDKClient) Model() string

Model returns the model identifier.

func (*SDKClient) Name

func (c *SDKClient) Name() string

Name returns the provider name.

Jump to

Keyboard shortcuts

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