neh 0.0.22 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/neh/cli/base.rb +21 -15
- 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
@@ -6,28 +6,23 @@ require 'async'
|
|
6
6
|
require 'async/io/stream'
|
7
7
|
require 'async/http/endpoint'
|
8
8
|
require 'async/websocket/client'
|
9
|
-
require 'ruby-progressbar'
|
10
9
|
require 'faraday'
|
11
10
|
require 'pry' if ENV['NEH_DEBUG']
|
12
11
|
require 'active_support/all'
|
13
12
|
|
14
13
|
class Neh::Cli::Base # rubocop:disable Metrics/ClassLength
|
14
|
+
attr_reader :uuid
|
15
|
+
|
15
16
|
def initialize(*args, options:)
|
16
17
|
@message = args.join(' ')
|
17
|
-
|
18
18
|
@options = options
|
19
|
-
server_host = ENV.fetch('NEH_SERVER_HOST', 'yoryo.gipcompany.com')
|
20
|
-
server_port = ENV.fetch('NEH_SERVER_PORT', 443)
|
21
|
-
@channel = 'LargeLanguageModelQueryChannel'
|
22
|
-
@uuid = SecureRandom.uuid
|
23
|
-
url = "ws://#{server_host}:#{server_port}/cable?uuid=#{@uuid}"
|
24
|
-
@endpoint = Async::HTTP::Endpoint.parse(url)
|
25
19
|
@message_pool = {}
|
26
20
|
@expected_sequence_number = 1
|
21
|
+
@uuid = SecureRandom.uuid
|
27
22
|
end
|
28
23
|
|
29
24
|
def execute
|
30
|
-
Async::WebSocket::Client.connect(
|
25
|
+
Async::WebSocket::Client.connect(endpoint, headers: { 'Authorization' => "Bearer #{token}" }) do |connection|
|
31
26
|
while (message = connection.read)
|
32
27
|
parsed_message =
|
33
28
|
JSON.parse(message, symbolize_names: true)
|
@@ -107,19 +102,23 @@ class Neh::Cli::Base # rubocop:disable Metrics/ClassLength
|
|
107
102
|
{
|
108
103
|
command: :subscribe,
|
109
104
|
identifier: {
|
110
|
-
channel
|
111
|
-
uuid:
|
105
|
+
channel:,
|
106
|
+
uuid:
|
112
107
|
}.to_json
|
113
108
|
}
|
114
109
|
connection.write(content.to_json)
|
115
110
|
connection.flush
|
116
111
|
end
|
117
112
|
|
113
|
+
def channel
|
114
|
+
'LargeLanguageModelQueryChannel'
|
115
|
+
end
|
116
|
+
|
118
117
|
def on_subscribed
|
119
118
|
response = http_connection.post("/api/neh/#{command}") do |req|
|
120
119
|
req.body = {
|
121
120
|
message: @message,
|
122
|
-
uuid
|
121
|
+
uuid:,
|
123
122
|
token:
|
124
123
|
}.to_json
|
125
124
|
|
@@ -142,13 +141,20 @@ class Neh::Cli::Base # rubocop:disable Metrics/ClassLength
|
|
142
141
|
end
|
143
142
|
|
144
143
|
def http_connection
|
145
|
-
Faraday.new(url:
|
144
|
+
Faraday.new(url:) do |faraday|
|
146
145
|
faraday.adapter Faraday.default_adapter
|
147
146
|
faraday.headers['Authorization'] = "Bearer #{token}"
|
148
147
|
end
|
149
148
|
end
|
150
149
|
|
151
|
-
def
|
152
|
-
|
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}"
|
153
159
|
end
|
154
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
|