neh 0.0.2 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -4
- data/.ruby-version +1 -0
- data/README.md +4 -29
- data/Rakefile +3 -3
- data/exe/neh +2 -2
- data/lib/neh/cli/o.rb +116 -0
- data/lib/neh/cli.rb +8 -0
- data/lib/neh/thor.rb +13 -0
- data/lib/neh/version.rb +1 -1
- data/lib/neh.rb +0 -10
- metadata +67 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc1528192324a5997074137ab0d636237810ce173d1bc225953341324fc938ee
|
4
|
+
data.tar.gz: d3f023deea9467aa4992a4ae9555311aa54c68cc248051f7870d823eccca24e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5757aabd566a847f24288e33c0c8113ee6d03f156026b8936ae32c0c6417ef18fb293383a88b5f087a2a9dac88fe0782e81e3c7e01ec480ca5a67e213bf7b87f
|
7
|
+
data.tar.gz: ad3f5f8b210075b6710af46b58e7e01c0b6bff9d4b1cfb25b8cd041ba0440d93342b7189351e11a15dc09a09a9535ab0b49beb12152c32fc3d35853a6786cbe9
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion:
|
2
|
+
TargetRubyVersion: <%= File.read(File.expand_path('../.ruby-version', __FILE__)).strip %>
|
3
|
+
NewCops: enable
|
3
4
|
|
5
|
+
Metrics/MethodLength:
|
6
|
+
Max: 20
|
7
|
+
Style/ClassAndModuleChildren:
|
8
|
+
Enabled: false
|
9
|
+
Style/Documentation:
|
10
|
+
Enabled: false
|
4
11
|
Style/StringLiterals:
|
5
|
-
|
6
|
-
|
12
|
+
Enabled: false
|
7
13
|
Style/StringLiteralsInInterpolation:
|
8
|
-
|
14
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.2
|
data/README.md
CHANGED
@@ -1,31 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# neh
|
2
2
|
|
3
|
-
|
3
|
+
Check connectivity from the client to the server.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
-
|
11
|
-
Install the gem and add to the application's Gemfile by executing:
|
12
|
-
|
13
|
-
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
14
|
-
|
15
|
-
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
-
|
17
|
-
$ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
TODO: Write usage instructions here
|
22
|
-
|
23
|
-
## Development
|
24
|
-
|
25
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
26
|
-
|
27
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
|
-
|
29
|
-
## Contributing
|
30
|
-
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/neh.
|
5
|
+
$ bundle exec neh o
|
6
|
+
Worker Progress ====================== 5/5 100.00%
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
require
|
8
|
+
require 'rubocop/rake_task'
|
9
9
|
|
10
10
|
RuboCop::RakeTask.new
|
11
11
|
|
data/exe/neh
CHANGED
data/lib/neh/cli/o.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
require 'net/http'
|
5
|
+
require 'async'
|
6
|
+
require 'async/io/stream'
|
7
|
+
require 'async/http/endpoint'
|
8
|
+
require 'async/websocket/client'
|
9
|
+
require 'ruby-progressbar'
|
10
|
+
require 'faraday'
|
11
|
+
require 'pry'
|
12
|
+
|
13
|
+
class Neh::Cli::O
|
14
|
+
def initialize(*args, options:)
|
15
|
+
@message = args.join(' ')
|
16
|
+
|
17
|
+
@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
|
+
|
22
|
+
url = "ws://#{server_host}:#{server_port}/cable"
|
23
|
+
@endpoint = Async::HTTP::Endpoint.parse(url)
|
24
|
+
end
|
25
|
+
|
26
|
+
def execute
|
27
|
+
Async do |_task|
|
28
|
+
Async::WebSocket::Client.connect(@endpoint, headers: { 'Authorization' => "Bearer #{token}" }) do |connection|
|
29
|
+
while (message = connection.read)
|
30
|
+
parsed_message =
|
31
|
+
JSON.parse(message, symbolize_names: true)
|
32
|
+
|
33
|
+
on_receive(connection, parsed_message)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def token
|
42
|
+
ENV.fetch('NEH_PERSONAL_ACCESS_TOKEN')
|
43
|
+
end
|
44
|
+
|
45
|
+
def on_receive(connection, message)
|
46
|
+
if message[:type]
|
47
|
+
handle_connection_message(connection, message)
|
48
|
+
else
|
49
|
+
handle_channel_message(connection, message[:message])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def handle_connection_message(connection, message)
|
54
|
+
type = message[:type]
|
55
|
+
|
56
|
+
case type
|
57
|
+
when 'welcome'
|
58
|
+
subscribe(connection)
|
59
|
+
when 'confirm_subscription'
|
60
|
+
on_subscribed
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def handle_channel_message(connection, message)
|
65
|
+
type = message[:type]
|
66
|
+
|
67
|
+
case type
|
68
|
+
when 'output'
|
69
|
+
print message[:message]
|
70
|
+
when 'worker_done'
|
71
|
+
puts ''
|
72
|
+
connection.close
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def subscribe(connection)
|
77
|
+
content =
|
78
|
+
{
|
79
|
+
command: :subscribe,
|
80
|
+
identifier: {
|
81
|
+
channel: @channel
|
82
|
+
}.to_json
|
83
|
+
}
|
84
|
+
connection.write(content.to_json)
|
85
|
+
connection.flush
|
86
|
+
end
|
87
|
+
|
88
|
+
def on_subscribed
|
89
|
+
response = http_connection.post("/api/neh/o") do |req|
|
90
|
+
req.body = {
|
91
|
+
message: @message,
|
92
|
+
token:
|
93
|
+
}.to_json
|
94
|
+
|
95
|
+
req.headers['Content-Type'] = 'application/json'
|
96
|
+
end
|
97
|
+
|
98
|
+
body = JSON.parse response.body
|
99
|
+
puts body['message'] if debug_mode?
|
100
|
+
end
|
101
|
+
|
102
|
+
def http_connection
|
103
|
+
Faraday.new(url: "#{protocol}://#{@endpoint.hostname}:#{@endpoint.port}") do |faraday|
|
104
|
+
faraday.adapter Faraday.default_adapter
|
105
|
+
faraday.headers['Authorization'] = "Bearer #{token}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def protocol
|
110
|
+
@endpoint.secure? ? 'https' : 'http'
|
111
|
+
end
|
112
|
+
|
113
|
+
def debug_mode?
|
114
|
+
ENV['NEH_DEBUG'] == 'true'
|
115
|
+
end
|
116
|
+
end
|
data/lib/neh/cli.rb
ADDED
data/lib/neh/thor.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
require_relative 'cli'
|
6
|
+
require_relative 'cli/o'
|
7
|
+
|
8
|
+
class Neh::Thor < Thor
|
9
|
+
desc 'o', 'This is the most standard command you can use to query an LLM AI.'
|
10
|
+
def o(*)
|
11
|
+
Neh::Cli::O.new(*, options:).execute
|
12
|
+
end
|
13
|
+
end
|
data/lib/neh/version.rb
CHANGED
data/lib/neh.rb
CHANGED
@@ -2,15 +2,5 @@
|
|
2
2
|
|
3
3
|
require_relative "neh/version"
|
4
4
|
|
5
|
-
# Neh module provides a sample greet method.
|
6
5
|
module Neh
|
7
|
-
# Error class is a standard error class used within the Neh module.
|
8
|
-
class Error < StandardError; end
|
9
|
-
|
10
|
-
# The `greet` method returns a greeting message from the Neh module.
|
11
|
-
#
|
12
|
-
# @return [String] Greeting message
|
13
|
-
def self.greet
|
14
|
-
"Hello from the neh gem!"
|
15
|
-
end
|
16
6
|
end
|
metadata
CHANGED
@@ -1,15 +1,71 @@
|
|
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.5
|
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-
|
12
|
-
dependencies:
|
11
|
+
date: 2024-07-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: async-io
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.43.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.43.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: async-websocket
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.26.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.26.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.9.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.9.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
13
69
|
description: Lightweight CLI client for interacting with AI using large language models
|
14
70
|
(LLM)
|
15
71
|
email:
|
@@ -21,11 +77,15 @@ extra_rdoc_files: []
|
|
21
77
|
files:
|
22
78
|
- ".rspec"
|
23
79
|
- ".rubocop.yml"
|
80
|
+
- ".ruby-version"
|
24
81
|
- CHANGELOG.md
|
25
82
|
- README.md
|
26
83
|
- Rakefile
|
27
84
|
- exe/neh
|
28
85
|
- lib/neh.rb
|
86
|
+
- lib/neh/cli.rb
|
87
|
+
- lib/neh/cli/o.rb
|
88
|
+
- lib/neh/thor.rb
|
29
89
|
- lib/neh/version.rb
|
30
90
|
- sig/neh.rbs
|
31
91
|
homepage: https://github.com/gipcompany/neh
|
@@ -34,22 +94,23 @@ metadata:
|
|
34
94
|
homepage_uri: https://github.com/gipcompany/neh
|
35
95
|
source_code_uri: https://github.com/gipcompany/neh
|
36
96
|
changelog_uri: https://github.com/gipcompany/neh/blob/main/CHANGELOG.md
|
97
|
+
rubygems_mfa_required: 'true'
|
37
98
|
post_install_message:
|
38
99
|
rdoc_options: []
|
39
100
|
require_paths:
|
40
101
|
- lib
|
41
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
42
103
|
requirements:
|
43
|
-
- - "
|
104
|
+
- - "~>"
|
44
105
|
- !ruby/object:Gem::Version
|
45
|
-
version: 3.
|
106
|
+
version: 3.2.2
|
46
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
108
|
requirements:
|
48
109
|
- - ">="
|
49
110
|
- !ruby/object:Gem::Version
|
50
111
|
version: '0'
|
51
112
|
requirements: []
|
52
|
-
rubygems_version: 3.5.
|
113
|
+
rubygems_version: 3.5.14
|
53
114
|
signing_key:
|
54
115
|
specification_version: 4
|
55
116
|
summary: CLI client for AI with large language models
|