class LittleGhost::Providers::Bedrock::CatalogSource
Enriches Bedrock availability and on-demand pricing using bounded, SigV4-signed AWS APIs.
Public Class Methods
Source
# File lib/little_ghost/providers/bedrock/catalog_source.rb, line 18 def initialize(provider:, region:, credential_resolver: nil, clock: -> { Time.now.utc }, http_client: nil) super(name: "bedrock") @provider = provider @region = region @credential_resolver = credential_resolver || CredentialResolver.new @clock = clock @http_client = http_client || Support::HTTPClient.new( open_timeout: 5, read_timeout: 30, max_response_bytes: 25 * 1024 * 1024 ) end
Creates a source for one Bedrock provider connection and AWS region.
Calls superclass method
LittleGhost::Models::Catalog::Source::new
Public Instance Methods
# File lib/little_ghost/providers/bedrock/catalog_source.rb, line 33 def attribute_merge_strategies = ATTRIBUTE_MERGE_STRATEGIES
AWS reports a coarse subset of Converse input capabilities, so live modalities augment richer facts supplied by another catalog source.
Source
# File lib/little_ghost/providers/bedrock/catalog_source.rb, line 35 def refresh(target: nil) credentials = @credential_resolver.call models = foundation_models(credentials, target:) products = (target && models.one?) ? pricing_products(credentials, models.first) : [] records(models, products, target:) rescue JSON::ParserError, KeyError, TypeError, ArgumentError => error raise ProviderError, "Bedrock returned an invalid catalog: #{error.message}" end