neh 0.0.23 → 0.0.24
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 +4 -4
- data/lib/neh/cli/base.rb +21 -14
- data/lib/neh/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acfcef0ee91e2a3a87f1618116449112811a1db27d457f4b822618e73823935c
|
4
|
+
data.tar.gz: 8573e2ac999dd18e5a5529793f548420d69ab70d8c98f8e29195354011c43222
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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
|
110
|
-
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
|
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:
|
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
|
151
|
-
|
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
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.
|
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-
|
11
|
+
date: 2024-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|