Skip to content

Commit 489a2c0

Browse files
lalunamelalexrudall
authored andcommitted
Do not log errors by default
1 parent b418ace commit 489a2c0

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ or when configuring the gem:
148148
```ruby
149149
OpenAI.configure do |config|
150150
config.access_token = ENV.fetch("OPENAI_ACCESS_TOKEN")
151-
config.log_errors = false # Optional
151+
config.log_errors = true # Optional
152152
config.organization_id = ENV.fetch("OPENAI_ORGANIZATION_ID") # Optional
153153
config.uri_base = "https://oai.hconeai.com/" # Optional
154154
config.request_timeout = 240 # Optional
@@ -173,12 +173,12 @@ client.add_headers("X-Proxy-TTL" => "43200")
173173

174174
##### Errors
175175

176-
By default, `ruby-openai` logs any `Faraday::Error`s encountered while executing a network request (e.g. 400s, 500s, SSL errors and more - see [here](https://www.rubydoc.info/github/lostisland/faraday/Faraday/Error) for a complete list of subclasses of `Faraday::Error` and what can cause them).
176+
By default, `ruby-openai` does not log any `Faraday::Error`s encountered while executing a network request to avoid leaking data (e.g. 400s, 500s, SSL errors and more - see [here](https://www.rubydoc.info/github/lostisland/faraday/Faraday/Error) for a complete list of subclasses of `Faraday::Error` and what can cause them).
177177

178-
If you would like to disable this functionality, you can set `log_errors` to `false` when configuring the client:
178+
If you would like to enable this functionality, you can set `log_errors` to `true` when configuring the client:
179179

180180
```ruby
181-
client = OpenAI::Client.new(log_errors: false)
181+
client = OpenAI::Client.new(log_errors: true)
182182
```
183183

184184
##### Faraday middleware

lib/openai.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Configuration
4949
DEFAULT_API_VERSION = "v1".freeze
5050
DEFAULT_URI_BASE = "https://api.openai.com/".freeze
5151
DEFAULT_REQUEST_TIMEOUT = 120
52-
DEFAULT_LOG_ERRORS = true
52+
DEFAULT_LOG_ERRORS = false
5353

5454
def initialize
5555
@access_token = nil

spec/openai/client/http_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,14 @@
284284
$stdout = @original_stdout
285285
end
286286

287-
it "happens by default" do
287+
it "is disabled by default" do
288288
VCR.use_cassette(cassette, record: :none) do
289289
expect { OpenAI::Client.new.models.retrieve(id: "text-ada-001") }
290290
.to raise_error Faraday::Error
291291

292292
$stdout.rewind
293293
captured_stdout = $stdout.string
294-
expect(captured_stdout).to include("OpenAI HTTP Error")
294+
expect(captured_stdout).not_to include("OpenAI HTTP Error")
295295
end
296296
end
297297

0 commit comments

Comments
 (0)