Class: OpenAI::Resources::Live::Sessions
- Inherits:
-
Object
- Object
- OpenAI::Resources::Live::Sessions
- Defined in:
- lib/openai/resources/live/sessions.rb,
sig/openai/resources/live/sessions.rbs
Instance Method Summary collapse
-
#accept(session_id, session:, request_options: {}) ⇒ nil
Accept an incoming SIP call.
-
#download_recording(session_id, request_options: {}) ⇒ StringIO
Get Live session content.
-
#fork(session_id, transport:, session: nil, request_options: {}) ⇒ OpenAI::Models::Live::SessionForkResponse
Fork a stored Live session onto a new WebRTC connection.
-
#hangup(session_id, request_options: {}) ⇒ nil
End a SIP call identified by session_id.
-
#initialize(client:) ⇒ Sessions
constructor
private
A new instance of Sessions.
-
#refer(session_id, target_uri:, request_options: {}) ⇒ nil
Transfer a SIP call to another destination.
-
#reject(session_id, status_code:, request_options: {}) ⇒ nil
Reject an incoming SIP call.
Constructor Details
#initialize(client:) ⇒ Sessions
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Sessions.
180 181 182 |
# File 'lib/openai/resources/live/sessions.rb', line 180 def initialize(client:) @client = client end |
Instance Method Details
#accept(session_id, session:, request_options: {}) ⇒ nil
Accept an incoming SIP call. Supply session with type live, the model, and startup configuration. Before accepting calls, follow the Live prompting guide to write frontend conversation instructions and a separate backend prompt. SIP media format is negotiated; omit audio.format.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/openai/resources/live/sessions.rb', line 28 def accept(session_id, params) parsed, = OpenAI::Live::SessionAcceptParams.dump_request(params) @client.request( method: :post, path: ["live/sessions/%1$s/accept", session_id], body: parsed, model: NilClass, security: {bearer_auth: true}, options: ) end |
#download_recording(session_id, request_options: {}) ⇒ StringIO
Get Live session content
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/openai/resources/live/sessions.rb', line 53 def download_recording(session_id, params = {}) @client.request( method: :get, path: ["live/sessions/%1$s/content", session_id], headers: {"accept" => "application/binary"}, model: StringIO, security: {bearer_auth: true}, options: params[:request_options] ) end |
#fork(session_id, transport:, session: nil, request_options: {}) ⇒ OpenAI::Models::Live::SessionForkResponse
Fork a stored Live session onto a new WebRTC connection.
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/openai/resources/live/sessions.rb', line 83 def fork(session_id, params) parsed, = OpenAI::Live::SessionForkParams.dump_request(params) @client.request( method: :post, path: ["live/sessions/%1$s/fork", session_id], body: parsed, model: OpenAI::Models::Live::SessionForkResponse, security: {bearer_auth: true}, options: ) end |
#hangup(session_id, request_options: {}) ⇒ nil
End a SIP call identified by session_id.
108 109 110 111 112 113 114 115 116 |
# File 'lib/openai/resources/live/sessions.rb', line 108 def hangup(session_id, params = {}) @client.request( method: :post, path: ["live/sessions/%1$s/hangup", session_id], model: NilClass, security: {bearer_auth: true}, options: params[:request_options] ) end |
#refer(session_id, target_uri:, request_options: {}) ⇒ nil
Transfer a SIP call to another destination. Supply a nonblank target_uri for the SIP Refer-To header.
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/openai/resources/live/sessions.rb', line 136 def refer(session_id, params) parsed, = OpenAI::Live::SessionReferParams.dump_request(params) @client.request( method: :post, path: ["live/sessions/%1$s/refer", session_id], body: parsed, model: NilClass, security: {bearer_auth: true}, options: ) end |
#reject(session_id, status_code:, request_options: {}) ⇒ nil
Reject an incoming SIP call. Send a required SIP rejection status_code between 300 and 699.
165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/openai/resources/live/sessions.rb', line 165 def reject(session_id, params) parsed, = OpenAI::Live::SessionRejectParams.dump_request(params) @client.request( method: :post, path: ["live/sessions/%1$s/reject", session_id], body: parsed, model: NilClass, security: {bearer_auth: true}, options: ) end |