anthropic 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3aeac8c8f19023ee694cd9c7ad3e5dd99e0e7048a811454efff82c00fe7a12b
4
- data.tar.gz: 8fd8babb73990354a553654be7613e5c182432e50b81b89080da9e0b450bfb63
3
+ metadata.gz: 5dccfd318c0bef10694a1aa969a9d5bb6e5f0783fb3e64a0beb395622f26f5b5
4
+ data.tar.gz: 60de84ff4313a79ce191da92d5afda97111f133e90031e823d1a8951357145be
5
5
  SHA512:
6
- metadata.gz: b47bef5c4483f716d55955a14d6692baacc3cacdee9be3c2470ec89f334f74fdacec4267181e20ac6971f3624c474d6e154579084ed73162d131fd4407621c56
7
- data.tar.gz: d91553e354390a3447f50d1927e60244783ee1070aca2acd28aeaa02e4365bf0926c01ab3d9f8810c7e54219985d43ef5e24d0decfb9a62af5ea7d42880ae970
6
+ metadata.gz: f6adf3c9d40f3554544c8e7ec818c47273fc2bc1c4b0afdbc9f0f7f04c316850ec4886d6974ba3fdb91e8d9090c39a41685db95ed40e14e4be071ebd777878a2
7
+ data.tar.gz: 6f37c51597136d2038d5a648d26811e41b32e0d9ffb7acbc873852748895d8e999a882bd44439223108137d3f4ed588dbbd39900d109d075c6584d9c7897a4de
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.1 (2025-08-07)
4
+
5
+ Full Changelog: [v1.4.0...v1.4.1](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.4.0...v1.4.1)
6
+
7
+ ### Bug Fixes
8
+
9
+ * aws bedrock should sign each request follow retries ([#672](https://github.com/anthropics/anthropic-sdk-ruby/issues/672)) ([df9f4e1](https://github.com/anthropics/anthropic-sdk-ruby/commit/df9f4e1aa7e7211dab3d36dd9093092d20649359))
10
+
3
11
  ## 1.4.0 (2025-08-05)
4
12
 
5
13
  Full Changelog: [v1.3.0...v1.4.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.3.0...v1.4.0)
data/README.md CHANGED
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
15
15
  <!-- x-release-please-start-version -->
16
16
 
17
17
  ```ruby
18
- gem "anthropic", "~> 1.4.0"
18
+ gem "anthropic", "~> 1.4.1"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -50,10 +50,10 @@ module Anthropic
50
50
  def initialize(
51
51
  aws_region: nil,
52
52
  base_url: nil,
53
- max_retries: DEFAULT_MAX_RETRIES,
54
- timeout: DEFAULT_TIMEOUT_IN_SECONDS,
55
- initial_retry_delay: DEFAULT_INITIAL_RETRY_DELAY,
56
- max_retry_delay: DEFAULT_MAX_RETRY_DELAY,
53
+ max_retries: self.class::DEFAULT_MAX_RETRIES,
54
+ timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
55
+ initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
56
+ max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY,
57
57
  aws_access_key: nil,
58
58
  aws_secret_key: nil,
59
59
  aws_session_token: nil,
@@ -113,56 +113,33 @@ module Anthropic
113
113
 
114
114
  # @api private
115
115
  #
116
- # @param req [Hash{Symbol=>Object}] .
116
+ # Very private API, do not use
117
117
  #
118
- # @option req [Symbol] :method
118
+ # @param request [Hash{Symbol=>Object}] .
119
119
  #
120
- # @option req [String, Array<String>] :path
120
+ # @option request [Symbol] :method
121
121
  #
122
- # @option req [Hash{String=>Array<String>, String, nil}, nil] :query
122
+ # @option request [URI::Generic] :url
123
123
  #
124
- # @option req [Hash{String=>String, Integer, Array<String, Integer, nil>, nil}, nil] :headers
124
+ # @option request [Hash{String=>String}] :headers
125
125
  #
126
- # @option req [Object, nil] :body
126
+ # @option request [Object] :body
127
127
  #
128
- # @option req [Symbol, Integer, Array<Symbol, Integer>, Proc, nil] :unwrap
129
- #
130
- # @option req [Class<Anthropic::Internal::Type::BasePage>, nil] :page
131
- #
132
- # @option req [Class<Anthropic::Internal::Type::BaseStream>, nil] :stream
133
- #
134
- # @option req [Anthropic::Internal::Type::Converter, Class, nil] :model
135
- #
136
- # @param opts [Hash{Symbol=>Object}] .
137
- #
138
- # @option opts [String, nil] :idempotency_key
139
- #
140
- # @option opts [Hash{String=>Array<String>, String, nil}, nil] :extra_query
141
- #
142
- # @option opts [Hash{String=>String, nil}, nil] :extra_headers
143
- #
144
- # @option opts [Object, nil] :extra_body
145
- #
146
- # @option opts [Integer, nil] :max_retries
147
- #
148
- # @option opts [Float, nil] :timeout
149
- #
150
- # @return [Hash{Symbol=>Object}]
151
- private def build_request(req, opts)
152
- fit_req_to_bedrock_specs!(req)
153
-
154
- request_input = super
155
-
156
- signed_request = @signer.sign_request(
157
- http_method: request_input[:method],
158
- url: request_input[:url],
159
- headers: request_input[:headers],
160
- body: request_input[:body]
161
- )
128
+ # @return [Hash{Symbol, Object}]
129
+ protected def transform_request(request)
130
+ fit_req_to_bedrock_specs!(request)
131
+ sliced = super.slice(
132
+ :method,
133
+ :url,
134
+ :headers,
135
+ :body
136
+ ).transform_keys(method: :http_method)
137
+ body = StringIO.new(body.to_a.join) if (body = sliced.fetch(:body)).is_a?(Enumerator)
162
138
 
163
- request_input[:headers].merge!(signed_request.headers)
139
+ signed = @signer.sign_request({**sliced, body: body})
164
140
 
165
- request_input
141
+ headers = Anthropic::Internal::Util.normalized_headers(request.fetch(:headers), signed.headers)
142
+ {**request, headers: headers}
166
143
  end
167
144
 
168
145
  # @param aws_region [String, nil]
@@ -341,6 +341,23 @@ module Anthropic
341
341
  (@initial_retry_delay * scale * jitter).clamp(0, @max_retry_delay)
342
342
  end
343
343
 
344
+ # @api private
345
+ #
346
+ # Very private API, do not use
347
+ #
348
+ # @param request [Hash{Symbol=>Object}] .
349
+ #
350
+ # @option request [Symbol] :method
351
+ #
352
+ # @option request [URI::Generic] :url
353
+ #
354
+ # @option request [Hash{String=>String}] :headers
355
+ #
356
+ # @option request [Object] :body
357
+ #
358
+ # @return [Hash{Symbol, Object}]
359
+ protected def transform_request(request) = request
360
+
344
361
  # @api private
345
362
  #
346
363
  # @param request [Hash{Symbol=>Object}] .
@@ -366,6 +383,7 @@ module Anthropic
366
383
  # @raise [Anthropic::Errors::APIError]
367
384
  # @return [Array(Integer, Net::HTTPResponse, Enumerable<String>)]
368
385
  def send_request(request, redirect_count:, retry_count:, send_retry_header:)
386
+ request = transform_request(request)
369
387
  url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout)
370
388
  input = {**request.except(:timeout), deadline: Anthropic::Internal::Util.monotonic_secs + timeout}
371
389
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anthropic
4
- VERSION = "1.4.0"
4
+ VERSION = "1.4.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anthropic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthropic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-08-05 00:00:00.000000000 Z
11
+ date: 2025-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool