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 +4 -4
- data/CHANGELOG.md +14 -1
- data/Gemfile.lock +1 -1
- data/README.md +4 -4
- data/lib/openai/client.rb +2 -2
- data/lib/openai/http.rb +10 -4
- data/lib/openai/version.rb +1 -1
- data/lib/openai.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9007c29faed86a4792fd80cd1081ddf18be51f71700ca7569dc05088bdf711fa
|
4
|
+
data.tar.gz: 6d190ab521aeada561ddaf72a5922d7d603d799a3e2e841e49ad5d9942c97bba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
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"
|
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"
|
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
|
-
|
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
|
-
}
|
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.
|
106
|
+
next value unless value.respond_to?(:close) # File or IO object.
|
101
107
|
|
102
|
-
# Doesn't seem like OpenAI
|
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)
|
data/lib/openai/version.rb
CHANGED
data/lib/openai.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2023-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|