Skip to content

Commit 72c9b8a

Browse files
committed
Increase default timeout to 120 seconds
1 parent f8ec2a8 commit 72c9b8a

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ client = OpenAI::Client.new
7171

7272
#### Setting request timeout
7373

74-
The default timeout for any OpenAI request is 60 seconds. You can change that passing the `request_timeout` when initializing the client:
74+
The default timeout for any OpenAI request is 120 seconds. You can change that passing the `request_timeout` when initializing the client:
7575

7676
```ruby
7777
client = OpenAI::Client.new(access_token: "access_token_goes_here", request_timeout: 25)

lib/openai.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Configuration
1616
attr_accessor :api_version, :organization_id, :request_timeout
1717

1818
DEFAULT_API_VERSION = "v1".freeze
19-
DEFAULT_REQUEST_TIMEOUT = 60
19+
DEFAULT_REQUEST_TIMEOUT = 120
2020

2121
def initialize
2222
@access_token = nil

spec/openai/client/client_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
RSpec.describe OpenAI::Client do
2+
let(:default_timeout) { OpenAI::Configuration::DEFAULT_REQUEST_TIMEOUT }
3+
24
it "can be initialized" do
35
expect { OpenAI::Client.new }.not_to raise_error
46
end
57

68
describe ".get" do
79
it "passes timeout as param to httparty" do
8-
expect(HTTParty).to receive(:get).with(any_args, hash_including(timeout: 60))
10+
expect(HTTParty).to receive(:get).with(any_args, hash_including(timeout: default_timeout))
911
OpenAI::Client.get(path: "abc")
1012
end
1113
end
1214

1315
describe ".json_post" do
1416
it "passes timeout as param to httparty" do
15-
expect(HTTParty).to receive(:post).with(any_args, hash_including(timeout: 60))
17+
expect(HTTParty).to receive(:post).with(any_args, hash_including(timeout: default_timeout))
1618
OpenAI::Client.json_post(path: "abc", parameters: { foo: :bar })
1719
end
1820
end
1921

2022
describe ".multipart_post" do
2123
it "passes timeout as param to httparty" do
22-
expect(HTTParty).to receive(:post).with(any_args, hash_including(timeout: 60))
24+
expect(HTTParty).to receive(:post).with(any_args, hash_including(timeout: default_timeout))
2325
OpenAI::Client.multipart_post(path: "abc")
2426
end
2527
end
2628

2729
describe ".delete" do
2830
it "passes timeout as param to httparty" do
29-
expect(HTTParty).to receive(:delete).with(any_args, hash_including(timeout: 60))
31+
expect(HTTParty).to receive(:delete).with(any_args, hash_including(timeout: default_timeout))
3032
OpenAI::Client.delete(path: "abc")
3133
end
3234
end

0 commit comments

Comments
 (0)