openai_ruby 0.4.2 → 0.4.4
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/Gemfile.lock +2 -1
- data/lib/openai_ruby/client.rb +31 -1
- data/lib/openai_ruby/version.rb +1 -1
- 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: f2f23fff1edcd7d6c7a6bc1d605ab251ac74c4aaf29f8c9a3cb3b661cc479bfb
|
|
4
|
+
data.tar.gz: 1cb460f0bb06b19e31121017ee63640dff99fbbda07b8a3487bbcf47a933aa54
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ae36726d144aaec060cad84594e962f4a1689cab2032e1d26ecc00d34229f621b035b072e8d741cadea205c30088fd9244b320b5b3745e6450984a9c893e8dd
|
|
7
|
+
data.tar.gz: 3290de2a8a6a290c7a08a11035a30be26180ae4af372b433dcc55d3d53358f33e486b9a787eb5e843e700942f4c033c7e3c287c23c5c3248bebde5126412f7bc
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
openai_ruby (0.4.
|
|
4
|
+
openai_ruby (0.4.4)
|
|
5
5
|
event_stream_parser (~> 1.0)
|
|
6
6
|
faraday (~> 2.7)
|
|
7
7
|
|
|
@@ -55,6 +55,7 @@ GEM
|
|
|
55
55
|
PLATFORMS
|
|
56
56
|
arm64-darwin-21
|
|
57
57
|
arm64-darwin-22
|
|
58
|
+
arm64-darwin-24
|
|
58
59
|
x86_64-linux
|
|
59
60
|
|
|
60
61
|
DEPENDENCIES
|
data/lib/openai_ruby/client.rb
CHANGED
|
@@ -55,10 +55,29 @@ module OpenAI
|
|
|
55
55
|
@images ||= OpenAI::Images.new(connection)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
def create_realtime_call(sdp_offer:, session: nil)
|
|
59
|
+
uri = "#{base_uri}/v1/realtime/calls"
|
|
60
|
+
|
|
61
|
+
if session
|
|
62
|
+
boundary, body = build_multipart_body(sdp_offer, session)
|
|
63
|
+
response = Faraday.post(uri) do |req|
|
|
64
|
+
req.headers["Authorization"] = "Bearer #{api_key}"
|
|
65
|
+
req.headers["Content-Type"] = "multipart/form-data; boundary=#{boundary}"
|
|
66
|
+
req.body = body
|
|
67
|
+
end
|
|
68
|
+
else
|
|
69
|
+
response = Faraday.post(uri) do |req|
|
|
70
|
+
req.headers["Content-Type"] = "application/sdp"
|
|
71
|
+
req.headers["Authorization"] = "Bearer #{api_key}"
|
|
72
|
+
req.body = sdp_offer
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
58
77
|
private
|
|
59
78
|
|
|
60
79
|
def connection
|
|
61
|
-
Faraday.new({ url: base_uri, headers: headers }.merge(options))
|
|
80
|
+
Faraday.new({ url: base_uri, headers: headers }.merge(options.except(:base_uri)))
|
|
62
81
|
end
|
|
63
82
|
|
|
64
83
|
def headers
|
|
@@ -73,5 +92,16 @@ module OpenAI
|
|
|
73
92
|
rescue JSON::ParserError
|
|
74
93
|
default_value || maybe_json
|
|
75
94
|
end
|
|
95
|
+
|
|
96
|
+
def build_multipart_body(sdp_offer, session)
|
|
97
|
+
boundary = "----RubyFormBoundary#{SecureRandom.hex(16)}"
|
|
98
|
+
parts = [
|
|
99
|
+
["--#{boundary}", 'Content-Disposition: form-data; name="sdp"', "Content-Type: application/sdp", "", sdp_offer],
|
|
100
|
+
["--#{boundary}", 'Content-Disposition: form-data; name="session"', "Content-Type: application/json", "", session.to_json],
|
|
101
|
+
["--#{boundary}--"],
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
[boundary, parts.flatten.join("\r\n")]
|
|
105
|
+
end
|
|
76
106
|
end
|
|
77
107
|
end
|
data/lib/openai_ruby/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openai_ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Renny Ren
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-12-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: event_stream_parser
|