Class: LittleGhost::Providers::Bedrock::CatalogSource
- Inherits:
-
Models::Catalog::Source
- Object
- Models::Catalog::Source
- LittleGhost::Providers::Bedrock::CatalogSource
- Defined in:
- lib/little_ghost/providers/bedrock/catalog_source.rb
Overview
Enriches Bedrock availability and on-demand pricing using bounded, SigV4-signed AWS APIs.
Constant Summary collapse
- PRICING_ENDPOINT =
:nodoc:
URI("https://api.pricing.us-east-1.amazonaws.com")
- PRICING_REGION =
:nodoc:
"us-east-1"- MAX_PRICING_PAGES =
:nodoc:
10- MAX_RESULTS =
:nodoc:
100- FOUNDATION_MODEL_OFFER =
:nodoc:
"AmazonBedrockFoundationModels"- BEDROCK_OFFER =
:nodoc:
"AmazonBedrock"- ATTRIBUTE_MERGE_STRATEGIES =
:nodoc:
{input_modalities: :union}.freeze
Constants inherited from Models::Catalog::Source
Models::Catalog::Source::DEFAULT_ATTRIBUTE_MERGE_STRATEGIES
Instance Attribute Summary
Attributes inherited from Models::Catalog::Source
Instance Method Summary collapse
-
#attribute_merge_strategies ⇒ Object
AWS reports a coarse subset of Converse input capabilities, so live modalities augment richer facts supplied by another catalog source.
-
#initialize(provider:, region:, credential_resolver: nil, clock: -> { Time.now.utc }, http_client: nil) ⇒ CatalogSource
constructor
Creates a source for one Bedrock provider connection and AWS region.
- #refresh(target: nil) ⇒ Object
Constructor Details
#initialize(provider:, region:, credential_resolver: nil, clock: -> { Time.now.utc }, http_client: nil) ⇒ CatalogSource
Creates a source for one Bedrock provider connection and AWS region.
18 19 20 21 22 23 24 25 26 27 28 29 |
# 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 |
Instance Method Details
#attribute_merge_strategies ⇒ Object
AWS reports a coarse subset of Converse input capabilities, so live modalities augment richer facts supplied by another catalog source.
33 |
# File 'lib/little_ghost/providers/bedrock/catalog_source.rb', line 33 def attribute_merge_strategies = ATTRIBUTE_MERGE_STRATEGIES |
#refresh(target: nil) ⇒ Object
35 36 37 38 39 40 41 42 |
# 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.}" end |