Class: Neh::Cli::O
- Inherits:
-
Object
- Object
- Neh::Cli::O
- Defined in:
- lib/neh/cli/o.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(*args, options:) ⇒ O
constructor
A new instance of O.
Constructor Details
#initialize(*args, options:) ⇒ O
Returns a new instance of O.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/neh/cli/o.rb', line 14 def initialize(*args, options:) @message = args.join(' ') @options = server_host = ENV.fetch('NEH_SERVER_HOST', 'yoryo.gipcompany.com') server_port = ENV.fetch('NEH_SERVER_PORT', 443) @channel = 'LargeLanguageModelQueryChannel' url = "ws://#{server_host}:#{server_port}/cable" @endpoint = Async::HTTP::Endpoint.parse(url) end |
Instance Method Details
#execute ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/neh/cli/o.rb', line 26 def execute Async do |_task| Async::WebSocket::Client.connect(@endpoint, headers: { 'Authorization' => "Bearer #{token}" }) do |connection| while ( = connection.read) = JSON.parse(, symbolize_names: true) on_receive(connection, ) end end end end |