Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/openai/internal/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def writable_enum(&blk)
# @type [Regexp]
JSON_CONTENT = %r{^application/(?:[a-zA-Z0-9.-]+\+)?json(?!l)}
# @type [Regexp]
JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}
JSONL_CONTENT = %r{\Aapplication/(?:x-(?:n|l)djson|(?:x-)?jsonl)(?:\s*;|\z)}i

class << self
# @api private
Expand Down
5 changes: 4 additions & 1 deletion rbi/openai/internal/util.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@ module OpenAI
JSON_CONTENT =
T.let(%r{^application/(?:[a-zA-Z0-9.-]+\+)?json(?!l)}, Regexp)
JSONL_CONTENT =
T.let(%r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}, Regexp)
T.let(
%r{\Aapplication/(?:x-(?:n|l)djson|(?:x-)?jsonl)(?:\s*;|\z)}i,
Regexp
)

class << self
# @api private
Expand Down
7 changes: 6 additions & 1 deletion test/openai/internal/util_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,13 @@ def test_jsonl_content
"application/x-ldjson" => true,
"application/jsonl" => true,
"application/x-jsonl" => true,
"application/jsonl; charset=utf-8" => true,
"APPLICATION/JSONL" => true,
"application/json" => false,
"application/vnd.api+json" => false
"application/vnd.api+json" => false,
"text/plain; name=jsonl" => false,
"foojsonlbar" => false,
"application/notjsonlbutjsonl" => false
}
cases.each do |header, verdict|
assert_pattern do
Expand Down