diff --git a/lib/openai/internal/util.rb b/lib/openai/internal/util.rb index 91e225b8..4b45e162 100644 --- a/lib/openai/internal/util.rb +++ b/lib/openai/internal/util.rb @@ -61,7 +61,7 @@ class << self # @return [Boolean] def primitive?(input) case input - in true | false | Integer | Float | Symbol | String + in true | false | Numeric | Symbol | String true else false @@ -504,7 +504,7 @@ class << self def encode_content(headers, body) content_type = headers["content-type"] case [content_type, body] - in [%r{^application/(?:vnd\.api\+)?json}, Hash | Array] + in [%r{^application/(?:vnd\.api\+)?json}, _] unless body.nil? [headers, JSON.fast_generate(body)] in [%r{^application/(?:x-)?jsonl}, Enumerable] [headers, body.lazy.map { JSON.fast_generate(_1) }] @@ -516,6 +516,8 @@ def encode_content(headers, body) [headers, body.tap(&:rewind)] in [_, StringIO] [headers, body.string] + in [_, Symbol | Numeric] + [headers, body.to_s] else [headers, body] end