openai_ruby 0.4.3 → 0.5.1

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: 10448ace53f6e68e2bc60436138502f2a14f80d4bd4a45605371c117debb322f
4
- data.tar.gz: b9c0ae0b2ba465cb214bfe5e6cbd5e7ba5a529c2cb074e627673c2d550ccd3cb
3
+ metadata.gz: 43cca3a6a9e872aa7034f2ad8d2ffaae29c4611e3050ee20f2ee45ef79d2faa7
4
+ data.tar.gz: c5e9270b2a86cff363d13befa16106cdbe090eacf45d86883c3b7636cf18e7d8
5
5
  SHA512:
6
- metadata.gz: c1223c6e2ee85062aed87dcee156af3c54f46819c948a15aebf641e2defa0f8a368e69f4c102f4c2ac6a3436950dc0825bd9e39db7251591353327b597265c73
7
- data.tar.gz: 8562163de47249a331df8727ec6347a02699e30d2ad56badc0b4cac3c8815a9c0e12717afe086fce230152d0d150d99f15612e57fdfcdd53d72b1f8453912732
6
+ metadata.gz: b0aa82059a59eb5035d1971792f900cc09cf5ad295066a145d18d75699c50d4c85c6e28719cebac2cba8c830d78d3c90238aecc0f0e0450d995d834a43f2c018
7
+ data.tar.gz: a1efa68b9d6bf3808dee5ea216be1fde0725bed68a7a38adf1db295c2d722b2c9d4f65e912b2ae75453026048b059f431be769cdd4e06c5c0151191083b03acb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openai_ruby (0.4.0)
4
+ openai_ruby (0.5.1)
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
@@ -55,6 +55,25 @@ 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
+ 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
+ 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
@@ -64,7 +83,7 @@ module OpenAI
64
83
  def headers
65
84
  {
66
85
  "Content-Type" => "application/json",
67
- "Authorization" => "Bearer #{api_key}",
86
+ "Authorization" => "Bearer #{api_key}"
68
87
  }
69
88
  end
70
89
 
@@ -73,5 +92,17 @@ 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", "",
101
+ session.to_json],
102
+ ["--#{boundary}--"]
103
+ ]
104
+
105
+ [boundary, parts.flatten.join("\r\n")]
106
+ end
76
107
  end
77
108
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenAI
4
- VERSION = "0.4.3"
4
+ VERSION = "0.5.1"
5
5
  end
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.3
4
+ version: 0.5.1
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-09-28 00:00:00.000000000 Z
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