neh 0.0.19 → 0.0.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c98adee45058fca1fd2d8ad4d4b986e9273d053336e380fa9cdc3e745bc2d25
4
- data.tar.gz: a2a97a95699a29cde7e0374be428613d34caf49cbba52610917f3e147bf32798
3
+ metadata.gz: e9a34bc3bc69cf530b83888832f87d576e01223ba302feaf5e723884878a0e91
4
+ data.tar.gz: 3986b68fa2ff9e119b5cf5a18863d45a6ac11785c8a476fac2680ddec369e209
5
5
  SHA512:
6
- metadata.gz: 02773dbfef6e5f43f48fd77d7f71587a5c3e8b811e4acbeaa47d529504257f714f5c0952e8e515bd8f90c359058fb0c4f591f54cab37ddc5f961a0bb99cafe12
7
- data.tar.gz: 48f77eebdb4b7c6b94ea5a449c39db3e56465c916d37cfd7084b46386a767302c7157b9921375742603b224abd454e13fbf0978e315f67ec238321526f6af937
6
+ metadata.gz: 5377ead7a8e6c3f86e393152496380ec1f94d2c5f432f8946bb1e463119e8a66edad9c24b5ced9513c7c6b659bcbb3ab569e97eeb0a972ae5d0b7bdd820c9d88
7
+ data.tar.gz: 20506ca2fe416565e300e7d067b1e358e39c5b8bb7d65a166ce2fbab2128870b4f9ac1883547b6f1a0e950a3daba8f10e0d9a45b0fac417dfa43f7f2a19b89a4
data/lib/neh/cli/base.rb CHANGED
@@ -11,7 +11,7 @@ require 'faraday'
11
11
  require 'pry' if ENV['NEH_DEBUG']
12
12
  require 'active_support/all'
13
13
 
14
- class Neh::Cli::Base
14
+ class Neh::Cli::Base # rubocop:disable Metrics/ClassLength
15
15
  def initialize(*args, options:)
16
16
  @message = args.join(' ')
17
17
 
@@ -19,9 +19,11 @@ class Neh::Cli::Base
19
19
  server_host = ENV.fetch('NEH_SERVER_HOST', 'yoryo.gipcompany.com')
20
20
  server_port = ENV.fetch('NEH_SERVER_PORT', 443)
21
21
  @channel = 'LargeLanguageModelQueryChannel'
22
-
23
- url = "ws://#{server_host}:#{server_port}/cable"
22
+ @uuid = SecureRandom.uuid
23
+ url = "ws://#{server_host}:#{server_port}/cable?uuid=#{@uuid}"
24
24
  @endpoint = Async::HTTP::Endpoint.parse(url)
25
+ @message_pool = {}
26
+ @expected_sequence_number = 1
25
27
  end
26
28
 
27
29
  def execute
@@ -56,11 +58,15 @@ class Neh::Cli::Base
56
58
  def handle_connection_message(connection, message)
57
59
  type = message[:type]
58
60
 
61
+ print "type: #{type}, message: #{message}" if ENV['NEH_DEBUG']
62
+
59
63
  case type
60
64
  when 'welcome'
61
65
  subscribe(connection)
62
- when 'confirm_subscription', 'ping'
66
+ when 'confirm_subscription'
63
67
  on_subscribed
68
+ when 'ping'
69
+ # do nothing
64
70
  when 'disconnect'
65
71
  puts "Connection has been disconnected. Reason: #{message[:reason]}"
66
72
  close(connection)
@@ -70,12 +76,21 @@ class Neh::Cli::Base
70
76
  end
71
77
  end
72
78
 
79
+ def process_message_in_order
80
+ while @message_pool.key?(@expected_sequence_number)
81
+ print @message_pool.delete(@expected_sequence_number)
82
+ @expected_sequence_number += 1
83
+ end
84
+ end
85
+
73
86
  def handle_channel_message(connection, message)
74
87
  type = message[:type]
88
+ sequence_number = message[:sequence_number]
75
89
 
76
90
  case type
77
91
  when 'output'
78
- print message[:message]
92
+ @message_pool[sequence_number] = message[:message]
93
+ process_message_in_order
79
94
  when 'worker_done'
80
95
  close(connection)
81
96
  end
@@ -90,7 +105,8 @@ class Neh::Cli::Base
90
105
  {
91
106
  command: :subscribe,
92
107
  identifier: {
93
- channel: @channel
108
+ channel: @channel,
109
+ uuid: @uuid
94
110
  }.to_json
95
111
  }
96
112
  connection.write(content.to_json)
@@ -101,6 +117,7 @@ class Neh::Cli::Base
101
117
  response = http_connection.post("/api/neh/#{command}") do |req|
102
118
  req.body = {
103
119
  message: @message,
120
+ uuid: @uuid,
104
121
  token:
105
122
  }.to_json
106
123
 
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.19"
4
+ VERSION = "0.0.21"
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.19
4
+ version: 0.0.21
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-12 00:00:00.000000000 Z
11
+ date: 2024-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport