ruby-openai 4.3.1 → 4.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53106fa1f3731bc10d9ab14609fe6db5eb1f439d100acdba6ddbc43b76abb015
4
- data.tar.gz: be123d1eccd0035d8b5c4cbd390f4392d66461230a5ec0ebbb0a0d1c3b0b0e8a
3
+ metadata.gz: 9007c29faed86a4792fd80cd1081ddf18be51f71700ca7569dc05088bdf711fa
4
+ data.tar.gz: 6d190ab521aeada561ddaf72a5922d7d603d799a3e2e841e49ad5d9942c97bba
5
5
  SHA512:
6
- metadata.gz: e5d6b68594c5ef30595f7921456795a3f05c0aac613126ea50612459a88c3dee15e91f30d07bb9bc2ce8bf6effda80969d4b9f90ed4927349a9b77d90659f550
7
- data.tar.gz: 3e96a3800503abd981999a5751b142c31566f8c34eb2e624d2858e165abc949413987b6046d6942a7f3fc7695af0dca1e70b874f08258a8e593def845daebed8
6
+ metadata.gz: cf02b7a6170d0497365b6dc1ee93e647f62f5eaf3080f3e27df42c58200c34b395aa8b7d0bfa1cec521bd00f4ede3a49983f40e074b8bb1d6dcba0a40a3373a5
7
+ data.tar.gz: 63d37b64f16825ff36314a66bb75b3188916fa03d2ee25e78f7dc7605a6734976c3678ac01fd398d4e96b0166d22de47a0f940c018b081c120c30d063dbc4963
data/CHANGELOG.md CHANGED
@@ -9,6 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ### Fixed
11
11
 
12
+ - Don't overwrite config extra-headers when making a client without different ones. Thanks to [@swistaczek](https://github.com/swistaczek) for raising this!
13
+ - Include extra-headers for Azure requests.
14
+
15
+ ## [4.3.1] - 2023-08-13
16
+
17
+ ### Fixed
18
+
12
19
  - Tempfiles can now be sent to the API as well as Files, eg for Whisper. Thanks to [@codergeek121](https://github.com/codergeek121) for the fix!
13
20
 
14
21
  ## [4.3.0] - 2023-08-12
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-openai (4.3.1)
4
+ ruby-openai (4.3.2)
5
5
  faraday (>= 1)
6
6
  faraday-multipart (>= 1)
7
7
 
data/lib/openai/client.rb CHANGED
@@ -3,12 +3,12 @@ module OpenAI
3
3
  extend OpenAI::HTTP
4
4
 
5
5
  def initialize(access_token: nil, organization_id: nil, uri_base: nil, request_timeout: nil,
6
- extra_headers: {})
6
+ extra_headers: nil)
7
7
  OpenAI.configuration.access_token = access_token if access_token
8
8
  OpenAI.configuration.organization_id = organization_id if organization_id
9
9
  OpenAI.configuration.uri_base = uri_base if uri_base
10
10
  OpenAI.configuration.request_timeout = request_timeout if request_timeout
11
- OpenAI.configuration.extra_headers = extra_headers
11
+ OpenAI.configuration.extra_headers = extra_headers if extra_headers
12
12
  end
13
13
 
14
14
  def chat(parameters: {})
data/lib/openai/http.rb CHANGED
@@ -79,13 +79,19 @@ module OpenAI
79
79
  end
80
80
 
81
81
  def headers
82
- return azure_headers if OpenAI.configuration.api_type == :azure
82
+ if OpenAI.configuration.api_type == :azure
83
+ azure_headers
84
+ else
85
+ openai_headers
86
+ end.merge(OpenAI.configuration.extra_headers || {})
87
+ end
83
88
 
89
+ def openai_headers
84
90
  {
85
91
  "Content-Type" => "application/json",
86
92
  "Authorization" => "Bearer #{OpenAI.configuration.access_token}",
87
93
  "OpenAI-Organization" => OpenAI.configuration.organization_id
88
- }.merge(OpenAI.configuration.extra_headers)
94
+ }
89
95
  end
90
96
 
91
97
  def azure_headers
@@ -1,3 +1,3 @@
1
1
  module OpenAI
2
- VERSION = "4.3.1".freeze
2
+ VERSION = "4.3.2".freeze
3
3
  end
data/lib/openai.rb CHANGED
@@ -29,6 +29,7 @@ module OpenAI
29
29
  @organization_id = nil
30
30
  @uri_base = DEFAULT_URI_BASE
31
31
  @request_timeout = DEFAULT_REQUEST_TIMEOUT
32
+ @extra_headers = nil
32
33
  end
33
34
 
34
35
  def access_token
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-openai
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.1
4
+ version: 4.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-13 00:00:00.000000000 Z
11
+ date: 2023-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday