Skip to content

Commit 8a0bf70

Browse files
committed
Fix warning: JSON.fast_generate is deprecated
Use JSON.generate instead.
1 parent ac3c96c commit 8a0bf70

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/openai/internal/util.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ class << self
515515
y << val.to_s
516516
else
517517
y << "Content-Type: application/json\r\n\r\n"
518-
y << JSON.fast_generate(val)
518+
y << JSON.generate(val)
519519
end
520520
y << "\r\n"
521521
end
@@ -564,9 +564,9 @@ def encode_content(headers, body)
564564

565565
case [content_type, body]
566566
in [%r{^application/(?:vnd\.api\+)?json}, Hash | Array | -> { primitive?(_1) }]
567-
[headers, JSON.fast_generate(body)]
567+
[headers, JSON.generate(body)]
568568
in [%r{^application/(?:x-)?jsonl}, Enumerable] unless body.is_a?(StringIO) || body.is_a?(IO)
569-
[headers, body.lazy.map { JSON.fast_generate(_1) }]
569+
[headers, body.lazy.map { JSON.generate(_1) }]
570570
in [%r{^multipart/form-data}, Hash | Pathname | StringIO | IO]
571571
boundary, strio = encode_multipart_streaming(body)
572572
headers = {**headers, "content-type" => "#{content_type}; boundary=#{boundary}"}

test/openai/client_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class MockRequester
3737
def initialize(response_code, response_headers, response_data)
3838
@response_code = response_code
3939
@response_headers = response_headers
40-
@response_data = JSON.fast_generate(response_data)
40+
@response_data = JSON.generate(response_data)
4141
@attempts = []
4242
end
4343

0 commit comments

Comments
 (0)