anthropic 1.1.1 → 1.3.0

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.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +69 -0
  3. data/README.md +32 -16
  4. data/lib/anthropic/errors.rb +22 -0
  5. data/lib/anthropic/helpers/streaming/events.rb +141 -0
  6. data/lib/anthropic/helpers/streaming/message_stream.rb +238 -0
  7. data/lib/anthropic/helpers/streaming.rb +37 -0
  8. data/lib/anthropic/helpers/vertex/client.rb +4 -1
  9. data/lib/anthropic/internal/stream.rb +4 -2
  10. data/lib/anthropic/internal/transport/base_client.rb +10 -2
  11. data/lib/anthropic/internal/type/array_of.rb +6 -1
  12. data/lib/anthropic/internal/type/base_model.rb +77 -23
  13. data/lib/anthropic/internal/type/base_stream.rb +3 -1
  14. data/lib/anthropic/internal/type/boolean.rb +7 -1
  15. data/lib/anthropic/internal/type/converter.rb +42 -34
  16. data/lib/anthropic/internal/type/enum.rb +16 -5
  17. data/lib/anthropic/internal/type/file_input.rb +6 -1
  18. data/lib/anthropic/internal/type/hash_of.rb +6 -1
  19. data/lib/anthropic/internal/type/union.rb +17 -9
  20. data/lib/anthropic/internal/type/unknown.rb +7 -1
  21. data/lib/anthropic/internal/util.rb +8 -9
  22. data/lib/anthropic/models/beta/beta_base64_pdf_block.rb +1 -65
  23. data/lib/anthropic/models/beta/beta_citation_search_result_location.rb +55 -0
  24. data/lib/anthropic/models/beta/beta_citation_search_result_location_param.rb +55 -0
  25. data/lib/anthropic/models/beta/beta_citations_delta.rb +5 -3
  26. data/lib/anthropic/models/beta/beta_content_block.rb +5 -5
  27. data/lib/anthropic/models/beta/beta_content_block_param.rb +20 -17
  28. data/lib/anthropic/models/beta/beta_message.rb +6 -2
  29. data/lib/anthropic/models/beta/beta_message_param.rb +3 -3
  30. data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +7 -7
  31. data/lib/anthropic/models/beta/beta_request_document_block.rb +75 -0
  32. data/lib/anthropic/models/beta/beta_search_result_block_param.rb +55 -0
  33. data/lib/anthropic/models/beta/beta_text_block.rb +2 -2
  34. data/lib/anthropic/models/beta/beta_text_block_param.rb +2 -2
  35. data/lib/anthropic/models/beta/beta_text_citation.rb +3 -1
  36. data/lib/anthropic/models/beta/beta_text_citation_param.rb +3 -1
  37. data/lib/anthropic/models/beta/beta_tool.rb +7 -1
  38. data/lib/anthropic/models/beta/beta_tool_result_block_param.rb +6 -4
  39. data/lib/anthropic/models/beta/beta_tool_union.rb +7 -7
  40. data/lib/anthropic/models/beta/message_count_tokens_params.rb +16 -10
  41. data/lib/anthropic/models/beta/message_create_params.rb +9 -3
  42. data/lib/anthropic/models/beta/messages/batch_create_params.rb +9 -3
  43. data/lib/anthropic/models/content_block.rb +5 -5
  44. data/lib/anthropic/models/content_block_param.rb +11 -11
  45. data/lib/anthropic/models/message.rb +6 -2
  46. data/lib/anthropic/models/message_count_tokens_params.rb +9 -3
  47. data/lib/anthropic/models/message_count_tokens_tool.rb +35 -1
  48. data/lib/anthropic/models/message_create_params.rb +9 -3
  49. data/lib/anthropic/models/message_param.rb +3 -3
  50. data/lib/anthropic/models/messages/batch_create_params.rb +9 -3
  51. data/lib/anthropic/models/model.rb +5 -21
  52. data/lib/anthropic/models/raw_content_block_start_event.rb +7 -7
  53. data/lib/anthropic/models/tool.rb +7 -1
  54. data/lib/anthropic/models/tool_union.rb +34 -1
  55. data/lib/anthropic/models/tool_use_block.rb +6 -0
  56. data/lib/anthropic/models.rb +4 -4
  57. data/lib/anthropic/resources/beta/messages.rb +73 -6
  58. data/lib/anthropic/resources/messages.rb +68 -7
  59. data/lib/anthropic/streaming.rb +5 -0
  60. data/lib/anthropic/version.rb +1 -1
  61. data/lib/anthropic.rb +8 -0
  62. data/rbi/anthropic/errors.rbi +16 -0
  63. data/rbi/anthropic/helpers/bedrock/client.rbi +17 -6
  64. data/rbi/anthropic/helpers/streaming/events.rbi +95 -0
  65. data/rbi/anthropic/helpers/streaming/message_stream.rbi +73 -0
  66. data/rbi/anthropic/helpers/vertex/client.rbi +17 -6
  67. data/rbi/anthropic/internal/type/base_stream.rbi +8 -1
  68. data/rbi/anthropic/internal/type/boolean.rbi +2 -0
  69. data/rbi/anthropic/internal/type/converter.rbi +15 -15
  70. data/rbi/anthropic/internal/type/union.rbi +5 -0
  71. data/rbi/anthropic/internal/type/unknown.rbi +2 -0
  72. data/rbi/anthropic/internal/util.rbi +2 -0
  73. data/rbi/anthropic/models/beta/beta_base64_pdf_block.rbi +1 -128
  74. data/rbi/anthropic/models/beta/beta_citation_search_result_location.rbi +78 -0
  75. data/rbi/anthropic/models/beta/beta_citation_search_result_location_param.rbi +79 -0
  76. data/rbi/anthropic/models/beta/beta_citations_delta.rbi +4 -2
  77. data/rbi/anthropic/models/beta/beta_content_block.rbi +3 -3
  78. data/rbi/anthropic/models/beta/beta_content_block_param.rbi +8 -7
  79. data/rbi/anthropic/models/beta/beta_message.rbi +11 -3
  80. data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +6 -6
  81. data/rbi/anthropic/models/beta/beta_request_document_block.rbi +140 -0
  82. data/rbi/anthropic/models/beta/beta_search_result_block_param.rbi +91 -0
  83. data/rbi/anthropic/models/beta/beta_text_block.rbi +2 -1
  84. data/rbi/anthropic/models/beta/beta_text_block_param.rbi +6 -3
  85. data/rbi/anthropic/models/beta/beta_text_citation.rbi +2 -1
  86. data/rbi/anthropic/models/beta/beta_text_citation_param.rbi +2 -1
  87. data/rbi/anthropic/models/beta/beta_tool.rbi +14 -5
  88. data/rbi/anthropic/models/beta/beta_tool_result_block_param.rbi +2 -1
  89. data/rbi/anthropic/models/beta/beta_tool_union.rbi +5 -5
  90. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +39 -27
  91. data/rbi/anthropic/models/beta/message_create_params.rbi +34 -22
  92. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +34 -22
  93. data/rbi/anthropic/models/content_block.rbi +3 -3
  94. data/rbi/anthropic/models/content_block_param.rbi +5 -5
  95. data/rbi/anthropic/models/message.rbi +11 -3
  96. data/rbi/anthropic/models/message_count_tokens_params.rbi +18 -2
  97. data/rbi/anthropic/models/message_count_tokens_tool.rbi +61 -0
  98. data/rbi/anthropic/models/message_create_params.rbi +18 -2
  99. data/rbi/anthropic/models/messages/batch_create_params.rbi +18 -2
  100. data/rbi/anthropic/models/model.rbi +0 -8
  101. data/rbi/anthropic/models/raw_content_block_start_event.rbi +6 -6
  102. data/rbi/anthropic/models/tool.rbi +16 -5
  103. data/rbi/anthropic/models/tool_union.rbi +61 -0
  104. data/rbi/anthropic/resources/beta/messages.rbi +36 -18
  105. data/rbi/anthropic/resources/messages.rbi +315 -3
  106. data/rbi/anthropic/streaming.rbi +5 -0
  107. data/sig/anthropic/errors.rbs +9 -0
  108. data/sig/anthropic/helpers/streaming/events.rbs +117 -0
  109. data/sig/anthropic/helpers/streaming/message_stream.rbs +57 -0
  110. data/sig/anthropic/internal/type/base_stream.rbs +4 -0
  111. data/sig/anthropic/internal/type/converter.rbs +7 -1
  112. data/sig/anthropic/models/beta/beta_base64_pdf_block.rbs +1 -58
  113. data/sig/anthropic/models/beta/beta_citation_search_result_location.rbs +54 -0
  114. data/sig/anthropic/models/beta/beta_citation_search_result_location_param.rbs +54 -0
  115. data/sig/anthropic/models/beta/beta_citations_delta.rbs +1 -0
  116. data/sig/anthropic/models/beta/beta_content_block.rbs +2 -2
  117. data/sig/anthropic/models/beta/beta_content_block_param.rbs +9 -8
  118. data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +2 -2
  119. data/sig/anthropic/models/beta/beta_request_document_block.rbs +66 -0
  120. data/sig/anthropic/models/beta/beta_search_result_block_param.rbs +53 -0
  121. data/sig/anthropic/models/beta/beta_text_citation.rbs +1 -0
  122. data/sig/anthropic/models/beta/beta_text_citation_param.rbs +1 -0
  123. data/sig/anthropic/models/beta/beta_tool.rbs +14 -3
  124. data/sig/anthropic/models/beta/beta_tool_result_block_param.rbs +1 -0
  125. data/sig/anthropic/models/beta/beta_tool_union.rbs +4 -4
  126. data/sig/anthropic/models/beta/message_count_tokens_params.rbs +4 -4
  127. data/sig/anthropic/models/content_block.rbs +2 -2
  128. data/sig/anthropic/models/content_block_param.rbs +5 -5
  129. data/sig/anthropic/models/message_count_tokens_tool.rbs +28 -0
  130. data/sig/anthropic/models/model.rbs +0 -10
  131. data/sig/anthropic/models/raw_content_block_start_event.rbs +2 -2
  132. data/sig/anthropic/models/tool.rbs +14 -3
  133. data/sig/anthropic/models/tool_union.rbs +28 -0
  134. data/sig/anthropic/streaming.rbs +3 -0
  135. metadata +26 -3
@@ -28,11 +28,11 @@ module Anthropic
28
28
 
29
29
  type content_block =
30
30
  Anthropic::TextBlock
31
+ | Anthropic::ThinkingBlock
32
+ | Anthropic::RedactedThinkingBlock
31
33
  | Anthropic::ToolUseBlock
32
34
  | Anthropic::ServerToolUseBlock
33
35
  | Anthropic::WebSearchToolResultBlock
34
- | Anthropic::ThinkingBlock
35
- | Anthropic::RedactedThinkingBlock
36
36
 
37
37
  module ContentBlock
38
38
  extend Anthropic::Internal::Type::Union
@@ -38,16 +38,27 @@ module Anthropic
38
38
  type: Anthropic::Models::Tool::type_?
39
39
  }
40
40
 
41
- type input_schema = { type: :object, properties: top? }
41
+ type input_schema =
42
+ { type: :object, properties: top?, required: ::Array[String]? }
42
43
 
43
44
  class InputSchema < Anthropic::Internal::Type::BaseModel
44
45
  attr_accessor type: :object
45
46
 
46
47
  attr_accessor properties: top?
47
48
 
48
- def initialize: (?properties: top?, ?type: :object) -> void
49
+ attr_accessor required: ::Array[String]?
49
50
 
50
- def to_hash: -> { type: :object, properties: top? }
51
+ def initialize: (
52
+ ?properties: top?,
53
+ ?required: ::Array[String]?,
54
+ ?type: :object
55
+ ) -> void
56
+
57
+ def to_hash: -> {
58
+ type: :object,
59
+ properties: top?,
60
+ required: ::Array[String]?
61
+ }
51
62
  end
52
63
 
53
64
  type type_ = :custom
@@ -4,11 +4,39 @@ module Anthropic
4
4
  Anthropic::Tool
5
5
  | Anthropic::ToolBash20250124
6
6
  | Anthropic::ToolTextEditor20250124
7
+ | Anthropic::ToolUnion::TextEditor20250429
7
8
  | Anthropic::WebSearchTool20250305
8
9
 
9
10
  module ToolUnion
10
11
  extend Anthropic::Internal::Type::Union
11
12
 
13
+ type text_editor20250429 =
14
+ {
15
+ name: :str_replace_based_edit_tool,
16
+ type: :text_editor_20250429,
17
+ cache_control: Anthropic::CacheControlEphemeral?
18
+ }
19
+
20
+ class TextEditor20250429 < Anthropic::Internal::Type::BaseModel
21
+ attr_accessor name: :str_replace_based_edit_tool
22
+
23
+ attr_accessor type: :text_editor_20250429
24
+
25
+ attr_accessor cache_control: Anthropic::CacheControlEphemeral?
26
+
27
+ def initialize: (
28
+ ?cache_control: Anthropic::CacheControlEphemeral?,
29
+ ?name: :str_replace_based_edit_tool,
30
+ ?type: :text_editor_20250429
31
+ ) -> void
32
+
33
+ def to_hash: -> {
34
+ name: :str_replace_based_edit_tool,
35
+ type: :text_editor_20250429,
36
+ cache_control: Anthropic::CacheControlEphemeral?
37
+ }
38
+ end
39
+
12
40
  def self?.variants: -> ::Array[Anthropic::Models::tool_union]
13
41
  end
14
42
  end
@@ -0,0 +1,3 @@
1
+ module Anthropic
2
+ Streaming: singleton(Anthropic::Helpers::Streaming)
3
+ 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.1.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthropic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-23 00:00:00.000000000 Z
11
+ date: 2025-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -41,6 +41,9 @@ files:
41
41
  - lib/anthropic/errors.rb
42
42
  - lib/anthropic/file_part.rb
43
43
  - lib/anthropic/helpers/bedrock/client.rb
44
+ - lib/anthropic/helpers/streaming.rb
45
+ - lib/anthropic/helpers/streaming/events.rb
46
+ - lib/anthropic/helpers/streaming/message_stream.rb
44
47
  - lib/anthropic/helpers/vertex/client.rb
45
48
  - lib/anthropic/internal.rb
46
49
  - lib/anthropic/internal/jsonl_stream.rb
@@ -78,6 +81,8 @@ files:
78
81
  - lib/anthropic/models/beta/beta_citation_content_block_location_param.rb
79
82
  - lib/anthropic/models/beta/beta_citation_page_location.rb
80
83
  - lib/anthropic/models/beta/beta_citation_page_location_param.rb
84
+ - lib/anthropic/models/beta/beta_citation_search_result_location.rb
85
+ - lib/anthropic/models/beta/beta_citation_search_result_location_param.rb
81
86
  - lib/anthropic/models/beta/beta_citation_web_search_result_location_param.rb
82
87
  - lib/anthropic/models/beta/beta_citations_config_param.rb
83
88
  - lib/anthropic/models/beta/beta_citations_delta.rb
@@ -125,9 +130,11 @@ files:
125
130
  - lib/anthropic/models/beta/beta_raw_message_stream_event.rb
126
131
  - lib/anthropic/models/beta/beta_redacted_thinking_block.rb
127
132
  - lib/anthropic/models/beta/beta_redacted_thinking_block_param.rb
133
+ - lib/anthropic/models/beta/beta_request_document_block.rb
128
134
  - lib/anthropic/models/beta/beta_request_mcp_server_tool_configuration.rb
129
135
  - lib/anthropic/models/beta/beta_request_mcp_server_url_definition.rb
130
136
  - lib/anthropic/models/beta/beta_request_mcp_tool_result_block_param.rb
137
+ - lib/anthropic/models/beta/beta_search_result_block_param.rb
131
138
  - lib/anthropic/models/beta/beta_server_tool_usage.rb
132
139
  - lib/anthropic/models/beta/beta_server_tool_use_block.rb
133
140
  - lib/anthropic/models/beta/beta_server_tool_use_block_param.rb
@@ -328,6 +335,7 @@ files:
328
335
  - lib/anthropic/resources/messages.rb
329
336
  - lib/anthropic/resources/messages/batches.rb
330
337
  - lib/anthropic/resources/models.rb
338
+ - lib/anthropic/streaming.rb
331
339
  - lib/anthropic/version.rb
332
340
  - lib/anthropic/vertex.rb
333
341
  - manifest.yaml
@@ -336,6 +344,8 @@ files:
336
344
  - rbi/anthropic/errors.rbi
337
345
  - rbi/anthropic/file_part.rbi
338
346
  - rbi/anthropic/helpers/bedrock/client.rbi
347
+ - rbi/anthropic/helpers/streaming/events.rbi
348
+ - rbi/anthropic/helpers/streaming/message_stream.rbi
339
349
  - rbi/anthropic/helpers/vertex/client.rbi
340
350
  - rbi/anthropic/internal.rbi
341
351
  - rbi/anthropic/internal/jsonl_stream.rbi
@@ -373,6 +383,8 @@ files:
373
383
  - rbi/anthropic/models/beta/beta_citation_content_block_location_param.rbi
374
384
  - rbi/anthropic/models/beta/beta_citation_page_location.rbi
375
385
  - rbi/anthropic/models/beta/beta_citation_page_location_param.rbi
386
+ - rbi/anthropic/models/beta/beta_citation_search_result_location.rbi
387
+ - rbi/anthropic/models/beta/beta_citation_search_result_location_param.rbi
376
388
  - rbi/anthropic/models/beta/beta_citation_web_search_result_location_param.rbi
377
389
  - rbi/anthropic/models/beta/beta_citations_config_param.rbi
378
390
  - rbi/anthropic/models/beta/beta_citations_delta.rbi
@@ -420,9 +432,11 @@ files:
420
432
  - rbi/anthropic/models/beta/beta_raw_message_stream_event.rbi
421
433
  - rbi/anthropic/models/beta/beta_redacted_thinking_block.rbi
422
434
  - rbi/anthropic/models/beta/beta_redacted_thinking_block_param.rbi
435
+ - rbi/anthropic/models/beta/beta_request_document_block.rbi
423
436
  - rbi/anthropic/models/beta/beta_request_mcp_server_tool_configuration.rbi
424
437
  - rbi/anthropic/models/beta/beta_request_mcp_server_url_definition.rbi
425
438
  - rbi/anthropic/models/beta/beta_request_mcp_tool_result_block_param.rbi
439
+ - rbi/anthropic/models/beta/beta_search_result_block_param.rbi
426
440
  - rbi/anthropic/models/beta/beta_server_tool_usage.rbi
427
441
  - rbi/anthropic/models/beta/beta_server_tool_use_block.rbi
428
442
  - rbi/anthropic/models/beta/beta_server_tool_use_block_param.rbi
@@ -623,6 +637,7 @@ files:
623
637
  - rbi/anthropic/resources/messages.rbi
624
638
  - rbi/anthropic/resources/messages/batches.rbi
625
639
  - rbi/anthropic/resources/models.rbi
640
+ - rbi/anthropic/streaming.rbi
626
641
  - rbi/anthropic/version.rbi
627
642
  - rbi/anthropic/vertex.rbi
628
643
  - sig/anthropic/bedrock.rbs
@@ -630,6 +645,8 @@ files:
630
645
  - sig/anthropic/errors.rbs
631
646
  - sig/anthropic/file_part.rbs
632
647
  - sig/anthropic/helpers/bedrock/client.rbs
648
+ - sig/anthropic/helpers/streaming/events.rbs
649
+ - sig/anthropic/helpers/streaming/message_stream.rbs
633
650
  - sig/anthropic/helpers/vertex/client.rbs
634
651
  - sig/anthropic/internal.rbs
635
652
  - sig/anthropic/internal/jsonl_stream.rbs
@@ -667,6 +684,8 @@ files:
667
684
  - sig/anthropic/models/beta/beta_citation_content_block_location_param.rbs
668
685
  - sig/anthropic/models/beta/beta_citation_page_location.rbs
669
686
  - sig/anthropic/models/beta/beta_citation_page_location_param.rbs
687
+ - sig/anthropic/models/beta/beta_citation_search_result_location.rbs
688
+ - sig/anthropic/models/beta/beta_citation_search_result_location_param.rbs
670
689
  - sig/anthropic/models/beta/beta_citation_web_search_result_location_param.rbs
671
690
  - sig/anthropic/models/beta/beta_citations_config_param.rbs
672
691
  - sig/anthropic/models/beta/beta_citations_delta.rbs
@@ -714,9 +733,11 @@ files:
714
733
  - sig/anthropic/models/beta/beta_raw_message_stream_event.rbs
715
734
  - sig/anthropic/models/beta/beta_redacted_thinking_block.rbs
716
735
  - sig/anthropic/models/beta/beta_redacted_thinking_block_param.rbs
736
+ - sig/anthropic/models/beta/beta_request_document_block.rbs
717
737
  - sig/anthropic/models/beta/beta_request_mcp_server_tool_configuration.rbs
718
738
  - sig/anthropic/models/beta/beta_request_mcp_server_url_definition.rbs
719
739
  - sig/anthropic/models/beta/beta_request_mcp_tool_result_block_param.rbs
740
+ - sig/anthropic/models/beta/beta_search_result_block_param.rbs
720
741
  - sig/anthropic/models/beta/beta_server_tool_usage.rbs
721
742
  - sig/anthropic/models/beta/beta_server_tool_use_block.rbs
722
743
  - sig/anthropic/models/beta/beta_server_tool_use_block_param.rbs
@@ -917,10 +938,12 @@ files:
917
938
  - sig/anthropic/resources/messages.rbs
918
939
  - sig/anthropic/resources/messages/batches.rbs
919
940
  - sig/anthropic/resources/models.rbs
941
+ - sig/anthropic/streaming.rbs
920
942
  - sig/anthropic/version.rbs
921
943
  - sig/anthropic/vertex.rbs
922
944
  homepage: https://gemdocs.org/gems/anthropic
923
- licenses: []
945
+ licenses:
946
+ - MIT
924
947
  metadata:
925
948
  homepage_uri: https://gemdocs.org/gems/anthropic
926
949
  source_code_uri: https://github.com/anthropics/anthropic-sdk-ruby