Closed alexrudall closed 7 months ago
This is such interesting timing. I was thinking of adding something along these lines, actually, because so far I was monkey patching this in the initializer openai.rb
!
OpenAI.configure do |config|
config.access_token = Rails.application.credentials.open_ai_key
config.request_timeout = 300
end
module OpenAI
module HTTP
def connection_with_timeout(multipart: false)
original_connection(multipart:).tap do |conn|
conn.use TimeoutMiddleware, timeout: @request_timeout
end
end
alias_method :original_connection, :conn
alias_method :conn, :connection_with_timeout
end
end
Obviously, having such a block to configure the Faraday object is an improvement.
FYI: this was because I was still observing time outs
This is such interesting timing. I was thinking of adding something along these lines, actually, because so far I was monkey patching this in the initializer
openai.rb
!OpenAI.configure do |config| config.access_token = Rails.application.credentials.open_ai_key config.request_timeout = 300 end module OpenAI module HTTP def connection_with_timeout(multipart: false) original_connection(multipart:).tap do |conn| conn.use TimeoutMiddleware, timeout: @request_timeout end end alias_method :original_connection, :conn alias_method :conn, :connection_with_timeout end end
Obviously, having such a block to configure the Faraday object is an improvement.
FYI: this was because I was still observing time outs
Ah sweet - could you test this PR with that use case? Would be much appreciated 🙏
All Submissions: