From 3135bd09c24cefb8ae88f5ad479741a784736346 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 5 Apr 2025 13:47:01 +0000 Subject: [PATCH] feat: allow all valid `JSON` types to be encoded --- lib/openai/internal/util.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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