Class: Ask::Providers::Bedrock
- Inherits:
-
Ask::Provider
- Object
- Ask::Provider
- Ask::Providers::Bedrock
- Defined in:
- lib/ask/provider/bedrock.rb
Overview
Amazon Bedrock provider using the Converse API. Uses the AWS SDK for authentication (credentials chain: env, ~/.aws, instance profile).
Class Method Summary collapse
- .capabilities ⇒ Object
- .configuration_options ⇒ Object
- .configuration_requirements ⇒ Object
- .slug ⇒ Object
Instance Method Summary collapse
- #api_base ⇒ Object
- #chat(messages, model:, tools: nil, temperature: nil, stream: nil, schema: nil, **params, &block) ⇒ Object
- #embed(_texts, model: nil) ⇒ Object
-
#initialize(config = {}) ⇒ Bedrock
constructor
A new instance of Bedrock.
- #list_models ⇒ Object
- #parse_error(response) ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Bedrock
Returns a new instance of Bedrock.
8 9 10 11 |
# File 'lib/ask/provider/bedrock.rb', line 8 def initialize(config = {}) config = normalize_config(config) super(config) end |
Class Method Details
.capabilities ⇒ Object
41 42 43 |
# File 'lib/ask/provider/bedrock.rb', line 41 def capabilities { chat: true, streaming: true, tool_calls: true, vision: true } end |
.configuration_options ⇒ Object
44 |
# File 'lib/ask/provider/bedrock.rb', line 44 def ; %i[region access_key_id secret_access_key session_token]; end |
.configuration_requirements ⇒ Object
45 |
# File 'lib/ask/provider/bedrock.rb', line 45 def configuration_requirements; %i[]; end |
.slug ⇒ Object
46 |
# File 'lib/ask/provider/bedrock.rb', line 46 def slug; "bedrock"; end |
Instance Method Details
#api_base ⇒ Object
13 14 15 |
# File 'lib/ask/provider/bedrock.rb', line 13 def api_base @config.region || "us-east-1" end |
#chat(messages, model:, tools: nil, temperature: nil, stream: nil, schema: nil, **params, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/ask/provider/bedrock.rb', line 17 def chat(, model:, tools: nil, temperature: nil, stream: nil, schema: nil, **params, &block) msgs = .is_a?(Ask::Conversation) ? .to_a : payload = build_converse_payload(msgs, model, tools, temperature, schema, **params) if stream chat_stream(payload, model, &block) else chat_nonstream(payload, model) end end |
#embed(_texts, model: nil) ⇒ Object
27 28 29 |
# File 'lib/ask/provider/bedrock.rb', line 27 def (_texts, model: nil) raise Ask::CapabilityNotSupported, "Bedrock does not support embeddings via Converse API" end |
#list_models ⇒ Object
31 32 33 34 |
# File 'lib/ask/provider/bedrock.rb', line 31 def list_models # Bedrock doesn't have a list models endpoint — rely on model catalog [] end |
#parse_error(response) ⇒ Object
36 37 38 |
# File 'lib/ask/provider/bedrock.rb', line 36 def parse_error(response) response.body["message"] rescue nil end |