anthropic 1.15.0 → 1.15.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: 96fbec3c8e86823794c9559e8ff4e1967abec7788c4f8933e43891d6700fe911
4
- data.tar.gz: 45edb4c50ecabd23c527f5f9a3a6a5c636657d6dfd45520d950bd366fc99f036
3
+ metadata.gz: 4ced85b0845309fa483a95e407acb558e39bccf379888470f19a8c1eae31e907
4
+ data.tar.gz: 14578f144cd3cbfc87f893778708dc0edc4f6e688b38f190282d3aa1281b37b2
5
5
  SHA512:
6
- metadata.gz: 574a806f729e6eb29debde3a6440f47a6e9dc7703d3c7a9b34ed2865d2240e1e00d3cabedde20c64e8283d1556142adb8f102b17610bb622a7861390f9155de6
7
- data.tar.gz: 9b10f42e58ff25f85123cac98231a38104e15fe7245779969d0db4f4b1da71441be662071dfe2c6c4e1663de02f22710ec7f66930ea6c31a0e4262b2a1aa3742
6
+ metadata.gz: 57200336a627b02746585da5c51260c9d59abfbc6727244370e6b4ff1a3d1abc47c0f24bfdcecb7ca474fed1e79aedc829c3e3d886af298efb1dcd3e4670df44
7
+ data.tar.gz: 249c20c997d69379e5eb9195639da67da2a46834a6bb20672e1993ccc794d10e5471911dc7237fa94c56a00eb67dd88841a1cbf19ae7435712f05369223f6c4e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.15.1 (2025-11-14)
4
+
5
+ Full Changelog: [v1.15.0...v1.15.1](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.15.0...v1.15.1)
6
+
3
7
  ## 1.15.0 (2025-11-14)
4
8
 
5
9
  Full Changelog: [v1.14.0...v1.15.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.14.0...v1.15.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.15.0"
18
+ gem "anthropic", "~> 1.15.1"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -20,18 +20,13 @@ module Anthropic
20
20
 
21
21
  case data
22
22
  in {tools: Array => tool_array}
23
- # rubocop:disable Metrics/BlockLength
24
23
  mapped = tool_array.map do |tool|
25
24
  case tool
26
25
  # Direct tool class:
27
26
  in Anthropic::Helpers::InputSchema::JsonSchemaConverter
28
27
  classname = tool.is_a?(Anthropic::Helpers::Tools::BaseTool) ? tool.class.name : tool.name
29
- name = classname
30
- .split("::")
31
- .last
32
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
33
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
34
- .downcase
28
+ name = model_name(classname)
29
+
35
30
  description =
36
31
  case tool
37
32
  in Anthropic::Helpers::Tools::BaseTool
@@ -59,9 +54,20 @@ module Anthropic
59
54
  end
60
55
  end
61
56
  tool_array.replace(mapped)
57
+ in {output_format: Anthropic::Helpers::InputSchema::JsonSchemaConverter => model}
58
+ name = model_name(model.name)
59
+ models.store(name, model)
60
+ schema = model.to_json_schema
61
+ Anthropic::Helpers::InputSchema::SupportedSchemas.transform_schema!(schema)
62
+ data.update(output_format: {type: :json_schema, schema: schema})
63
+ in {output_format: {schema: Anthropic::Helpers::StructuredOutput::JsonSchemaConverter => model} => output_format}
64
+ name = model_name(model.name)
65
+ models.store(name, model)
66
+ schema = model.to_json_schema
67
+ Anthropic::Helpers::InputSchema::SupportedSchemas.transform_schema!(schema)
68
+ output_format.update(type: :json_schema, schema:)
62
69
  else
63
70
  end
64
- # rubocop:enable Metrics/BlockLength
65
71
 
66
72
  [tools, models]
67
73
  end
@@ -101,6 +107,20 @@ module Anthropic
101
107
 
102
108
  raw
103
109
  end
110
+
111
+ # @api private
112
+ #
113
+ # @param classname [String]
114
+ #
115
+ # @return [String]
116
+ private def model_name(classname)
117
+ classname
118
+ .split("::")
119
+ .last
120
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
121
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
122
+ .downcase
123
+ end
104
124
  end
105
125
  end
106
126
  end
@@ -278,7 +278,6 @@ module Anthropic
278
278
  @accumated_message_snapshot = nil
279
279
  # Mapping of tool names to model classes for parsing.
280
280
  @tools = tools
281
- # Mapping of tool names to model classes for parsing.
282
281
  @models = models
283
282
  # Lazy enumerable that transforms raw events into consumable events.
284
283
  @iterator = iterator
@@ -59,6 +59,18 @@ module Anthropic
59
59
  # @return [Array<Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaWebFetchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaBashCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaTextEditorCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock>]
60
60
  required :content, -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaContentBlock] }
61
61
 
62
+ # parsed value of response when a JSON output schema object has been specified via :output_format
63
+ #
64
+ # @return [Object, nil]
65
+ def parsed_output
66
+ case content
67
+ in [*, {parsed:}]
68
+ parsed
69
+ else
70
+ nil
71
+ end
72
+ end
73
+
62
74
  # @!attribute context_management
63
75
  # Context management response.
64
76
  #
@@ -21,6 +21,14 @@ module Anthropic
21
21
  # @return [String]
22
22
  required :text, String
23
23
 
24
+ response_only do
25
+ # @!attribute parsed
26
+ # parsed value of `#text` when a JSON output schema object has been specified
27
+ #
28
+ # @return [Object, nil]
29
+ optional :parsed, Anthropic::Helpers::InputSchema::ParsedJson
30
+ end
31
+
24
32
  # @!attribute type
25
33
  #
26
34
  # @return [Symbol, :text]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anthropic
4
- VERSION = "1.15.0"
4
+ VERSION = "1.15.1"
5
5
  end
@@ -51,7 +51,14 @@ module Anthropic
51
51
  def text
52
52
  end
53
53
 
54
- sig { returns(Anthropic::Models::Message) }
54
+ sig do
55
+ returns(
56
+ T.any(
57
+ Anthropic::Models::Message,
58
+ Anthropic::Models::Beta::BetaMessage
59
+ )
60
+ )
61
+ end
55
62
  def accumulated_message
56
63
  end
57
64
 
@@ -12,7 +12,9 @@ module Anthropic
12
12
  class << self
13
13
  # @api public
14
14
  #
15
- sig { returns(T.class_of(Anthropic::Helpers::InputSchema::BaseModel)) }
15
+ sig do
16
+ returns(T.class_of(Anthropic::Helpers::InputSchema::BaseModel))
17
+ end
16
18
  attr_reader :model
17
19
 
18
20
  sig { returns(T.class_of(String)) }
@@ -28,7 +30,11 @@ module Anthropic
28
30
 
29
31
  # @api public
30
32
  #
31
- sig { params(model: T.class_of(Anthropic::Helpers::InputSchema::BaseModel)).returns(T.class_of(Anthropic::Helpers::InputSchema::BaseModel)) }
33
+ sig do
34
+ params(
35
+ model: T.class_of(Anthropic::Helpers::InputSchema::BaseModel)
36
+ ).returns(T.class_of(Anthropic::Helpers::InputSchema::BaseModel))
37
+ end
32
38
  def input_schema(model) = (@model = model)
33
39
  end
34
40
 
@@ -42,7 +48,11 @@ module Anthropic
42
48
 
43
49
  # @api public
44
50
  #
45
- sig { params(parsed: Anthropic::Helpers::InputSchema::BaseModel).returns(T.anything) }
51
+ sig do
52
+ params(parsed: Anthropic::Helpers::InputSchema::BaseModel).returns(
53
+ T.anything
54
+ )
55
+ end
46
56
  def call(parsed)
47
57
  end
48
58
  end
@@ -10,30 +10,36 @@ module Anthropic
10
10
  attr_accessor :params
11
11
 
12
12
  sig { returns(T::Boolean) }
13
- def finished?; end
13
+ def finished?
14
+ end
14
15
 
15
16
  sig { params(messages: Anthropic::Models::Beta::BetaMessageParam).void }
16
- def feed_messages(*messages); end
17
+ def feed_messages(*messages)
18
+ end
17
19
 
18
20
  sig { returns(Anthropic::Models::BetaMessage) }
19
- def next_message; end
21
+ def next_message
22
+ end
20
23
 
21
24
  sig { returns(T::Array[Anthropic::Models::BetaMessage]) }
22
- def run_until_finished; end
25
+ def run_until_finished
26
+ end
23
27
 
24
28
  sig do
25
29
  params(
26
30
  blk: T.proc.params(arg0: Anthropic::Models::BetaMessage).void
27
31
  ).void
28
32
  end
29
- def each_message(&blk); end
33
+ def each_message(&blk)
34
+ end
30
35
 
31
36
  sig do
32
37
  params(
33
38
  blk: T.proc.params(arg0: Anthropic::Streaming::MessageStream).void
34
39
  ).void
35
40
  end
36
- def each_streaming(&blk); end
41
+ def each_streaming(&blk)
42
+ end
37
43
  end
38
44
  end
39
45
  end
@@ -20,6 +20,9 @@ module Anthropic
20
20
  sig { returns(T::Hash[Symbol, T.anything]) }
21
21
  attr_accessor :input
22
22
 
23
+ sig { returns(T.nilable(T.anything)) }
24
+ attr_accessor :parsed
25
+
23
26
  # The name of the MCP tool
24
27
  sig { returns(String) }
25
28
  attr_accessor :name
@@ -29,6 +29,10 @@ module Anthropic
29
29
  end
30
30
  attr_writer :container
31
31
 
32
+ sig { returns(T.nilable(T.anything)) }
33
+ def parsed_output
34
+ end
35
+
32
36
  # Content generated by the model.
33
37
  #
34
38
  # This is an array of content blocks, each of which has a `type` that determines
@@ -26,6 +26,10 @@ module Anthropic
26
26
  sig { returns(String) }
27
27
  attr_accessor :text
28
28
 
29
+ # parsed value of `#text` when a JSON output schema object has been specified
30
+ sig { returns(T.nilable(T.anything)) }
31
+ attr_accessor :parsed
32
+
29
33
  sig { returns(Symbol) }
30
34
  attr_accessor :type
31
35
 
@@ -14,15 +14,15 @@ module Anthropic
14
14
  sig { returns(T::Hash[Symbol, T.anything]) }
15
15
  attr_accessor :input
16
16
 
17
+ sig { returns(T.nilable(T.anything)) }
18
+ attr_accessor :parsed
19
+
17
20
  sig { returns(String) }
18
21
  attr_accessor :name
19
22
 
20
23
  sig { returns(Symbol) }
21
24
  attr_accessor :type
22
25
 
23
- sig { returns(T.nilable(T.anything)) }
24
- attr_accessor :parsed
25
-
26
26
  sig do
27
27
  params(
28
28
  id: String,
@@ -34,7 +34,8 @@ module Anthropic
34
34
 
35
35
  def text: -> Enumerator[String]
36
36
 
37
- def accumulated_message: -> Anthropic::Models::message
37
+ def accumulated_message: -> (Anthropic::Models::message
38
+ | Anthropic::Models::Beta::BetaMessage)
38
39
 
39
40
  def accumulated_text: -> String
40
41
 
@@ -24,6 +24,8 @@ module Anthropic
24
24
 
25
25
  attr_accessor content: ::Array[Anthropic::Models::Beta::beta_content_block]
26
26
 
27
+ def output_format: -> top
28
+
27
29
  attr_accessor context_management: Anthropic::Beta::BetaContextManagementResponse?
28
30
 
29
31
  attr_accessor model: Anthropic::Models::model
@@ -15,6 +15,8 @@ module Anthropic
15
15
 
16
16
  attr_accessor text: String
17
17
 
18
+ attr_accessor parsed: top
19
+
18
20
  attr_accessor type: :text
19
21
 
20
22
  def initialize: (
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anthropic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.0
4
+ version: 1.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthropic