alexrudall / ruby-openai

OpenAI API + Ruby! 🤖❤️ NEW: Assistant Vector Stores
MIT License
2.61k stars 302 forks source link

Only Require Faraday Multipart if Faraday Version >= 2 #392

Open ajGingrich opened 7 months ago

ajGingrich commented 7 months ago

Describe the bug

After upgrading from 3.7.0 to the latest version, I see warnings related to already initialized constants from Faraday Multipart. This is because I'm still using Faraday 1.

To Reproduce

Steps to reproduce the behavior:

  1. Use Faraday 1.1
  2. Use latest ruby-openai
  3. See warnings below
/usr/local/bundle/gems/faraday-multipart-1.0.4/lib/faraday/multipart.rb:15: warning: already initialized constant Faraday::FilePart
/usr/local/bundle/gems/faraday-1.1.0/lib/faraday/file_part.rb:53: warning: previous definition of FilePart was here

Expected behavior

Only require faraday multipart if the Faraday version is >= 2 so the constants are not required twice.

Screenshots

image

Additional context

It should be a one line fix here https://github.com/alexrudall/ruby-openai/blob/80da19351b6920309a52b95e18897e23fdf72166/lib/openai.rb#L2

require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')

I can make the change if desired.