neh 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57b439f5f249bf9904c1120635eef65b477a8ad769c1f52c7a47b95d48fc6ffc
4
- data.tar.gz: a873810f8083889464e4de53f6f28468e3fa1a589b187542d435eea37f4639ab
3
+ metadata.gz: acfcef0ee91e2a3a87f1618116449112811a1db27d457f4b822618e73823935c
4
+ data.tar.gz: 8573e2ac999dd18e5a5529793f548420d69ab70d8c98f8e29195354011c43222
5
5
  SHA512:
6
- metadata.gz: 1863c446c1cddcac3fac7f3bbdd8fd27b392d7c14014daf02639837dad6061058d05d23a4938e432a83007d8c01cc200a554b46635c147e0cac9aa500cd8dbf1
7
- data.tar.gz: 14411df40b0463fe1851364e8157777281164e6b9d1112f1835929f6769f1b86c33d05e50c281509d4c45089281785e03a6eebba54a51a2518b6631c21dd2f8c
6
+ metadata.gz: d90e5b71167430ef4a4eb85c3a3024f207757a28593c71bfe398230e724cbf378755deea51921f73136031d1bbca6b7b03f7629baca83bc4fe711ca301fd51b3
7
+ data.tar.gz: 7918d5ffaa197c6c36d0e38d95efb1cf906bf4d8fed5c00e218cfac5e66c47dc55a690b088808ab3b10a0bc301783594f766216ba1fabd9ab5091455d315ea7a
data/lib/neh/cli/base.rb CHANGED
@@ -11,22 +11,18 @@ require 'pry' if ENV['NEH_DEBUG']
11
11
  require 'active_support/all'
12
12
 
13
13
  class Neh::Cli::Base # rubocop:disable Metrics/ClassLength
14
+ attr_reader :uuid
15
+
14
16
  def initialize(*args, options:)
15
17
  @message = args.join(' ')
16
-
17
18
  @options = options
18
- server_host = ENV.fetch('NEH_SERVER_HOST', 'yoryo.gipcompany.com')
19
- server_port = ENV.fetch('NEH_SERVER_PORT', 443)
20
- @channel = 'LargeLanguageModelQueryChannel'
21
- @uuid = SecureRandom.uuid
22
- url = "ws://#{server_host}:#{server_port}/cable?uuid=#{@uuid}"
23
- @endpoint = Async::HTTP::Endpoint.parse(url)
24
19
  @message_pool = {}
25
20
  @expected_sequence_number = 1
21
+ @uuid = SecureRandom.uuid
26
22
  end
27
23
 
28
24
  def execute
29
- Async::WebSocket::Client.connect(@endpoint, headers: { 'Authorization' => "Bearer #{token}" }) do |connection|
25
+ Async::WebSocket::Client.connect(endpoint, headers: { 'Authorization' => "Bearer #{token}" }) do |connection|
30
26
  while (message = connection.read)
31
27
  parsed_message =
32
28
  JSON.parse(message, symbolize_names: true)
@@ -106,19 +102,23 @@ class Neh::Cli::Base # rubocop:disable Metrics/ClassLength
106
102
  {
107
103
  command: :subscribe,
108
104
  identifier: {
109
- channel: @channel,
110
- uuid: @uuid
105
+ channel:,
106
+ uuid:
111
107
  }.to_json
112
108
  }
113
109
  connection.write(content.to_json)
114
110
  connection.flush
115
111
  end
116
112
 
113
+ def channel
114
+ 'LargeLanguageModelQueryChannel'
115
+ end
116
+
117
117
  def on_subscribed
118
118
  response = http_connection.post("/api/neh/#{command}") do |req|
119
119
  req.body = {
120
120
  message: @message,
121
- uuid: @uuid,
121
+ uuid:,
122
122
  token:
123
123
  }.to_json
124
124
 
@@ -141,13 +141,20 @@ class Neh::Cli::Base # rubocop:disable Metrics/ClassLength
141
141
  end
142
142
 
143
143
  def http_connection
144
- Faraday.new(url: "#{protocol}://#{@endpoint.hostname}:#{@endpoint.port}") do |faraday|
144
+ Faraday.new(url:) do |faraday|
145
145
  faraday.adapter Faraday.default_adapter
146
146
  faraday.headers['Authorization'] = "Bearer #{token}"
147
147
  end
148
148
  end
149
149
 
150
- def protocol
151
- @endpoint.secure? ? 'https' : 'http'
150
+ def endpoint
151
+ Async::HTTP::Endpoint.parse(
152
+ url,
153
+ alpn_protocols: Async::HTTP::Protocol::HTTP11.names #=> ["http/1.1"]
154
+ )
155
+ end
156
+
157
+ def url
158
+ ENV['WORKING_ON_LOCALHOST'].present? ? "http://localhost:6060/cable?uuid=#{uuid}" : "https://yoryo-app.onrender.com/cable?uuid=#{uuid}"
152
159
  end
153
160
  end
data/lib/neh/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Neh
4
- VERSION = "0.0.23"
4
+ VERSION = "0.0.24"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Atsushi Ishida
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-24 00:00:00.000000000 Z
11
+ date: 2024-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport