Closed adenta closed 2 days ago
This looks like a missing feature.
Hi, I'm able to do it with async. example:
def ws_client
require "async"
require "async/http"
require "async/websocket"
url = "wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-10-01"
# Creating headers for the request
headers = {
"Authorization" => "Bearer #{ENV.fetch('OPENAI_API_KEY', nil)}",
"OpenAI-Beta" => "realtime=v1"
}
Async do |task|
endpoint = Async::HTTP::Endpoint.parse(url, alpn_protocols: Async::HTTP::Protocol::HTTP11.names)
Async::WebSocket::Client.connect(endpoint, headers: headers) do |connection|
input_task = task.async do
while line = $stdin.gets
text = {
type: "response.create",
response: {
modalities: ["text"],
instructions: "Please assist the user."
}
}
message = Protocol::WebSocket::TextMessage.generate(text) # ({ text: line })
message.send(connection)
connection.flush
end
end
puts "Connected..."
while message = connection.read
puts "> #{message.to_h}"
end
ensure
input_task&.stop
end
end
end
Are you seeing session.created
events from the server? Would the above example work with function calling?
I was able to get a basic example working, but it would not call defined tools/functions
looks like this is the async-websocket repo, not the ruby-openai, so closing
Okay, just to confirm, this is now working for you, at least the websocket part?
It’s working for the other guy, I haven’t tested it yet. I went with Faye
On Thu, Oct 17, 2024 at 6:47 PM Samuel Williams @.***> wrote:
Okay, just to confirm, this is now working for you, at least the websocket part?
— Reply to this email directly, view it on GitHub https://github.com/socketry/async-websocket/issues/75#issuecomment-2420755339, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACGUU5VKM7DC4ER7KLWMQ2DZ4A475AVCNFSM6AAAAABQCXDRJGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRQG42TKMZTHE . You are receiving this because you modified the open/close state.Message ID: @.***>
Couldn't find documentation either.
gives me a
Failed to negotiate connection!
when a similar turn of phrase works with websocket-client-simple. I am fairly certain I am not passing in the headers properly, and I couldnt find any documentation about what exactly this library is looking for.