ruby-openai 4.3.0 → 4.3.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: 666cf605fbc981b59131ef5005ec32fd0eabd604f924d907ae0ee0d707b739bb
4
- data.tar.gz: fe938931bad97952bd8829ab1ec336896c12ed247c18bc62f3df116917919498
3
+ metadata.gz: 9007c29faed86a4792fd80cd1081ddf18be51f71700ca7569dc05088bdf711fa
4
+ data.tar.gz: 6d190ab521aeada561ddaf72a5922d7d603d799a3e2e841e49ad5d9942c97bba
5
5
  SHA512:
6
- metadata.gz: 2799064a7bbfc79dc47ea4168b0a7755e53aad89e3f3d55a79defba569592141aca70bdfd86747d1690b4ab72acf0d542844d6dd7f1fc8e235c6e3bf7f911854
7
- data.tar.gz: d81441ee5b5a1b4070c438ae02f363b95f133d571971c9876bd1cc239225cbd193955c4ce23efbba0c45af6d2726d06bd6d27b418a2a682edcf9de5c1c701b7f
6
+ metadata.gz: cf02b7a6170d0497365b6dc1ee93e647f62f5eaf3080f3e27df42c58200c34b395aa8b7d0bfa1cec521bd00f4ede3a49983f40e074b8bb1d6dcba0a40a3373a5
7
+ data.tar.gz: 63d37b64f16825ff36314a66bb75b3188916fa03d2ee25e78f7dc7605a6734976c3678ac01fd398d4e96b0166d22de47a0f940c018b081c120c30d063dbc4963
data/CHANGELOG.md CHANGED
@@ -5,7 +5,20 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [4.3.0] - 2023-06-20
8
+ ## [4.3.1] - 2023-08-13
9
+
10
+ ### Fixed
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
+
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!
20
+
21
+ ## [4.3.0] - 2023-08-12
9
22
 
10
23
  ### Added
11
24
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-openai (4.3.0)
4
+ ruby-openai (4.3.2)
5
5
  faraday (>= 1)
6
6
  faraday-multipart (>= 1)
7
7
 
data/README.md CHANGED
@@ -79,8 +79,8 @@ client = OpenAI::Client.new(
79
79
  request_timeout: 240,
80
80
  extra_headers: {
81
81
  "X-Proxy-TTL" => "43200", # For https://github.com/6/openai-caching-proxy-worker#specifying-a-cache-ttl
82
- "X-Proxy-Refresh": "true" # For https://github.com/6/openai-caching-proxy-worker#refreshing-the-cache
83
- "Helicone-Auth": "Bearer HELICONE_API_KEY", # For https://docs.helicone.ai/getting-started/integration-method/openai-proxy
82
+ "X-Proxy-Refresh": "true", # For https://github.com/6/openai-caching-proxy-worker#refreshing-the-cache
83
+ "Helicone-Auth": "Bearer HELICONE_API_KEY" # For https://docs.helicone.ai/getting-started/integration-method/openai-proxy
84
84
  }
85
85
  )
86
86
  ```
@@ -95,8 +95,8 @@ OpenAI.configure do |config|
95
95
  config.request_timeout = 240 # Optional
96
96
  config.extra_headers = {
97
97
  "X-Proxy-TTL" => "43200", # For https://github.com/6/openai-caching-proxy-worker#specifying-a-cache-ttl
98
- "X-Proxy-Refresh": "true" # For https://github.com/6/openai-caching-proxy-worker#refreshing-the-cache
99
- "Helicone-Auth": "Bearer HELICONE_API_KEY", # For https://docs.helicone.ai/getting-started/integration-method/openai-proxy
98
+ "X-Proxy-Refresh": "true", # For https://github.com/6/openai-caching-proxy-worker#refreshing-the-cache
99
+ "Helicone-Auth": "Bearer HELICONE_API_KEY" # For https://docs.helicone.ai/getting-started/integration-method/openai-proxy
100
100
  } # Optional
101
101
  end
102
102
  ```
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
@@ -97,9 +103,9 @@ module OpenAI
97
103
 
98
104
  def multipart_parameters(parameters)
99
105
  parameters&.transform_values do |value|
100
- next value unless value.is_a?(File)
106
+ next value unless value.respond_to?(:close) # File or IO object.
101
107
 
102
- # Doesn't seem like OpenAI need mime_type yet, so not worth
108
+ # Doesn't seem like OpenAI needs mime_type yet, so not worth
103
109
  # the library to figure this out. Hence the empty string
104
110
  # as the second argument.
105
111
  Faraday::UploadIO.new(value, "", value.path)
@@ -1,3 +1,3 @@
1
1
  module OpenAI
2
- VERSION = "4.3.0".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.0
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-12 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