Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/openai/pooled_net_requester.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def calibrate_socket_timeout(conn, deadline)
#
# @param blk [Proc]
#
# @yieldparam [String]
# @return [Net::HTTPGenericRequest]
def build_request(request, &)
method, url, headers, body = request.fetch_values(:method, :url, :headers, :body)
Expand Down Expand Up @@ -86,6 +87,9 @@ def build_request(request, &)
# @param url [URI::Generic]
# @param deadline [Float]
# @param blk [Proc]
#
# @raise [Timeout::Error]
# @yieldparam [Net::HTTP]
private def with_pool(url, deadline:, &blk)
origin = OpenAI::Util.uri_origin(url)
timeout = deadline - OpenAI::Util.monotonic_secs
Expand Down
4 changes: 4 additions & 0 deletions lib/openai/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ def read(max_len = nil, out_string = nil)
#
# @param stream [String, IO, StringIO, Enumerable]
# @param blk [Proc]
#
# @yieldparam [String]
def initialize(stream, &blk)
@stream = stream.is_a?(String) ? StringIO.new(stream) : stream
@buf = String.new.b
Expand All @@ -439,6 +441,7 @@ def initialize(stream, &blk)
class << self
# @param blk [Proc]
#
# @yieldparam [Enumerator::Yielder]
# @return [Enumerable]
def string_io(&blk)
Enumerator.new do |y|
Expand Down Expand Up @@ -633,6 +636,7 @@ def close_fused!(enum)
# @param enum [Enumerable, nil]
# @param blk [Proc]
#
# @yieldparam [Enumerator::Yielder]
# @return [Enumerable]
def chain_fused(enum, &blk)
iter = Enumerator.new { blk.call(_1) }
Expand Down