ruby-amazon-bedrock 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81db5e2aa4d8b27014d6f2f24bc79083ddae2401a60a2d6d120fbc27e9facd62
4
- data.tar.gz: f8f3ae19c0756142df41ef49e9d1d66d33f480013d375b6086cdb70e5365a3f2
3
+ metadata.gz: 06f4b8ff875c2d3d8b104c026621108f24e2ea60dd4ef07e85b4874b346b95af
4
+ data.tar.gz: 5fae3ad77abbab1f45ce187ade385da0ab0d3a64d7a8c38e22283a08ed23078b
5
5
  SHA512:
6
- metadata.gz: 4cd2bdd5a70da7ddd8f92dfed38cee2432b3a1800d9d774918fd967f6d623df68afef0b1e250866a90a013a0ff3f4226146cf1e9684c1e28bd8ebdd4dad444bc
7
- data.tar.gz: e2b2f8a61ab61967e7d79ce0762002fbee9ce3fdc60086b5a6cb7f0c825caa91835fe07c632380cabcf8d0cadd237f609b104d3335af7bd9ffb08224bdf84d7f
6
+ metadata.gz: cd0bd9610262b0222d9680386cfcd46b070582c8f0053737020c35509504a31c2cac4e94668debed36fc9f3f5c4f45396f0082c57314277572124d24ce2bffb4
7
+ data.tar.gz: 44c080409f214e186841ff78a073a84749bb84cc978d2d206045f0a143b9533bf652356da17e4405bbdf3ae59337a0752f762af02ec2125ee1e84750a1c394a9
data/.circleci/config.yml CHANGED
@@ -50,8 +50,6 @@ workflows:
50
50
  matrix:
51
51
  parameters:
52
52
  ruby-image:
53
- - cimg/ruby:2.6-node
54
- - cimg/ruby:2.7-node
55
53
  - cimg/ruby:3.0-node
56
54
  - cimg/ruby:3.1-node
57
55
  - cimg/ruby:3.2-node
data/.env.sample ADDED
@@ -0,0 +1,5 @@
1
+ AWS_REGION: 'us-east-1'
2
+
3
+ # You don't need valid key data *unless you are creating new
4
+ AWS_ACCESS_KEY_ID: 'aaaaaaaaaaaaaaaaaaaa'
5
+ AWS_SECRET_ACCESS_KEY: 'aaaaaaaaaaaaaaaaaaaa'
data/.gitignore CHANGED
@@ -4,7 +4,7 @@
4
4
  /coverage/
5
5
  /doc/
6
6
  /pkg/
7
- /spec/reports/
7
+ /spec/reports/
8
8
  /tmp/
9
9
  .env
10
10
  *.gem
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.2.5] - 2024-09-17
2
+
3
+ - Support for llama38b_instruct_v1
4
+ - Support for llama370b_instruct_v1
5
+ - Explicitly add base64 gem to dependencies
6
+ - Support the use of AWS Named Profiles for authentication
7
+
1
8
  ## [0.2.3] - 2024-01-12
2
9
 
3
10
  - Fix A121 Labs bug for maxTokens parameter
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ gem "bundler-audit", "~> 0.8"
9
9
  gem "dotenv", "~> 2.7"
10
10
  gem "pry", "~> 0.13"
11
11
  gem "rake", "~> 13.0"
12
+ gem "rexml", ">= 3.3.6"
12
13
  gem "rspec", "~> 3.0"
13
14
  gem "rubocop", "~> 1.21"
14
15
  gem "vcr", "~> 6.0"
data/Gemfile.lock CHANGED
@@ -1,104 +1,110 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-amazon-bedrock (0.2.3)
4
+ ruby-amazon-bedrock (0.2.4)
5
5
  aws-sdk-bedrockruntime (~> 1.0)
6
6
  aws-sdk-s3 (~> 1.0)
7
+ base64 (~> 0.2)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- addressable (2.8.5)
12
- public_suffix (>= 2.0.2, < 6.0)
12
+ addressable (2.8.7)
13
+ public_suffix (>= 2.0.2, < 7.0)
13
14
  ast (2.4.2)
14
15
  aws-eventstream (1.3.0)
15
- aws-partitions (1.860.0)
16
- aws-sdk-bedrockruntime (1.4.0)
17
- aws-sdk-core (~> 3, >= 3.188.0)
18
- aws-sigv4 (~> 1.1)
19
- aws-sdk-core (3.189.0)
16
+ aws-partitions (1.963.0)
17
+ aws-sdk-bedrockruntime (1.17.0)
18
+ aws-sdk-core (~> 3, >= 3.201.0)
19
+ aws-sigv4 (~> 1.5)
20
+ aws-sdk-core (3.201.4)
20
21
  aws-eventstream (~> 1, >= 1.3.0)
21
22
  aws-partitions (~> 1, >= 1.651.0)
22
23
  aws-sigv4 (~> 1.8)
23
24
  jmespath (~> 1, >= 1.6.1)
24
- aws-sdk-kms (1.71.0)
25
- aws-sdk-core (~> 3, >= 3.177.0)
26
- aws-sigv4 (~> 1.1)
27
- aws-sdk-s3 (1.132.0)
28
- aws-sdk-core (~> 3, >= 3.179.0)
25
+ aws-sdk-kms (1.88.0)
26
+ aws-sdk-core (~> 3, >= 3.201.0)
27
+ aws-sigv4 (~> 1.5)
28
+ aws-sdk-s3 (1.157.0)
29
+ aws-sdk-core (~> 3, >= 3.201.0)
29
30
  aws-sdk-kms (~> 1)
30
- aws-sigv4 (~> 1.6)
31
- aws-sigv4 (1.8.0)
31
+ aws-sigv4 (~> 1.5)
32
+ aws-sigv4 (1.9.1)
32
33
  aws-eventstream (~> 1, >= 1.0.2)
34
+ base64 (0.2.0)
35
+ bigdecimal (3.1.8)
33
36
  bundler-audit (0.9.1)
34
37
  bundler (>= 1.2.0, < 3)
35
38
  thor (~> 1.0)
36
39
  coderay (1.1.3)
37
- crack (0.4.5)
40
+ crack (1.0.0)
41
+ bigdecimal
38
42
  rexml
39
- diff-lcs (1.5.0)
43
+ diff-lcs (1.5.1)
40
44
  dotenv (2.8.1)
41
- hashdiff (1.0.1)
45
+ hashdiff (1.1.1)
42
46
  jmespath (1.6.2)
43
- json (2.6.3)
47
+ json (2.7.2)
44
48
  language_server-protocol (3.17.0.3)
45
- method_source (1.0.0)
46
- parallel (1.23.0)
47
- parser (3.2.2.4)
49
+ method_source (1.1.0)
50
+ parallel (1.26.1)
51
+ parser (3.3.4.2)
48
52
  ast (~> 2.4.1)
49
53
  racc
50
54
  pry (0.14.2)
51
55
  coderay (~> 1.1)
52
56
  method_source (~> 1.0)
53
- public_suffix (5.0.4)
54
- racc (1.7.3)
57
+ public_suffix (5.1.1)
58
+ racc (1.8.1)
55
59
  rainbow (3.1.1)
56
- rake (13.1.0)
57
- regexp_parser (2.8.2)
58
- rexml (3.2.6)
59
- rspec (3.12.0)
60
- rspec-core (~> 3.12.0)
61
- rspec-expectations (~> 3.12.0)
62
- rspec-mocks (~> 3.12.0)
63
- rspec-core (3.12.2)
64
- rspec-support (~> 3.12.0)
65
- rspec-expectations (3.12.3)
60
+ rake (13.2.1)
61
+ regexp_parser (2.9.2)
62
+ rexml (3.3.7)
63
+ rspec (3.13.0)
64
+ rspec-core (~> 3.13.0)
65
+ rspec-expectations (~> 3.13.0)
66
+ rspec-mocks (~> 3.13.0)
67
+ rspec-core (3.13.0)
68
+ rspec-support (~> 3.13.0)
69
+ rspec-expectations (3.13.1)
66
70
  diff-lcs (>= 1.2.0, < 2.0)
67
- rspec-support (~> 3.12.0)
68
- rspec-mocks (3.12.6)
71
+ rspec-support (~> 3.13.0)
72
+ rspec-mocks (3.13.1)
69
73
  diff-lcs (>= 1.2.0, < 2.0)
70
- rspec-support (~> 3.12.0)
71
- rspec-support (3.12.1)
72
- rubocop (1.57.2)
74
+ rspec-support (~> 3.13.0)
75
+ rspec-support (3.13.1)
76
+ rubocop (1.65.1)
73
77
  json (~> 2.3)
74
78
  language_server-protocol (>= 3.17.0)
75
79
  parallel (~> 1.10)
76
- parser (>= 3.2.2.4)
80
+ parser (>= 3.3.0.2)
77
81
  rainbow (>= 2.2.2, < 4.0)
78
- regexp_parser (>= 1.8, < 3.0)
82
+ regexp_parser (>= 2.4, < 3.0)
79
83
  rexml (>= 3.2.5, < 4.0)
80
- rubocop-ast (>= 1.28.1, < 2.0)
84
+ rubocop-ast (>= 1.31.1, < 2.0)
81
85
  ruby-progressbar (~> 1.7)
82
86
  unicode-display_width (>= 2.4.0, < 3.0)
83
- rubocop-ast (1.30.0)
84
- parser (>= 3.2.1.0)
87
+ rubocop-ast (1.32.0)
88
+ parser (>= 3.3.1.0)
85
89
  ruby-progressbar (1.13.0)
86
- thor (1.3.0)
90
+ thor (1.3.1)
87
91
  unicode-display_width (2.5.0)
88
92
  vcr (6.2.0)
89
- webmock (3.19.1)
93
+ webmock (3.23.1)
90
94
  addressable (>= 2.8.0)
91
95
  crack (>= 0.3.2)
92
96
  hashdiff (>= 0.4.0, < 2.0.0)
93
97
 
94
98
  PLATFORMS
95
99
  arm64-darwin-22
100
+ arm64-darwin-23
96
101
 
97
102
  DEPENDENCIES
98
103
  bundler-audit (~> 0.8)
99
104
  dotenv (~> 2.7)
100
105
  pry (~> 0.13)
101
106
  rake (~> 13.0)
107
+ rexml (>= 3.3.6)
102
108
  rspec (~> 3.0)
103
109
  rubocop (~> 1.21)
104
110
  ruby-amazon-bedrock!
@@ -106,4 +112,4 @@ DEPENDENCIES
106
112
  webmock (~> 3.12)
107
113
 
108
114
  BUNDLED WITH
109
- 2.4.22
115
+ 2.4.14
data/README.md CHANGED
@@ -14,7 +14,7 @@ Amazon Bedrock is a fully managed service that makes FMs from leading AI startup
14
14
  Add the following line to your application's Gemfile:
15
15
 
16
16
  ```ruby
17
- gem "ruby-amazon-bedrock", "~> 0.2.3"
17
+ gem "ruby-amazon-bedrock", "~> 0.2.4"
18
18
  ```
19
19
 
20
20
  And then execute:
@@ -59,20 +59,28 @@ Instantiate a client by passing your AWS IAM credentials:
59
59
  client = RubyAmazonBedrock::Client.new(
60
60
  region: "AWS_REGION",
61
61
  access_key_id: "AWS_ACCESS_KEY_ID",
62
- access_token: "AWS_SECRET_ACCESS_KEY"
62
+ secret_access_key: "AWS_SECRET_ACCESS_KEY"
63
63
  )
64
64
  ```
65
65
 
66
- ## With Configuration
66
+ Or copy the `.env.sample` to a `.env` file with your account's credentials and use the `ENV` variable. NOTE: This step is REQUIRED in order to run the tests with `rspec`
67
67
 
68
68
  ```ruby
69
- RubyAmazonBedrock.configure do |config|
70
- config.region = ENV.fetch('AWS_REGION', nil)
71
- config.access_key_id = ENV.fetch('AWS_ACCESS_KEY_ID', nil)
72
- config.secret_access_key = ENV.fetch('AWS_SECRET_ACCESS_KEY', nil)
73
- end
69
+ client = RubyAmazonBedrock::Client.new(
70
+ region: ENV["AWS_REGION"],
71
+ access_key_id: ENV["AWS_ACCESS_KEY_ID"],
72
+ secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"]
73
+ )
74
+ ```
75
+
76
+ ### AWS Named Profiles
74
77
 
75
- client = RubyAmazonBedrock::Client.new
78
+ You can also use [AWS Named Profiles](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-format-profile) by passing the `profile` keywoard argument. When using a named profile, specyfing the `region`, `access_key_id` and `access_token` won't be required.
79
+
80
+ ```ruby
81
+ client = RubyAmazonBedrock::Client.new(
82
+ profile: "AWS_PROFILE"
83
+ )
76
84
  ```
77
85
 
78
86
  ## Options
@@ -231,7 +239,7 @@ _*Claude Instant 1.2*_
231
239
  Supports: Question answering, information extraction, removing PII, content generation, multiple choice classification, Roleplay, comparing text, summarization, document Q&A with citation
232
240
 
233
241
  ```ruby
234
- client.invoke_model('anthropic.claude-instant-v1', 'What is a neural network?')
242
+ client.invoke_model(id: 'anthropic.claude-instant-v1', prompt: 'What is a neural network?')
235
243
 
236
244
  # Response
237
245
  {:completion=>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyAmazonBedrock
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.4"
5
5
  end
@@ -13,7 +13,7 @@ module RubyAmazonBedrock
13
13
 
14
14
  # Configuration class for setting up AWS credentials and region.
15
15
  class Configuration
16
- attr_accessor :region, :access_key_id, :secret_access_key
16
+ attr_accessor :region, :access_key_id, :secret_access_key, :profile
17
17
 
18
18
  # Initializes a new Configuration instance, loading values from
19
19
  # environment variables or setting them to nil by default so the
@@ -22,6 +22,7 @@ module RubyAmazonBedrock
22
22
  @region = ENV.fetch('AWS_REGION', nil)
23
23
  @access_key_id = ENV.fetch('AWS_ACCESS_KEY_ID', nil)
24
24
  @secret_access_key = ENV.fetch('AWS_SECRET_ACCESS_KEY', nil)
25
+ @profile = ENV.fetch('AWS_PROFILE', nil)
25
26
  end
26
27
  end
27
28
 
@@ -14,14 +14,20 @@ module RubyAmazonBedrock
14
14
  # Initializes the AWS BedrockRuntime client.
15
15
  #
16
16
  # @note The AWS credentials and region are fetched from the environment variables.
17
- def initialize(region: nil, access_key_id: nil, secret_access_key: nil)
17
+ def initialize(region: nil, access_key_id: nil, secret_access_key: nil, profile: nil)
18
18
  config = RubyAmazonBedrock.configuration || RubyAmazonBedrock::Configuration.new
19
19
 
20
- @client = Aws::BedrockRuntime::Client.new(
21
- region: region || config.region,
22
- access_key_id: access_key_id || config.access_key_id,
23
- secret_access_key: secret_access_key || config.secret_access_key
24
- )
20
+ @client = if profile
21
+ Aws::BedrockRuntime::Client.new(
22
+ profile: profile
23
+ )
24
+ else
25
+ Aws::BedrockRuntime::Client.new(
26
+ region: region || config.region,
27
+ access_key_id: access_key_id || config.access_key_id,
28
+ secret_access_key: secret_access_key || config.secret_access_key
29
+ )
30
+ end
25
31
  end
26
32
 
27
33
  # Invokes a model using the Bedrock Runtime client.
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyAmazonBedrock
4
+ module PayloadBuilders
5
+ module Meta
6
+ # Llama370bInstructV1 is a subclass of Base. It provides functionalities specific to the Meta
7
+ # Llama 3 70B Instruct model.
8
+ #
9
+ # @see https://us-west-2.console.aws.amazon.com/bedrock/home?region=us-west-2#/providers?model=meta.llama3-70b-instruct-v1:0
10
+ # for more information about the Meta model.
11
+ class Llama370bInstructV1 < Base
12
+ # Returns the model ID for the Meta Llama 3 70B Instruct model.
13
+ #
14
+ # @return [String] 'meta.llama3-70b-chat-v1:0'
15
+ def model_id
16
+ 'meta.llama3-70b-instruct-v1:0'
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyAmazonBedrock
4
+ module PayloadBuilders
5
+ module Meta
6
+ # Llama370bInstructV1 is a subclass of Base. It provides functionalities specific to the Meta
7
+ # Llama 3 70B Instruct model.
8
+ #
9
+ # @see https://us-west-2.console.aws.amazon.com/bedrock/home?region=us-west-2#/providers?model=meta.llama3-8b-instruct-v1:0
10
+ # for more information about the Meta model.
11
+ class Llama38bInstructV1 < Base
12
+ # Returns the model ID for the Meta Llama 3 70B Instruct model.
13
+ #
14
+ # @return [String] 'meta.llama3-8b-instruct-v1:0'
15
+ def model_id
16
+ 'meta.llama3-8b-instruct-v1:0'
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -14,6 +14,8 @@ require_relative 'payload_builders/cohere/embed_english_v3'
14
14
  require_relative 'payload_builders/cohere/embed_multilingual_v3'
15
15
  require_relative 'payload_builders/meta/llama213b_chat_v1'
16
16
  require_relative 'payload_builders/meta/llama270b_chat_v1'
17
+ require_relative 'payload_builders/meta/llama370b_instruct_v1'
18
+ require_relative 'payload_builders/meta/llama38b_instruct_v1'
17
19
  require_relative 'payload_builders/stability_ai/stable_diffusion_xl_v0'
18
20
  require_relative 'payload_builders/stability_ai/stable_diffusion_xl_v1'
19
21
 
@@ -64,6 +66,8 @@ module RubyAmazonBedrock
64
66
  'cohere.embed-multilingual-v3' => PayloadBuilders::Cohere::EmbedMultilingualV3,
65
67
  'meta.llama2-13b-chat-v1' => PayloadBuilders::Meta::Llama213bChatV1,
66
68
  'meta.llama2-70b-chat-v1' => PayloadBuilders::Meta::Llama270bChatV1,
69
+ 'meta.llama3-70b-instruct-v1:0' => PayloadBuilders::Meta::Llama370bInstructV1,
70
+ 'meta.llama3-8b-instruct-v1:0' => PayloadBuilders::Meta::Llama38bInstructV1,
67
71
  'stability.stable-diffusion-xl-v0' => PayloadBuilders::StabilityAi::StableDiffusionXlV0,
68
72
  'stability.stable-diffusion-xl-v1' => PayloadBuilders::StabilityAi::StableDiffusionXlV1
69
73
  }
@@ -55,6 +55,8 @@ module RubyAmazonBedrock
55
55
  'cohere.embed-multilingual-v3' => ResponseBuilders::CohereEmbed,
56
56
  'meta.llama2-13b-chat-v1' => ResponseBuilders::Meta,
57
57
  'meta.llama2-70b-chat-v1' => ResponseBuilders::Meta,
58
+ 'meta.llama3-70b-instruct-v1:0' => ResponseBuilders::Meta,
59
+ 'meta.llama3-8b-instruct-v1:0' => ResponseBuilders::Meta,
58
60
  'stability.stable-diffusion-xl-v0' => ResponseBuilders::StabilityAi,
59
61
  'stability.stable-diffusion-xl-v1' => ResponseBuilders::StabilityAi
60
62
  }
@@ -37,4 +37,5 @@ Gem::Specification.new do |spec|
37
37
 
38
38
  spec.add_dependency "aws-sdk-bedrockruntime", "~> 1.0"
39
39
  spec.add_dependency "aws-sdk-s3", "~> 1.0"
40
+ spec.add_dependency "base64", "~> 0.2"
40
41
  end
@@ -8,7 +8,8 @@ RSpec.describe RubyAmazonBedrock::Client do
8
8
  described_class.new(
9
9
  region: ENV.fetch('AWS_REGION', nil),
10
10
  access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID', nil),
11
- secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY', nil)
11
+ secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY', nil),
12
+ profile: ENV.fetch('AWS_PROFILE', nil)
12
13
  )
13
14
  end
14
15
 
@@ -26,6 +27,8 @@ RSpec.describe RubyAmazonBedrock::Client do
26
27
  'cohere.embed-multilingual-v3',
27
28
  'meta.llama2-13b-chat-v1',
28
29
  'meta.llama2-70b-chat-v1',
30
+ 'meta.llama3-70b-instruct-v1:0',
31
+ 'meta.llama3-8b-instruct-v1:0',
29
32
  'stability.stable-diffusion-xl-v0',
30
33
  'stability.stable-diffusion-xl-v1'
31
34
  ]
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'bedrock_runtime/payload_builders/meta/llama370b_instruct_v1'
5
+
6
+ RSpec.describe RubyAmazonBedrock::PayloadBuilders::Meta::Llama370bInstructV1 do
7
+ let(:prompt) { 'example_prompt' }
8
+ let(:options) { {} }
9
+ let(:body) do
10
+ {
11
+ prompt: prompt,
12
+ max_gen_len: 512,
13
+ temperature: 0.5,
14
+ top_p: 0.9
15
+ }.to_json
16
+ end
17
+
18
+ describe '#build' do
19
+ it_should_behave_like 'a payload builder'
20
+
21
+ context 'with custom parameters' do
22
+ include_context 'meta parameters'
23
+ it_should_behave_like 'a payload builder'
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'bedrock_runtime/payload_builders/meta/llama38b_instruct_v1'
5
+
6
+ RSpec.describe RubyAmazonBedrock::PayloadBuilders::Meta::Llama38bInstructV1 do
7
+ let(:prompt) { 'example_prompt' }
8
+ let(:options) { {} }
9
+ let(:body) do
10
+ {
11
+ prompt: prompt,
12
+ max_gen_len: 512,
13
+ temperature: 0.5,
14
+ top_p: 0.9
15
+ }.to_json
16
+ end
17
+
18
+ describe '#build' do
19
+ it_should_behave_like 'a payload builder'
20
+
21
+ context 'with custom parameters' do
22
+ include_context 'meta parameters'
23
+ it_should_behave_like 'a payload builder'
24
+ end
25
+ end
26
+ end
@@ -19,6 +19,8 @@ RSpec.describe RubyAmazonBedrock::PayloadFactory do
19
19
  "cohere.embed-multilingual-v3",
20
20
  "meta.llama2-13b-chat-v1",
21
21
  "meta.llama2-70b-chat-v1",
22
+ "meta.llama3-70b-instruct-v1:0",
23
+ "meta.llama3-8b-instruct-v1:0",
22
24
  "stability.stable-diffusion-xl-v0",
23
25
  "stability.stable-diffusion-xl-v1"]
24
26
  end
@@ -48,7 +50,7 @@ RSpec.describe RubyAmazonBedrock::PayloadFactory do
48
50
 
49
51
  describe '#models_to_builders' do
50
52
  it 'defines a mapping of model identifiers to builder classes' do
51
- expect(models_mapping.keys).to eq(bedrock_models)
53
+ expect(models_mapping.keys).to contain_exactly(*bedrock_models)
52
54
  end
53
55
  end
54
56
  end
@@ -0,0 +1,73 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://bedrock-runtime.us-east-1.amazonaws.com/model/meta.llama3-70b-instruct-v1:0/invoke
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"prompt":"Give me a short list of steps for creating a Ruby gem","max_gen_len":512,"temperature":0.5,"top_p":0.9}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - ''
12
+ Amz-Sdk-Invocation-Id:
13
+ - 32851ae6-1618-400a-9411-11d6d3d67636
14
+ Content-Type:
15
+ - application/json
16
+ Accept:
17
+ - "*/*"
18
+ User-Agent:
19
+ - aws-sdk-ruby3/3.201.4 ua/2.1 api/bedrock_runtime#1.17.0 os/macos#23 md/arm64
20
+ lang/ruby#3.0.0 md/3.0.0 m/D
21
+ Host:
22
+ - bedrock-runtime.us-east-1.amazonaws.com
23
+ X-Amz-Date:
24
+ - 20240917T163051Z
25
+ X-Amz-Content-Sha256:
26
+ - cf1ec2da83f5824b04de33922f5727968ac482454a9af56c2c3119c6711f2b1e
27
+ Authorization:
28
+ - AWS4-HMAC-SHA256 Credential=AKIASKU7DUX5LSIDI7FA/20240917/us-east-1/bedrock/aws4_request,
29
+ SignedHeaders=accept;amz-sdk-invocation-id;content-type;host;x-amz-content-sha256;x-amz-date,
30
+ Signature=c2858b5790f78f1428b84dace670018733257a68224824485146d1c0a695f0c6
31
+ Content-Length:
32
+ - '114'
33
+ response:
34
+ status:
35
+ code: 200
36
+ message: OK
37
+ headers:
38
+ Date:
39
+ - Tue, 17 Sep 2024 16:31:00 GMT
40
+ Content-Type:
41
+ - application/json
42
+ Content-Length:
43
+ - '1244'
44
+ Connection:
45
+ - keep-alive
46
+ X-Amzn-Requestid:
47
+ - 83c64727-212b-4d5d-a26e-681c991809d3
48
+ X-Amzn-Bedrock-Invocation-Latency:
49
+ - '7293'
50
+ X-Amzn-Bedrock-Output-Token-Count:
51
+ - '293'
52
+ X-Amzn-Bedrock-Input-Token-Count:
53
+ - '12'
54
+ body:
55
+ encoding: UTF-8
56
+ string: '{"generation":".\n\nHere is a short list of steps for creating a Ruby
57
+ gem:\n\n1. **Create a new gem**: Run `gem new my_gem` (replace \"my_gem\"
58
+ with your gem''s name) to create a new gem with the basic directory structure.\n2.
59
+ **Define your gem''s metadata**: Edit the `my_gem.gemspec` file to specify
60
+ your gem''s name, and other metadata such as version, description, and dependencies.\n3.
61
+ **Write your gem''s code**: Create a `lib` directory and add your Ruby code
62
+ to it. This is where you''ll implement the functionality of your gem.\n4.
63
+ **Test your gem**: Create a `test` directory and add test files to it. Use
64
+ a testing framework like RSpec or Minitest to write tests for your gem.\n5.
65
+ **Build and package your gem**: Run `gem build my_gem.gemspec` to build your
66
+ gem, and then `gem push my_gem-0.1.0.gem` (replace \"0.1.0\" with your gem''s
67
+ version) to push it to RubyGems.org.\n6. **Publish your gem**: Go to RubyGems.org
68
+ and create an account if you haven''t already. Then, upload your gem and make
69
+ it publicly available.\n\nThat''s it! Of course, there are many more details
70
+ to consider when creating a Ruby gem, but these steps should give you a good
71
+ starting point.","prompt_token_count":12,"generation_token_count":293,"stop_reason":"stop"}'
72
+ recorded_at: Tue, 17 Sep 2024 16:31:00 GMT
73
+ recorded_with: VCR 6.2.0
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://bedrock-runtime.us-east-1.amazonaws.com/model/meta.llama3-8b-instruct-v1:0/invoke
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"prompt":"Give me a short list of steps for creating a Ruby gem","max_gen_len":512,"temperature":0.5,"top_p":0.9}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - ''
12
+ Amz-Sdk-Invocation-Id:
13
+ - f256772e-a630-485d-b52d-e20311339125
14
+ Content-Type:
15
+ - application/json
16
+ Accept:
17
+ - "*/*"
18
+ User-Agent:
19
+ - aws-sdk-ruby3/3.201.4 ua/2.1 api/bedrock_runtime#1.17.0 os/macos#23 md/arm64
20
+ lang/ruby#3.0.0 md/3.0.0 m/D
21
+ Host:
22
+ - bedrock-runtime.us-east-1.amazonaws.com
23
+ X-Amz-Date:
24
+ - 20240917T163109Z
25
+ X-Amz-Content-Sha256:
26
+ - cf1ec2da83f5824b04de33922f5727968ac482454a9af56c2c3119c6711f2b1e
27
+ Authorization:
28
+ - AWS4-HMAC-SHA256 Credential=AKIASKU7DUX5LSIDI7FA/20240917/us-east-1/bedrock/aws4_request,
29
+ SignedHeaders=accept;amz-sdk-invocation-id;content-type;host;x-amz-content-sha256;x-amz-date,
30
+ Signature=036bf9fb08b5c0308655674b5bd9eec2eb8c347f3b2e712585be1def1c780f69
31
+ Content-Length:
32
+ - '114'
33
+ response:
34
+ status:
35
+ code: 200
36
+ message: OK
37
+ headers:
38
+ Date:
39
+ - Tue, 17 Sep 2024 16:31:13 GMT
40
+ Content-Type:
41
+ - application/json
42
+ Content-Length:
43
+ - '1170'
44
+ Connection:
45
+ - keep-alive
46
+ X-Amzn-Requestid:
47
+ - 1e88ebb3-f78f-4b57-8926-229f8d4dc625
48
+ X-Amzn-Bedrock-Invocation-Latency:
49
+ - '3536'
50
+ X-Amzn-Bedrock-Output-Token-Count:
51
+ - '275'
52
+ X-Amzn-Bedrock-Input-Token-Count:
53
+ - '12'
54
+ body:
55
+ encoding: UTF-8
56
+ string: '{"generation":".\n\nComment by Brian Hays on January 28, 2013 at 9:13am\n\nHere
57
+ are the basic steps for creating a Ruby gem:\n\n1. Create a new directory
58
+ for your gem and navigate to it in your terminal.\n2. Run `gem init` to create
59
+ a basic gem structure.\n3. Edit the `gemspec` file to add information about
60
+ your gem, such as its name, version, and dependencies.\n4. Write your gem''s
61
+ code in the `lib` directory.\n5. Run `gem build` to build your gem.\n6. Run
62
+ `gem push` to publish your gem to a gem server (such as RubyGems.org).\n\nThat''s
63
+ the basic process, but there are many other things you can do to customize
64
+ and improve your gem, such as adding tests, documentation, and a README file.\n\nComment
65
+ by Brian Hays on January 28, 2013 at 9:14am\n\nAlso, you may want to consider
66
+ using a gem template tool like Bundler''s `bundle gem` command or the `gem-skeleton`
67
+ gem to help you get started with creating a new gem. These tools can save
68
+ you some time and effort by creating a basic gem structure for you. Just run
69
+ `bundle gem my_gem` or `gem-skeleton my_gem` and you''ll be off and running!","prompt_token_count":12,"generation_token_count":275,"stop_reason":"stop"}'
70
+ recorded_at: Tue, 17 Sep 2024 16:31:13 GMT
71
+ recorded_with: VCR 6.2.0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-amazon-bedrock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alvaro Delgado
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-12 00:00:00.000000000 Z
11
+ date: 2024-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-bedrockruntime
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: base64
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.2'
41
55
  description: The ruby-amazon-bedrock gem offers Ruby developers an efficient and user-friendly
42
56
  interface to Amazon Bedrock, a powerful library for AI-driven text and image
43
57
  generation. This gem simplifies the process of connecting to Amazon Bedrock's
@@ -50,6 +64,7 @@ extensions: []
50
64
  extra_rdoc_files: []
51
65
  files:
52
66
  - ".circleci/config.yml"
67
+ - ".env.sample"
53
68
  - ".gitignore"
54
69
  - ".rspec"
55
70
  - ".rubocop.yml"
@@ -90,6 +105,8 @@ files:
90
105
  - lib/bedrock_runtime/payload_builders/meta/base.rb
91
106
  - lib/bedrock_runtime/payload_builders/meta/llama213b_chat_v1.rb
92
107
  - lib/bedrock_runtime/payload_builders/meta/llama270b_chat_v1.rb
108
+ - lib/bedrock_runtime/payload_builders/meta/llama370b_instruct_v1.rb
109
+ - lib/bedrock_runtime/payload_builders/meta/llama38b_instruct_v1.rb
93
110
  - lib/bedrock_runtime/payload_builders/stability_ai/base.rb
94
111
  - lib/bedrock_runtime/payload_builders/stability_ai/stable_diffusion_xl_v0.rb
95
112
  - lib/bedrock_runtime/payload_builders/stability_ai/stable_diffusion_xl_v1.rb
@@ -128,6 +145,8 @@ files:
128
145
  - spec/bedrock_runtime/payload_builders/meta/base_spec.rb
129
146
  - spec/bedrock_runtime/payload_builders/meta/llama213b_chat_v1_spec.rb
130
147
  - spec/bedrock_runtime/payload_builders/meta/llama270b_chat_v1_spec.rb
148
+ - spec/bedrock_runtime/payload_builders/meta/llama370b_instruct_v1_spec.rb
149
+ - spec/bedrock_runtime/payload_builders/meta/llama38b_instruct_v1_spec.rb
131
150
  - spec/bedrock_runtime/payload_builders/stability_ai/base_spec.rb
132
151
  - spec/bedrock_runtime/payload_builders/stability_ai/stable_diffusion_xl_v0_spec.rb
133
152
  - spec/bedrock_runtime/payload_builders/stability_ai/stable_diffusion_xl_v1_spec.rb
@@ -148,6 +167,8 @@ files:
148
167
  - spec/cassettes/models/errors/not_found.yml
149
168
  - spec/cassettes/models/meta_llama2-13b-chat-v1.yml
150
169
  - spec/cassettes/models/meta_llama2-70b-chat-v1.yml
170
+ - spec/cassettes/models/meta_llama3-70b-instruct-v1_0.yml
171
+ - spec/cassettes/models/meta_llama3-8b-instruct-v1_0.yml
151
172
  - spec/cassettes/models/stability_stable-diffusion-xl-v0.yml
152
173
  - spec/cassettes/models/stability_stable-diffusion-xl-v1.yml
153
174
  - spec/fixtures/sample_image.jpg
@@ -176,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
197
  - !ruby/object:Gem::Version
177
198
  version: '0'
178
199
  requirements: []
179
- rubygems_version: 3.4.22
200
+ rubygems_version: 3.2.3
180
201
  signing_key:
181
202
  specification_version: 4
182
203
  summary: Seamless Integration with Amazon Bedrock for AI-Powered Text and Image Generation