Module: Anthropic::Internal::Type::BaseStream Private
- Includes:
- Enumerable, Enumerable[Elem]
- Included in:
- Helpers::Streaming::MessageStream, JsonLStream, Stream
- Defined in:
- lib/anthropic/internal/type/base_stream.rb,
sig/anthropic/internal/type/base_stream.rbs
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) {|, arg0| ... } ⇒ void
- #initialize(model:, url:, status:, headers:, response:, unwrap:, stream:) ⇒ Object private
- #inspect ⇒ String private
- #request_id ⇒ String?
- #to_enum ⇒ Enumerator<generic<Elem>> (also: #enum_for)
- #workspace_id ⇒ String?
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.
35 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 35 def close = Anthropic::Internal::Util.close_fused!(@iterator) |
#each(&blk) {|, arg0| ... } ⇒ void
This method returns an undefined value.
48 49 50 51 52 53 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 48 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:) ⇒ Object
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.
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 71 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.
85 86 87 88 89 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 85 def inspect model = Anthropic::Internal::Type::Converter.inspect(@model, depth: 1) "#<#{self.class}[#{model}]:0x#{object_id.to_s(16)}>" end |
#request_id ⇒ String?
25 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 25 def request_id = headers["request-id"] |
#to_enum ⇒ Enumerator<generic<Elem>> Also known as: enum_for
58 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 58 def to_enum = @iterator |
#workspace_id ⇒ String?
30 |
# File 'lib/anthropic/internal/type/base_stream.rb', line 30 def workspace_id = headers["anthropic-workspace-id"] |