Class: Riffer::Providers::AmazonBedrock
- Defined in:
- lib/riffer/providers/amazon_bedrock.rb
Overview
Amazon Bedrock provider for Claude and other foundation models.
Requires the aws-sdk-bedrockruntime gem to be installed.
See docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/BedrockRuntime/Client.html
Constant Summary collapse
- ANTHROPIC_MODEL_PATTERN =
Matches Anthropic models on Bedrock: bare ids like
anthropic.claude-3-5-sonnet-20241022-v2:0and cross-region prefixed ids likeus.anthropic.claude-sonnet-4-6. /(?:^|\.)anthropic\./
Constants inherited from Base
Class Method Summary collapse
-
.skills_adapter(model = nil) ⇒ Object
Returns the preferred skill adapter for the given Bedrock model.
Instance Method Summary collapse
-
#initialize(api_token: nil, region: nil, **options) ⇒ AmazonBedrock
constructor
Initializes the Amazon Bedrock provider.
Methods inherited from Base
Methods included from Messages::Converter
#convert_to_file_part, #convert_to_message_object
Methods included from Helpers::Dependencies
Constructor Details
#initialize(api_token: nil, region: nil, **options) ⇒ AmazonBedrock
Initializes the Amazon Bedrock provider.
– : (?api_token: String?, ?region: String?, **untyped) -> void
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/riffer/providers/amazon_bedrock.rb', line 34 def initialize(api_token: nil, region: nil, **) depends_on "aws-sdk-bedrockruntime" api_token ||= Riffer.config.amazon_bedrock.api_token region ||= Riffer.config.amazon_bedrock.region @client = if api_token && !api_token.empty? Aws::BedrockRuntime::Client.new( region: region, token_provider: Aws::StaticTokenProvider.new(api_token), auth_scheme_preference: ["httpBearerAuth"], ** ) else Aws::BedrockRuntime::Client.new(region: region, **) end end |
Class Method Details
.skills_adapter(model = nil) ⇒ Object
Returns the preferred skill adapter for the given Bedrock model.
Bedrock hosts models from multiple vendors. Anthropic models prefer XML-rendered catalogs; everything else falls back to the default Markdown adapter.
– : (?String?) -> singleton(Riffer::Skills::Adapter)
25 26 27 28 |
# File 'lib/riffer/providers/amazon_bedrock.rb', line 25 def self.skills_adapter(model = nil) return Riffer::Skills::XmlAdapter if model && ANTHROPIC_MODEL_PATTERN.match?(model) Riffer::Skills::MarkdownAdapter end |