openai 0.35.0 → 0.35.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abaa011e78b024745cccd6b1efad5fb9a3c5201aeb60257d0237c6c78097bb0c
4
- data.tar.gz: 9dde864dac2f4b5535cf3793093a7d06c4675f1d1f1f7d0f25eaed5e51e76d6e
3
+ metadata.gz: a382ad359ddcf643add7dacb494b3ae4a168613ef39f5bcd42714fc1442d02ba
4
+ data.tar.gz: f28ed9c7f0e0a90a962568a3ae3ae47a07b8bd563b2a81720499c7ba7ec8fb6e
5
5
  SHA512:
6
- metadata.gz: 77f016fb4b47043ee5e6ce97095a948d1b255f919e17548e2c495c3545d3cad7506fcf01c6b473df5114be3d70910c0a858da727f5284a1bbae16178c96ec739
7
- data.tar.gz: 7b4ff9197e751ebc3266d56b5e714b784215c868e5df1aecc716fba0cfd3e4dcaeefb5d051e9132e126191e098441fc1429a1d93ab49c71af67afdc4b1354a4a
6
+ metadata.gz: 445ec7a996ba1f852090a1c0b7c6b1f5a3b448ab5bdb94be1475b6fae76b25085dd6e494d8e811e7c440978783b8c10e559665ded5a294c69d00006c86d3e774
7
+ data.tar.gz: 9407b17d49a8749eb432a60348b382176ff19663f321dd3283d38848a7a9247be3f480b3e46d002b028580a9c045f63fe0a48436a8447fae225cb602b93c8fce
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.35.2 (2025-11-05)
4
+
5
+ Full Changelog: [v0.35.1...v0.35.2](https://github.com/openai/openai-ruby/compare/v0.35.1...v0.35.2)
6
+
7
+ ### Bug Fixes
8
+
9
+ * better thread safety via early initializing SSL store during HTTP client creation ([e7d9a3d](https://github.com/openai/openai-ruby/commit/e7d9a3d70c0930ac248b4da680296213cb3e163d))
10
+ * schema generation ([#862](https://github.com/openai/openai-ruby/issues/862)) ([2c9b91a](https://github.com/openai/openai-ruby/commit/2c9b91acc79262dd56ef52854ad64384f172984b))
11
+
12
+ ## 0.35.1 (2025-11-04)
13
+
14
+ Full Changelog: [v0.35.0...v0.35.1](https://github.com/openai/openai-ruby/compare/v0.35.0...v0.35.1)
15
+
16
+ ### Bug Fixes
17
+
18
+ * **api:** fix nullability of logprobs ([adead66](https://github.com/openai/openai-ruby/commit/adead661c71c8c5f6420bbafc5fa5b188758ddc5))
19
+
3
20
  ## 0.35.0 (2025-11-03)
4
21
 
5
22
  Full Changelog: [v0.34.1...v0.35.0](https://github.com/openai/openai-ruby/compare/v0.34.1...v0.35.0)
data/README.md CHANGED
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
15
15
  <!-- x-release-please-start-version -->
16
16
 
17
17
  ```ruby
18
- gem "openai", "~> 0.35.0"
18
+ gem "openai", "~> 0.35.2"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -21,6 +21,7 @@ module OpenAI
21
21
  #
22
22
  # @return [Hash{Symbol=>Object}]
23
23
  def to_json_schema_inner(state:)
24
+ # rubocop:disable Metrics/BlockLength
24
25
  OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.cache_def!(state, type: self) do
25
26
  path = state.fetch(:path)
26
27
  mergeable_keys = {[:anyOf] => 0, [:type] => 0}
@@ -33,7 +34,9 @@ module OpenAI
33
34
  end
34
35
 
35
36
  schemas.each do |schema|
36
- mergeable_keys.each_key { mergeable_keys[_1] += 1 if schema.keys == _1 }
37
+ mergeable_keys.each_key do
38
+ mergeable_keys[_1] += 1 if schema.keys == _1 && schema[_1].is_a?(Array)
39
+ end
37
40
  end
38
41
  mergeable = mergeable_keys.any? { _1.last == schemas.length }
39
42
  if mergeable
@@ -48,6 +51,7 @@ module OpenAI
48
51
  }
49
52
  end
50
53
  end
54
+ # rubocop:enable Metrics/BlockLength
51
55
  end
52
56
 
53
57
  private_class_method :new
@@ -16,10 +16,11 @@ module OpenAI
16
16
  class << self
17
17
  # @api private
18
18
  #
19
+ # @param cert_store [OpenSSL::X509::Store]
19
20
  # @param url [URI::Generic]
20
21
  #
21
22
  # @return [Net::HTTP]
22
- def connect(url)
23
+ def connect(cert_store:, url:)
23
24
  port =
24
25
  case [url.port, url.scheme]
25
26
  in [Integer, _]
@@ -33,6 +34,8 @@ module OpenAI
33
34
  Net::HTTP.new(url.host, port).tap do
34
35
  _1.use_ssl = %w[https wss].include?(url.scheme)
35
36
  _1.max_retries = 0
37
+
38
+ (_1.cert_store = cert_store) if _1.use_ssl?
36
39
  end
37
40
  end
38
41
 
@@ -102,7 +105,7 @@ module OpenAI
102
105
  pool =
103
106
  @mutex.synchronize do
104
107
  @pools[origin] ||= ConnectionPool.new(size: @size) do
105
- self.class.connect(url)
108
+ self.class.connect(cert_store: @cert_store, url: url)
106
109
  end
107
110
  end
108
111
 
@@ -192,6 +195,7 @@ module OpenAI
192
195
  def initialize(size: self.class::DEFAULT_MAX_CONNECTIONS)
193
196
  @mutex = Mutex.new
194
197
  @size = size
198
+ @cert_store = OpenSSL::X509::Store.new.tap(&:set_default_paths)
195
199
  @pools = {}
196
200
  end
197
201
 
@@ -11,11 +11,6 @@ module OpenAI
11
11
  required :annotations,
12
12
  -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::ResponseOutputText::Annotation] }
13
13
 
14
- # @!attribute logprobs
15
- #
16
- # @return [Array<OpenAI::Models::Responses::ResponseOutputText::Logprob>]
17
- required :logprobs, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseOutputText::Logprob] }
18
-
19
14
  # @!attribute text
20
15
  # The text output from the model.
21
16
  #
@@ -36,15 +31,20 @@ module OpenAI
36
31
  # @return [Symbol, :output_text]
37
32
  required :type, const: :output_text
38
33
 
39
- # @!method initialize(annotations:, logprobs:, text:, type: :output_text)
34
+ # @!attribute logprobs
35
+ #
36
+ # @return [Array<OpenAI::Models::Responses::ResponseOutputText::Logprob>, nil]
37
+ optional :logprobs, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseOutputText::Logprob] }
38
+
39
+ # @!method initialize(annotations:, text:, logprobs: nil, type: :output_text)
40
40
  # A text output from the model.
41
41
  #
42
42
  # @param annotations [Array<OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::ContainerFileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath>] The annotations of the text output.
43
43
  #
44
- # @param logprobs [Array<OpenAI::Models::Responses::ResponseOutputText::Logprob>]
45
- #
46
44
  # @param text [String] The text output from the model.
47
45
  #
46
+ # @param logprobs [Array<OpenAI::Models::Responses::ResponseOutputText::Logprob>]
47
+ #
48
48
  # @param type [Symbol, :output_text] The type of the output text. Always `output_text`.
49
49
 
50
50
  # A citation to a file.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenAI
4
- VERSION = "0.35.0"
4
+ VERSION = "0.35.2"
5
5
  end
data/lib/openai.rb CHANGED
@@ -8,6 +8,7 @@ require "erb"
8
8
  require "etc"
9
9
  require "json"
10
10
  require "net/http"
11
+ require "openssl"
11
12
  require "pathname"
12
13
  require "rbconfig"
13
14
  require "securerandom"
data/manifest.yaml CHANGED
@@ -6,6 +6,7 @@ dependencies:
6
6
  - etc
7
7
  - json
8
8
  - net/http
9
+ - openssl
9
10
  - pathname
10
11
  - rbconfig
11
12
  - securerandom
@@ -26,8 +26,12 @@ module OpenAI
26
26
 
27
27
  class << self
28
28
  # @api private
29
- sig { params(url: URI::Generic).returns(Net::HTTP) }
30
- def connect(url)
29
+ sig do
30
+ params(cert_store: OpenSSL::X509::Store, url: URI::Generic).returns(
31
+ Net::HTTP
32
+ )
33
+ end
34
+ def connect(cert_store:, url:)
31
35
  end
32
36
 
33
37
  # @api private
@@ -27,11 +27,6 @@ module OpenAI
27
27
  end
28
28
  attr_accessor :annotations
29
29
 
30
- sig do
31
- returns(T::Array[OpenAI::Responses::ResponseOutputText::Logprob])
32
- end
33
- attr_accessor :logprobs
34
-
35
30
  # The text output from the model.
36
31
  sig { returns(String) }
37
32
  attr_accessor :text
@@ -44,6 +39,21 @@ module OpenAI
44
39
  sig { returns(Symbol) }
45
40
  attr_accessor :type
46
41
 
42
+ sig do
43
+ returns(
44
+ T.nilable(T::Array[OpenAI::Responses::ResponseOutputText::Logprob])
45
+ )
46
+ end
47
+ attr_reader :logprobs
48
+
49
+ sig do
50
+ params(
51
+ logprobs:
52
+ T::Array[OpenAI::Responses::ResponseOutputText::Logprob::OrHash]
53
+ ).void
54
+ end
55
+ attr_writer :logprobs
56
+
47
57
  # A text output from the model.
48
58
  sig do
49
59
  params(
@@ -56,18 +66,18 @@ module OpenAI
56
66
  OpenAI::Responses::ResponseOutputText::Annotation::FilePath::OrHash
57
67
  )
58
68
  ],
69
+ text: String,
59
70
  logprobs:
60
71
  T::Array[OpenAI::Responses::ResponseOutputText::Logprob::OrHash],
61
- text: String,
62
72
  type: Symbol
63
73
  ).returns(T.attached_class)
64
74
  end
65
75
  def self.new(
66
76
  # The annotations of the text output.
67
77
  annotations:,
68
- logprobs:,
69
78
  # The text output from the model.
70
79
  text:,
80
+ logprobs: nil,
71
81
  # The type of the output text. Always `output_text`.
72
82
  type: :output_text
73
83
  )
@@ -85,10 +95,9 @@ module OpenAI
85
95
  OpenAI::Responses::ResponseOutputText::Annotation::FilePath
86
96
  )
87
97
  ],
88
- logprobs:
89
- T::Array[OpenAI::Responses::ResponseOutputText::Logprob],
90
98
  text: String,
91
- type: Symbol
99
+ type: Symbol,
100
+ logprobs: T::Array[OpenAI::Responses::ResponseOutputText::Logprob]
92
101
  }
93
102
  )
94
103
  end
@@ -17,7 +17,10 @@ module OpenAI
17
17
 
18
18
  DEFAULT_MAX_CONNECTIONS: Integer
19
19
 
20
- def self.connect: (URI::Generic url) -> top
20
+ def self.connect: (
21
+ cert_store: OpenSSL::X509::Store,
22
+ url: URI::Generic
23
+ ) -> top
21
24
 
22
25
  def self.calibrate_socket_timeout: (top conn, Float deadline) -> void
23
26
 
@@ -4,32 +4,36 @@ module OpenAI
4
4
  type response_output_text =
5
5
  {
6
6
  annotations: ::Array[OpenAI::Models::Responses::ResponseOutputText::annotation],
7
- logprobs: ::Array[OpenAI::Responses::ResponseOutputText::Logprob],
8
7
  text: String,
9
- type: :output_text
8
+ type: :output_text,
9
+ logprobs: ::Array[OpenAI::Responses::ResponseOutputText::Logprob]
10
10
  }
11
11
 
12
12
  class ResponseOutputText < OpenAI::Internal::Type::BaseModel
13
13
  attr_accessor annotations: ::Array[OpenAI::Models::Responses::ResponseOutputText::annotation]
14
14
 
15
- attr_accessor logprobs: ::Array[OpenAI::Responses::ResponseOutputText::Logprob]
16
-
17
15
  attr_accessor text: String
18
16
 
19
17
  attr_accessor type: :output_text
20
18
 
19
+ attr_reader logprobs: ::Array[OpenAI::Responses::ResponseOutputText::Logprob]?
20
+
21
+ def logprobs=: (
22
+ ::Array[OpenAI::Responses::ResponseOutputText::Logprob]
23
+ ) -> ::Array[OpenAI::Responses::ResponseOutputText::Logprob]
24
+
21
25
  def initialize: (
22
26
  annotations: ::Array[OpenAI::Models::Responses::ResponseOutputText::annotation],
23
- logprobs: ::Array[OpenAI::Responses::ResponseOutputText::Logprob],
24
27
  text: String,
28
+ ?logprobs: ::Array[OpenAI::Responses::ResponseOutputText::Logprob],
25
29
  ?type: :output_text
26
30
  ) -> void
27
31
 
28
32
  def to_hash: -> {
29
33
  annotations: ::Array[OpenAI::Models::Responses::ResponseOutputText::annotation],
30
- logprobs: ::Array[OpenAI::Responses::ResponseOutputText::Logprob],
31
34
  text: String,
32
- type: :output_text
35
+ type: :output_text,
36
+ logprobs: ::Array[OpenAI::Responses::ResponseOutputText::Logprob]
33
37
  }
34
38
 
35
39
  type annotation =
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.35.0
4
+ version: 0.35.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenAI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-03 00:00:00.000000000 Z
11
+ date: 2025-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool