diff --git a/Gemfile.lock b/Gemfile.lock index a9b29979..a4affe22 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,8 +3,9 @@ PATH specs: ruby-openai (6.3.0) event_stream_parser (>= 0.3.0, < 2.0.0) - faraday (>= 1) + faraday (~> 1.10.1) faraday-multipart (>= 1) + faraday_middleware (< 1.2.0) GEM remote: https://rubygems.org/ @@ -12,20 +13,37 @@ GEM addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) - base64 (0.1.1) byebug (11.1.3) crack (0.4.5) rexml diff-lcs (1.5.0) dotenv (2.8.1) event_stream_parser (1.0.0) - faraday (2.7.11) - base64 - faraday-net_http (>= 2.0, < 3.1) + faraday (1.10.3) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.0) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) + faraday-retry (~> 1.0) ruby2_keywords (>= 0.0.4) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) faraday-multipart (1.0.4) multipart-post (~> 2) - faraday-net_http (3.0.2) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + faraday-retry (1.0.3) + faraday_middleware (1.1.0) + faraday (~> 1.0) hashdiff (1.0.1) json (2.6.3) multipart-post (2.3.0) diff --git a/lib/openai.rb b/lib/openai.rb index 704ef6f5..37cce3ed 100644 --- a/lib/openai.rb +++ b/lib/openai.rb @@ -1,5 +1,12 @@ require "faraday" -require "faraday/multipart" if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new("2.0") + +if Gem::Version.new(Faraday::VERSION) <= Gem::Version.new("2.0") + require 'faraday_middleware' + require 'logger' + # require 'json_api_client' +else + require "faraday/multipart" +end require_relative "openai/http" require_relative "openai/client" diff --git a/ruby-openai.gemspec b/ruby-openai.gemspec index 2bd77098..d7b0aa31 100644 --- a/ruby-openai.gemspec +++ b/ruby-openai.gemspec @@ -26,6 +26,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency "event_stream_parser", ">= 0.3.0", "< 2.0.0" - spec.add_dependency "faraday", ">= 1" + spec.add_dependency "faraday", "~> 1.10.1" spec.add_dependency "faraday-multipart", ">= 1" + spec.add_dependency 'faraday_middleware', "< 1.2.0" end diff --git a/spec/openai/client/chat_spec.rb b/spec/openai/client/chat_spec.rb index 20f9a223..d9321551 100644 --- a/spec/openai/client/chat_spec.rb +++ b/spec/openai/client/chat_spec.rb @@ -1,6 +1,6 @@ RSpec.describe OpenAI::Client do describe "#chat" do - context "with messages", :vcr do + context "with messages" do let(:messages) { [{ role: "user", content: "Hello!" }] } let(:stream) { false } let(:response) do diff --git a/spec/openai/client/files_spec.rb b/spec/openai/client/files_spec.rb index 42b5a6f1..b6ee075a 100644 --- a/spec/openai/client/files_spec.rb +++ b/spec/openai/client/files_spec.rb @@ -45,6 +45,10 @@ let(:upload_cassette) { "#{cassette} upload" } let(:response) { OpenAI::Client.new.files.retrieve(id: upload_id) } + # binding.pry + print("foo bar") + print(response) + it "succeeds" do VCR.use_cassette(cassette) do expect(response["filename"]).to eq(filename)