Module: Anthropic::Internal::Type::BaseStream Private
- Includes:
- Enumerable
- Included in:
- Helpers::Streaming::MessageStream, JsonLStream, Stream
- Defined in:
- lib/anthropic/internal/type/base_stream.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
This module provides a base implementation for streaming responses in the SDK.
Instance Attribute Summary collapse
- #headers ⇒ Hash{String=>String} readonly private
- #status ⇒ Integer readonly private
Instance Method Summary collapse
- #close ⇒ void
- #each(&blk) {|| ... } ⇒ void
- #initialize(model:, url:, status:, headers:, response:, unwrap:, stream:) ⇒ void private
- #inspect ⇒ String private
- #to_enum ⇒ Enumerator<generic<Elem>> (also: #enum_for)
Instance Attribute Details
#headers ⇒ Hash{String=>String} (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 20 def headers @headers end |
#status ⇒ Integer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 17 def status @status end |
Instance Method Details
#close ⇒ void
This method returns an undefined value.
25 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 25 def close = Anthropic::Internal::Util.close_fused!(@iterator) |
#each(&blk) {|| ... } ⇒ void
This method returns an undefined value.
38 39 40 41 42 43 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 38 def each(&blk) unless block_given? raise ArgumentError.new("A block must be given to ##{__method__}") end @iterator.each(&blk) end |
#initialize(model:, url:, status:, headers:, response:, unwrap:, stream:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 61 def initialize(model:, url:, status:, headers:, response:, unwrap:, stream:) @model = model @url = url @status = status @headers = headers @response = response @unwrap = unwrap @stream = stream @iterator = iterator end |
#inspect ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 78 79 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 75 def inspect model = Anthropic::Internal::Type::Converter.inspect(@model, depth: 1) "#<#{self.class}[#{model}]:0x#{object_id.to_s(16)}>" end |
#to_enum ⇒ Enumerator<generic<Elem>> Also known as: enum_for
48 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 48 def to_enum = @iterator |