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
@@ -497,7 +497,7 @@ module Anthropic
497
497
  # @param closing [Array<Proc>]
498
498
  # @param content_type [String, nil]
499
499
  private def write_multipart_content(y, val:, closing:, content_type: nil)
500
- content_type ||= "application/octet-stream"
500
+ content_line = "Content-Type: %s\r\n\r\n"
501
501
 
502
502
  case val
503
503
  in Anthropic::FilePart
@@ -508,24 +508,21 @@ module Anthropic
508
508
  content_type: val.content_type
509
509
  )
510
510
  in Pathname
511
- y << "Content-Type: #{content_type}\r\n\r\n"
511
+ y << format(content_line, content_type || "application/octet-stream")
512
512
  io = val.open(binmode: true)
513
513
  closing << io.method(:close)
514
514
  IO.copy_stream(io, y)
515
515
  in IO
516
- y << "Content-Type: #{content_type}\r\n\r\n"
516
+ y << format(content_line, content_type || "application/octet-stream")
517
517
  IO.copy_stream(val, y)
518
518
  in StringIO
519
- y << "Content-Type: #{content_type}\r\n\r\n"
519
+ y << format(content_line, content_type || "application/octet-stream")
520
520
  y << val.string
521
- in String
522
- y << "Content-Type: #{content_type}\r\n\r\n"
523
- y << val.to_s
524
521
  in -> { primitive?(_1) }
525
- y << "Content-Type: text/plain\r\n\r\n"
522
+ y << format(content_line, content_type || "text/plain")
526
523
  y << val.to_s
527
524
  else
528
- y << "Content-Type: application/json\r\n\r\n"
525
+ y << format(content_line, content_type || "application/json")
529
526
  y << JSON.generate(val)
530
527
  end
531
528
  y << "\r\n"
@@ -563,6 +560,8 @@ module Anthropic
563
560
 
564
561
  # @api private
565
562
  #
563
+ # https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content
564
+ #
566
565
  # @param body [Object]
567
566
  #
568
567
  # @return [Array(String, Enumerable<String>)]
@@ -3,71 +3,7 @@
3
3
  module Anthropic
4
4
  module Models
5
5
  module Beta
6
- class BetaBase64PDFBlock < Anthropic::Internal::Type::BaseModel
7
- # @!attribute source
8
- #
9
- # @return [Anthropic::Models::Beta::BetaBase64PDFSource, Anthropic::Models::Beta::BetaPlainTextSource, Anthropic::Models::Beta::BetaContentBlockSource, Anthropic::Models::Beta::BetaURLPDFSource, Anthropic::Models::Beta::BetaFileDocumentSource]
10
- required :source, union: -> { Anthropic::Beta::BetaBase64PDFBlock::Source }
11
-
12
- # @!attribute type
13
- #
14
- # @return [Symbol, :document]
15
- required :type, const: :document
16
-
17
- # @!attribute cache_control
18
- # Create a cache control breakpoint at this content block.
19
- #
20
- # @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
21
- optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
22
-
23
- # @!attribute citations
24
- #
25
- # @return [Anthropic::Models::Beta::BetaCitationsConfigParam, nil]
26
- optional :citations, -> { Anthropic::Beta::BetaCitationsConfigParam }
27
-
28
- # @!attribute context
29
- #
30
- # @return [String, nil]
31
- optional :context, String, nil?: true
32
-
33
- # @!attribute title
34
- #
35
- # @return [String, nil]
36
- optional :title, String, nil?: true
37
-
38
- # @!method initialize(source:, cache_control: nil, citations: nil, context: nil, title: nil, type: :document)
39
- # @param source [Anthropic::Models::Beta::BetaBase64PDFSource, Anthropic::Models::Beta::BetaPlainTextSource, Anthropic::Models::Beta::BetaContentBlockSource, Anthropic::Models::Beta::BetaURLPDFSource, Anthropic::Models::Beta::BetaFileDocumentSource]
40
- #
41
- # @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
42
- #
43
- # @param citations [Anthropic::Models::Beta::BetaCitationsConfigParam]
44
- #
45
- # @param context [String, nil]
46
- #
47
- # @param title [String, nil]
48
- #
49
- # @param type [Symbol, :document]
50
-
51
- # @see Anthropic::Models::Beta::BetaBase64PDFBlock#source
52
- module Source
53
- extend Anthropic::Internal::Type::Union
54
-
55
- discriminator :type
56
-
57
- variant :base64, -> { Anthropic::Beta::BetaBase64PDFSource }
58
-
59
- variant :text, -> { Anthropic::Beta::BetaPlainTextSource }
60
-
61
- variant :content, -> { Anthropic::Beta::BetaContentBlockSource }
62
-
63
- variant :url, -> { Anthropic::Beta::BetaURLPDFSource }
64
-
65
- variant :file, -> { Anthropic::Beta::BetaFileDocumentSource }
66
-
67
- # @!method self.variants
68
- # @return [Array(Anthropic::Models::Beta::BetaBase64PDFSource, Anthropic::Models::Beta::BetaPlainTextSource, Anthropic::Models::Beta::BetaContentBlockSource, Anthropic::Models::Beta::BetaURLPDFSource, Anthropic::Models::Beta::BetaFileDocumentSource)]
69
- end
70
- end
6
+ BetaBase64PDFBlock = Anthropic::Models::Beta::BetaRequestDocumentBlock
71
7
  end
72
8
 
73
9
  BetaBase64PDFBlock = Beta::BetaBase64PDFBlock
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaCitationSearchResultLocation < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute cited_text
8
+ #
9
+ # @return [String]
10
+ required :cited_text, String
11
+
12
+ # @!attribute end_block_index
13
+ #
14
+ # @return [Integer]
15
+ required :end_block_index, Integer
16
+
17
+ # @!attribute search_result_index
18
+ #
19
+ # @return [Integer]
20
+ required :search_result_index, Integer
21
+
22
+ # @!attribute source
23
+ #
24
+ # @return [String]
25
+ required :source, String
26
+
27
+ # @!attribute start_block_index
28
+ #
29
+ # @return [Integer]
30
+ required :start_block_index, Integer
31
+
32
+ # @!attribute title
33
+ #
34
+ # @return [String, nil]
35
+ required :title, String, nil?: true
36
+
37
+ # @!attribute type
38
+ #
39
+ # @return [Symbol, :search_result_location]
40
+ required :type, const: :search_result_location
41
+
42
+ # @!method initialize(cited_text:, end_block_index:, search_result_index:, source:, start_block_index:, title:, type: :search_result_location)
43
+ # @param cited_text [String]
44
+ # @param end_block_index [Integer]
45
+ # @param search_result_index [Integer]
46
+ # @param source [String]
47
+ # @param start_block_index [Integer]
48
+ # @param title [String, nil]
49
+ # @param type [Symbol, :search_result_location]
50
+ end
51
+ end
52
+
53
+ BetaCitationSearchResultLocation = Beta::BetaCitationSearchResultLocation
54
+ end
55
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaCitationSearchResultLocationParam < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute cited_text
8
+ #
9
+ # @return [String]
10
+ required :cited_text, String
11
+
12
+ # @!attribute end_block_index
13
+ #
14
+ # @return [Integer]
15
+ required :end_block_index, Integer
16
+
17
+ # @!attribute search_result_index
18
+ #
19
+ # @return [Integer]
20
+ required :search_result_index, Integer
21
+
22
+ # @!attribute source
23
+ #
24
+ # @return [String]
25
+ required :source, String
26
+
27
+ # @!attribute start_block_index
28
+ #
29
+ # @return [Integer]
30
+ required :start_block_index, Integer
31
+
32
+ # @!attribute title
33
+ #
34
+ # @return [String, nil]
35
+ required :title, String, nil?: true
36
+
37
+ # @!attribute type
38
+ #
39
+ # @return [Symbol, :search_result_location]
40
+ required :type, const: :search_result_location
41
+
42
+ # @!method initialize(cited_text:, end_block_index:, search_result_index:, source:, start_block_index:, title:, type: :search_result_location)
43
+ # @param cited_text [String]
44
+ # @param end_block_index [Integer]
45
+ # @param search_result_index [Integer]
46
+ # @param source [String]
47
+ # @param start_block_index [Integer]
48
+ # @param title [String, nil]
49
+ # @param type [Symbol, :search_result_location]
50
+ end
51
+ end
52
+
53
+ BetaCitationSearchResultLocationParam = Beta::BetaCitationSearchResultLocationParam
54
+ end
55
+ end
@@ -6,7 +6,7 @@ module Anthropic
6
6
  class BetaCitationsDelta < Anthropic::Internal::Type::BaseModel
7
7
  # @!attribute citation
8
8
  #
9
- # @return [Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation]
9
+ # @return [Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation, Anthropic::Models::Beta::BetaCitationSearchResultLocation]
10
10
  required :citation, union: -> { Anthropic::Beta::BetaCitationsDelta::Citation }
11
11
 
12
12
  # @!attribute type
@@ -15,7 +15,7 @@ module Anthropic
15
15
  required :type, const: :citations_delta
16
16
 
17
17
  # @!method initialize(citation:, type: :citations_delta)
18
- # @param citation [Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation]
18
+ # @param citation [Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation, Anthropic::Models::Beta::BetaCitationSearchResultLocation]
19
19
  # @param type [Symbol, :citations_delta]
20
20
 
21
21
  # @see Anthropic::Models::Beta::BetaCitationsDelta#citation
@@ -32,8 +32,10 @@ module Anthropic
32
32
 
33
33
  variant :web_search_result_location, -> { Anthropic::Beta::BetaCitationsWebSearchResultLocation }
34
34
 
35
+ variant :search_result_location, -> { Anthropic::Beta::BetaCitationSearchResultLocation }
36
+
35
37
  # @!method self.variants
36
- # @return [Array(Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation)]
38
+ # @return [Array(Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation, Anthropic::Models::Beta::BetaCitationSearchResultLocation)]
37
39
  end
38
40
  end
39
41
  end
@@ -11,6 +11,10 @@ module Anthropic
11
11
 
12
12
  variant :text, -> { Anthropic::Beta::BetaTextBlock }
13
13
 
14
+ variant :thinking, -> { Anthropic::Beta::BetaThinkingBlock }
15
+
16
+ variant :redacted_thinking, -> { Anthropic::Beta::BetaRedactedThinkingBlock }
17
+
14
18
  variant :tool_use, -> { Anthropic::Beta::BetaToolUseBlock }
15
19
 
16
20
  variant :server_tool_use, -> { Anthropic::Beta::BetaServerToolUseBlock }
@@ -26,12 +30,8 @@ module Anthropic
26
30
  # Response model for a file uploaded to the container.
27
31
  variant :container_upload, -> { Anthropic::Beta::BetaContainerUploadBlock }
28
32
 
29
- variant :thinking, -> { Anthropic::Beta::BetaThinkingBlock }
30
-
31
- variant :redacted_thinking, -> { Anthropic::Beta::BetaRedactedThinkingBlock }
32
-
33
33
  # @!method self.variants
34
- # @return [Array(Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock)]
34
+ # @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::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock)]
35
35
  end
36
36
  end
37
37
 
@@ -9,43 +9,46 @@ module Anthropic
9
9
 
10
10
  discriminator :type
11
11
 
12
- variant :server_tool_use, -> { Anthropic::Beta::BetaServerToolUseBlockParam }
13
-
14
- variant :web_search_tool_result, -> { Anthropic::Beta::BetaWebSearchToolResultBlockParam }
15
-
16
- variant :code_execution_tool_result, -> { Anthropic::Beta::BetaCodeExecutionToolResultBlockParam }
17
-
18
- variant :mcp_tool_use, -> { Anthropic::Beta::BetaMCPToolUseBlockParam }
19
-
20
- variant :mcp_tool_result, -> { Anthropic::Beta::BetaRequestMCPToolResultBlockParam }
21
-
22
12
  # Regular text content.
23
13
  variant :text, -> { Anthropic::Beta::BetaTextBlockParam }
24
14
 
25
15
  # Image content specified directly as base64 data or as a reference via a URL.
26
16
  variant :image, -> { Anthropic::Beta::BetaImageBlockParam }
27
17
 
18
+ # Document content, either specified directly as base64 data, as text, or as a reference via a URL.
19
+ variant :document, -> { Anthropic::Beta::BetaRequestDocumentBlock }
20
+
21
+ # A search result block containing source, title, and content from search operations.
22
+ variant :search_result, -> { Anthropic::Beta::BetaSearchResultBlockParam }
23
+
24
+ # A block specifying internal thinking by the model.
25
+ variant :thinking, -> { Anthropic::Beta::BetaThinkingBlockParam }
26
+
27
+ # A block specifying internal, redacted thinking by the model.
28
+ variant :redacted_thinking, -> { Anthropic::Beta::BetaRedactedThinkingBlockParam }
29
+
28
30
  # A block indicating a tool use by the model.
29
31
  variant :tool_use, -> { Anthropic::Beta::BetaToolUseBlockParam }
30
32
 
31
33
  # A block specifying the results of a tool use by the model.
32
34
  variant :tool_result, -> { Anthropic::Beta::BetaToolResultBlockParam }
33
35
 
34
- # Document content, either specified directly as base64 data, as text, or as a reference via a URL.
35
- variant :document, -> { Anthropic::Beta::BetaBase64PDFBlock }
36
+ variant :server_tool_use, -> { Anthropic::Beta::BetaServerToolUseBlockParam }
36
37
 
37
- # A block specifying internal thinking by the model.
38
- variant :thinking, -> { Anthropic::Beta::BetaThinkingBlockParam }
38
+ variant :web_search_tool_result, -> { Anthropic::Beta::BetaWebSearchToolResultBlockParam }
39
39
 
40
- # A block specifying internal, redacted thinking by the model.
41
- variant :redacted_thinking, -> { Anthropic::Beta::BetaRedactedThinkingBlockParam }
40
+ variant :code_execution_tool_result, -> { Anthropic::Beta::BetaCodeExecutionToolResultBlockParam }
41
+
42
+ variant :mcp_tool_use, -> { Anthropic::Beta::BetaMCPToolUseBlockParam }
43
+
44
+ variant :mcp_tool_result, -> { Anthropic::Beta::BetaRequestMCPToolResultBlockParam }
42
45
 
43
46
  # A content block that represents a file to be uploaded to the container
44
47
  # Files uploaded via this block will be available in the container's input directory.
45
48
  variant :container_upload, -> { Anthropic::Beta::BetaContainerUploadBlockParam }
46
49
 
47
50
  # @!method self.variants
48
- # @return [Array(Anthropic::Models::Beta::BetaServerToolUseBlockParam, Anthropic::Models::Beta::BetaWebSearchToolResultBlockParam, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlockParam, Anthropic::Models::Beta::BetaMCPToolUseBlockParam, Anthropic::Models::Beta::BetaRequestMCPToolResultBlockParam, Anthropic::Models::Beta::BetaTextBlockParam, Anthropic::Models::Beta::BetaImageBlockParam, Anthropic::Models::Beta::BetaToolUseBlockParam, Anthropic::Models::Beta::BetaToolResultBlockParam, Anthropic::Models::Beta::BetaBase64PDFBlock, Anthropic::Models::Beta::BetaThinkingBlockParam, Anthropic::Models::Beta::BetaRedactedThinkingBlockParam, Anthropic::Models::Beta::BetaContainerUploadBlockParam)]
51
+ # @return [Array(Anthropic::Models::Beta::BetaTextBlockParam, Anthropic::Models::Beta::BetaImageBlockParam, Anthropic::Models::Beta::BetaRequestDocumentBlock, Anthropic::Models::Beta::BetaSearchResultBlockParam, Anthropic::Models::Beta::BetaThinkingBlockParam, Anthropic::Models::Beta::BetaRedactedThinkingBlockParam, Anthropic::Models::Beta::BetaToolUseBlockParam, Anthropic::Models::Beta::BetaToolResultBlockParam, Anthropic::Models::Beta::BetaServerToolUseBlockParam, Anthropic::Models::Beta::BetaWebSearchToolResultBlockParam, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlockParam, Anthropic::Models::Beta::BetaMCPToolUseBlockParam, Anthropic::Models::Beta::BetaRequestMCPToolResultBlockParam, Anthropic::Models::Beta::BetaContainerUploadBlockParam)]
49
52
  end
50
53
  end
51
54
 
@@ -56,7 +56,7 @@ module Anthropic
56
56
  # [{ "type": "text", "text": "B)" }]
57
57
  # ```
58
58
  #
59
- # @return [Array<Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock>]
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::BetaCodeExecutionToolResultBlock, 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
62
  # @!attribute model
@@ -84,6 +84,10 @@ module Anthropic
84
84
  # - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
85
85
  # - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
86
86
  # - `"tool_use"`: the model invoked one or more tools
87
+ # - `"pause_turn"`: we paused a long-running turn. You may provide the response
88
+ # back as-is in a subsequent request to let the model continue.
89
+ # - `"refusal"`: when streaming classifiers intervene to handle potential policy
90
+ # violations
87
91
  #
88
92
  # In non-streaming mode this value is always non-null. In streaming mode, it is
89
93
  # null in the `message_start` event and non-null otherwise.
@@ -136,7 +140,7 @@ module Anthropic
136
140
  #
137
141
  # @param container [Anthropic::Models::Beta::BetaContainer, nil] Information about the container used in the request (for the code execution tool
138
142
  #
139
- # @param content [Array<Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock>] Content generated by the model.
143
+ # @param content [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::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock>] Content generated by the model.
140
144
  #
141
145
  # @param model [Symbol, String, Anthropic::Models::Model] The model that will complete your prompt.\n\nSee [models](https://docs.anthropic
142
146
  #
@@ -6,7 +6,7 @@ module Anthropic
6
6
  class BetaMessageParam < Anthropic::Internal::Type::BaseModel
7
7
  # @!attribute content
8
8
  #
9
- # @return [String, Array<Anthropic::Models::Beta::BetaServerToolUseBlockParam, Anthropic::Models::Beta::BetaWebSearchToolResultBlockParam, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlockParam, Anthropic::Models::Beta::BetaMCPToolUseBlockParam, Anthropic::Models::Beta::BetaRequestMCPToolResultBlockParam, Anthropic::Models::Beta::BetaTextBlockParam, Anthropic::Models::Beta::BetaImageBlockParam, Anthropic::Models::Beta::BetaToolUseBlockParam, Anthropic::Models::Beta::BetaToolResultBlockParam, Anthropic::Models::Beta::BetaBase64PDFBlock, Anthropic::Models::Beta::BetaThinkingBlockParam, Anthropic::Models::Beta::BetaRedactedThinkingBlockParam, Anthropic::Models::Beta::BetaContainerUploadBlockParam>]
9
+ # @return [String, Array<Anthropic::Models::Beta::BetaTextBlockParam, Anthropic::Models::Beta::BetaImageBlockParam, Anthropic::Models::Beta::BetaRequestDocumentBlock, Anthropic::Models::Beta::BetaSearchResultBlockParam, Anthropic::Models::Beta::BetaThinkingBlockParam, Anthropic::Models::Beta::BetaRedactedThinkingBlockParam, Anthropic::Models::Beta::BetaToolUseBlockParam, Anthropic::Models::Beta::BetaToolResultBlockParam, Anthropic::Models::Beta::BetaServerToolUseBlockParam, Anthropic::Models::Beta::BetaWebSearchToolResultBlockParam, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlockParam, Anthropic::Models::Beta::BetaMCPToolUseBlockParam, Anthropic::Models::Beta::BetaRequestMCPToolResultBlockParam, Anthropic::Models::Beta::BetaContainerUploadBlockParam>]
10
10
  required :content, union: -> { Anthropic::Beta::BetaMessageParam::Content }
11
11
 
12
12
  # @!attribute role
@@ -15,7 +15,7 @@ module Anthropic
15
15
  required :role, enum: -> { Anthropic::Beta::BetaMessageParam::Role }
16
16
 
17
17
  # @!method initialize(content:, role:)
18
- # @param content [String, Array<Anthropic::Models::Beta::BetaServerToolUseBlockParam, Anthropic::Models::Beta::BetaWebSearchToolResultBlockParam, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlockParam, Anthropic::Models::Beta::BetaMCPToolUseBlockParam, Anthropic::Models::Beta::BetaRequestMCPToolResultBlockParam, Anthropic::Models::Beta::BetaTextBlockParam, Anthropic::Models::Beta::BetaImageBlockParam, Anthropic::Models::Beta::BetaToolUseBlockParam, Anthropic::Models::Beta::BetaToolResultBlockParam, Anthropic::Models::Beta::BetaBase64PDFBlock, Anthropic::Models::Beta::BetaThinkingBlockParam, Anthropic::Models::Beta::BetaRedactedThinkingBlockParam, Anthropic::Models::Beta::BetaContainerUploadBlockParam>]
18
+ # @param content [String, Array<Anthropic::Models::Beta::BetaTextBlockParam, Anthropic::Models::Beta::BetaImageBlockParam, Anthropic::Models::Beta::BetaRequestDocumentBlock, Anthropic::Models::Beta::BetaSearchResultBlockParam, Anthropic::Models::Beta::BetaThinkingBlockParam, Anthropic::Models::Beta::BetaRedactedThinkingBlockParam, Anthropic::Models::Beta::BetaToolUseBlockParam, Anthropic::Models::Beta::BetaToolResultBlockParam, Anthropic::Models::Beta::BetaServerToolUseBlockParam, Anthropic::Models::Beta::BetaWebSearchToolResultBlockParam, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlockParam, Anthropic::Models::Beta::BetaMCPToolUseBlockParam, Anthropic::Models::Beta::BetaRequestMCPToolResultBlockParam, Anthropic::Models::Beta::BetaContainerUploadBlockParam>]
19
19
  # @param role [Symbol, Anthropic::Models::Beta::BetaMessageParam::Role]
20
20
 
21
21
  # @see Anthropic::Models::Beta::BetaMessageParam#content
@@ -27,7 +27,7 @@ module Anthropic
27
27
  variant -> { Anthropic::Models::Beta::BetaMessageParam::Content::BetaContentBlockParamArray }
28
28
 
29
29
  # @!method self.variants
30
- # @return [Array(String, Array<Anthropic::Models::Beta::BetaServerToolUseBlockParam, Anthropic::Models::Beta::BetaWebSearchToolResultBlockParam, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlockParam, Anthropic::Models::Beta::BetaMCPToolUseBlockParam, Anthropic::Models::Beta::BetaRequestMCPToolResultBlockParam, Anthropic::Models::Beta::BetaTextBlockParam, Anthropic::Models::Beta::BetaImageBlockParam, Anthropic::Models::Beta::BetaToolUseBlockParam, Anthropic::Models::Beta::BetaToolResultBlockParam, Anthropic::Models::Beta::BetaBase64PDFBlock, Anthropic::Models::Beta::BetaThinkingBlockParam, Anthropic::Models::Beta::BetaRedactedThinkingBlockParam, Anthropic::Models::Beta::BetaContainerUploadBlockParam>)]
30
+ # @return [Array(String, Array<Anthropic::Models::Beta::BetaTextBlockParam, Anthropic::Models::Beta::BetaImageBlockParam, Anthropic::Models::Beta::BetaRequestDocumentBlock, Anthropic::Models::Beta::BetaSearchResultBlockParam, Anthropic::Models::Beta::BetaThinkingBlockParam, Anthropic::Models::Beta::BetaRedactedThinkingBlockParam, Anthropic::Models::Beta::BetaToolUseBlockParam, Anthropic::Models::Beta::BetaToolResultBlockParam, Anthropic::Models::Beta::BetaServerToolUseBlockParam, Anthropic::Models::Beta::BetaWebSearchToolResultBlockParam, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlockParam, Anthropic::Models::Beta::BetaMCPToolUseBlockParam, Anthropic::Models::Beta::BetaRequestMCPToolResultBlockParam, Anthropic::Models::Beta::BetaContainerUploadBlockParam>)]
31
31
 
32
32
  # @type [Anthropic::Internal::Type::Converter]
33
33
  BetaContentBlockParamArray =
@@ -7,7 +7,7 @@ module Anthropic
7
7
  # @!attribute content_block
8
8
  # Response model for a file uploaded to the container.
9
9
  #
10
- # @return [Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock]
10
+ # @return [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::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock]
11
11
  required :content_block, union: -> { Anthropic::Beta::BetaRawContentBlockStartEvent::ContentBlock }
12
12
 
13
13
  # @!attribute index
@@ -21,7 +21,7 @@ module Anthropic
21
21
  required :type, const: :content_block_start
22
22
 
23
23
  # @!method initialize(content_block:, index:, type: :content_block_start)
24
- # @param content_block [Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock] Response model for a file uploaded to the container.
24
+ # @param content_block [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::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock] Response model for a file uploaded to the container.
25
25
  #
26
26
  # @param index [Integer]
27
27
  #
@@ -37,6 +37,10 @@ module Anthropic
37
37
 
38
38
  variant :text, -> { Anthropic::Beta::BetaTextBlock }
39
39
 
40
+ variant :thinking, -> { Anthropic::Beta::BetaThinkingBlock }
41
+
42
+ variant :redacted_thinking, -> { Anthropic::Beta::BetaRedactedThinkingBlock }
43
+
40
44
  variant :tool_use, -> { Anthropic::Beta::BetaToolUseBlock }
41
45
 
42
46
  variant :server_tool_use, -> { Anthropic::Beta::BetaServerToolUseBlock }
@@ -52,12 +56,8 @@ module Anthropic
52
56
  # Response model for a file uploaded to the container.
53
57
  variant :container_upload, -> { Anthropic::Beta::BetaContainerUploadBlock }
54
58
 
55
- variant :thinking, -> { Anthropic::Beta::BetaThinkingBlock }
56
-
57
- variant :redacted_thinking, -> { Anthropic::Beta::BetaRedactedThinkingBlock }
58
-
59
59
  # @!method self.variants
60
- # @return [Array(Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock)]
60
+ # @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::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock)]
61
61
  end
62
62
  end
63
63
  end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaRequestDocumentBlock < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute source
8
+ #
9
+ # @return [Anthropic::Models::Beta::BetaBase64PDFSource, Anthropic::Models::Beta::BetaPlainTextSource, Anthropic::Models::Beta::BetaContentBlockSource, Anthropic::Models::Beta::BetaURLPDFSource, Anthropic::Models::Beta::BetaFileDocumentSource]
10
+ required :source, union: -> { Anthropic::Beta::BetaRequestDocumentBlock::Source }
11
+
12
+ # @!attribute type
13
+ #
14
+ # @return [Symbol, :document]
15
+ required :type, const: :document
16
+
17
+ # @!attribute cache_control
18
+ # Create a cache control breakpoint at this content block.
19
+ #
20
+ # @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
21
+ optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
22
+
23
+ # @!attribute citations
24
+ #
25
+ # @return [Anthropic::Models::Beta::BetaCitationsConfigParam, nil]
26
+ optional :citations, -> { Anthropic::Beta::BetaCitationsConfigParam }
27
+
28
+ # @!attribute context
29
+ #
30
+ # @return [String, nil]
31
+ optional :context, String, nil?: true
32
+
33
+ # @!attribute title
34
+ #
35
+ # @return [String, nil]
36
+ optional :title, String, nil?: true
37
+
38
+ # @!method initialize(source:, cache_control: nil, citations: nil, context: nil, title: nil, type: :document)
39
+ # @param source [Anthropic::Models::Beta::BetaBase64PDFSource, Anthropic::Models::Beta::BetaPlainTextSource, Anthropic::Models::Beta::BetaContentBlockSource, Anthropic::Models::Beta::BetaURLPDFSource, Anthropic::Models::Beta::BetaFileDocumentSource]
40
+ #
41
+ # @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
42
+ #
43
+ # @param citations [Anthropic::Models::Beta::BetaCitationsConfigParam]
44
+ #
45
+ # @param context [String, nil]
46
+ #
47
+ # @param title [String, nil]
48
+ #
49
+ # @param type [Symbol, :document]
50
+
51
+ # @see Anthropic::Models::Beta::BetaRequestDocumentBlock#source
52
+ module Source
53
+ extend Anthropic::Internal::Type::Union
54
+
55
+ discriminator :type
56
+
57
+ variant :base64, -> { Anthropic::Beta::BetaBase64PDFSource }
58
+
59
+ variant :text, -> { Anthropic::Beta::BetaPlainTextSource }
60
+
61
+ variant :content, -> { Anthropic::Beta::BetaContentBlockSource }
62
+
63
+ variant :url, -> { Anthropic::Beta::BetaURLPDFSource }
64
+
65
+ variant :file, -> { Anthropic::Beta::BetaFileDocumentSource }
66
+
67
+ # @!method self.variants
68
+ # @return [Array(Anthropic::Models::Beta::BetaBase64PDFSource, Anthropic::Models::Beta::BetaPlainTextSource, Anthropic::Models::Beta::BetaContentBlockSource, Anthropic::Models::Beta::BetaURLPDFSource, Anthropic::Models::Beta::BetaFileDocumentSource)]
69
+ end
70
+ end
71
+ end
72
+
73
+ BetaRequestDocumentBlock = Beta::BetaRequestDocumentBlock
74
+ end
75
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaSearchResultBlockParam < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute content
8
+ #
9
+ # @return [Array<Anthropic::Models::Beta::BetaTextBlockParam>]
10
+ required :content, -> { Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaTextBlockParam] }
11
+
12
+ # @!attribute source
13
+ #
14
+ # @return [String]
15
+ required :source, String
16
+
17
+ # @!attribute title
18
+ #
19
+ # @return [String]
20
+ required :title, String
21
+
22
+ # @!attribute type
23
+ #
24
+ # @return [Symbol, :search_result]
25
+ required :type, const: :search_result
26
+
27
+ # @!attribute cache_control
28
+ # Create a cache control breakpoint at this content block.
29
+ #
30
+ # @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
31
+ optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
32
+
33
+ # @!attribute citations
34
+ #
35
+ # @return [Anthropic::Models::Beta::BetaCitationsConfigParam, nil]
36
+ optional :citations, -> { Anthropic::Beta::BetaCitationsConfigParam }
37
+
38
+ # @!method initialize(content:, source:, title:, cache_control: nil, citations: nil, type: :search_result)
39
+ # @param content [Array<Anthropic::Models::Beta::BetaTextBlockParam>]
40
+ #
41
+ # @param source [String]
42
+ #
43
+ # @param title [String]
44
+ #
45
+ # @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
46
+ #
47
+ # @param citations [Anthropic::Models::Beta::BetaCitationsConfigParam]
48
+ #
49
+ # @param type [Symbol, :search_result]
50
+ end
51
+ end
52
+
53
+ BetaSearchResultBlockParam = Beta::BetaSearchResultBlockParam
54
+ end
55
+ end
@@ -11,7 +11,7 @@ module Anthropic
11
11
  # Citing a PDF results in `page_location`, plain text results in `char_location`,
12
12
  # and content document results in `content_block_location`.
13
13
  #
14
- # @return [Array<Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation>, nil]
14
+ # @return [Array<Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation, Anthropic::Models::Beta::BetaCitationSearchResultLocation>, nil]
15
15
  required :citations,
16
16
  -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaTextCitation] },
17
17
  nil?: true
@@ -30,7 +30,7 @@ module Anthropic
30
30
  # Some parameter documentations has been truncated, see
31
31
  # {Anthropic::Models::Beta::BetaTextBlock} for more details.
32
32
  #
33
- # @param citations [Array<Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation>, nil] Citations supporting the text block.
33
+ # @param citations [Array<Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation, Anthropic::Models::Beta::BetaCitationSearchResultLocation>, nil] Citations supporting the text block.
34
34
  #
35
35
  # @param text [String]
36
36
  #
@@ -22,7 +22,7 @@ module Anthropic
22
22
 
23
23
  # @!attribute citations
24
24
  #
25
- # @return [Array<Anthropic::Models::Beta::BetaCitationCharLocationParam, Anthropic::Models::Beta::BetaCitationPageLocationParam, Anthropic::Models::Beta::BetaCitationContentBlockLocationParam, Anthropic::Models::Beta::BetaCitationWebSearchResultLocationParam>, nil]
25
+ # @return [Array<Anthropic::Models::Beta::BetaCitationCharLocationParam, Anthropic::Models::Beta::BetaCitationPageLocationParam, Anthropic::Models::Beta::BetaCitationContentBlockLocationParam, Anthropic::Models::Beta::BetaCitationWebSearchResultLocationParam, Anthropic::Models::Beta::BetaCitationSearchResultLocationParam>, nil]
26
26
  optional :citations,
27
27
  -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaTextCitationParam] },
28
28
  nil?: true
@@ -32,7 +32,7 @@ module Anthropic
32
32
  #
33
33
  # @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
34
34
  #
35
- # @param citations [Array<Anthropic::Models::Beta::BetaCitationCharLocationParam, Anthropic::Models::Beta::BetaCitationPageLocationParam, Anthropic::Models::Beta::BetaCitationContentBlockLocationParam, Anthropic::Models::Beta::BetaCitationWebSearchResultLocationParam>, nil]
35
+ # @param citations [Array<Anthropic::Models::Beta::BetaCitationCharLocationParam, Anthropic::Models::Beta::BetaCitationPageLocationParam, Anthropic::Models::Beta::BetaCitationContentBlockLocationParam, Anthropic::Models::Beta::BetaCitationWebSearchResultLocationParam, Anthropic::Models::Beta::BetaCitationSearchResultLocationParam>, nil]
36
36
  #
37
37
  # @param type [Symbol, :text]
38
38
  end