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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a348fb883a6cb05766862daf8761222a2899ab9f6487296d490cdfb1dafee8ad
4
- data.tar.gz: '04319db4bc44ab64d7efc0425ccaef06a08baeb960a4613abba4e558f24ee54d'
3
+ metadata.gz: acfcef0ee91e2a3a87f1618116449112811a1db27d457f4b822618e73823935c
4
+ data.tar.gz: 8573e2ac999dd18e5a5529793f548420d69ab70d8c98f8e29195354011c43222
5
5
  SHA512:
6
- metadata.gz: 34e7279aa665e9782e2ae78626f36b4f7e94b4163e979a08746cc6fc8ca25af8845256b51739bb4d951a059e82dcbd53c326fe91ce3c51bd8a356d5eb80c729e
7
- data.tar.gz: 10b7893ee7fca52b57c3a0872a9136d83258f3602e2fe2742bc22d792c482b2b5b8649dee26e841c67b6009b803bb4ebf2ade8e7dc0212c12149f47a98f73b9d
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(@endpoint, headers: { 'Authorization' => "Bearer #{token}" }) do |connection|
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: @channel,
111
- uuid: @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: @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: "#{protocol}://#{@endpoint.hostname}:#{@endpoint.port}") do |faraday|
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 protocol
152
- @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}"
153
159
  end
154
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.22"
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.22
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-19 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